![]() |
![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
|
Welcome to Vista Forums we are your forum to discuss Windows Vista x64 and x86 systems. Whether you need help or just want to post an idea you have on Vista, this is the forum for you.
br> br> |
| |||||||
![]() |
| | Thread Tools | Display Modes |
| | #1 (permalink) |
| Guest | How to get a area of an image Newbie question. In my application I display an Image and I want to also be able to display parts of the image in another location on my screen, for instance, I'd like to be able to set the height and width to 100 and 100 and get a 100 x 100px square from the top left corner of the image. Or something similiar to that effect. |
My System Specs![]() |
| | #2 (permalink) |
| Guest | Re: How to get a area of an image I'd recommend using a TileBrush for this purpose. Since your content is known to be an Image, you can use an ImageBrush elsewhere in your scene to reference the Image.Source and set the ViewBox to 0,0,100,100 and ViewboxUnits to Absolute. Alternately, and more generally, you can set the same on a VisualBrush which references the Image Element itself - this will work for any Element. You can then display different parts of the ImageSource/Element by manipulating the ViewBox or the Brush.Transform property, whichever you prefer. -Adam Smith [MS] "John Lorenzen" <lorenzen_J@hotmail.com> wrote in message news:OLp8KCQ1GHA.4108@TK2MSFTNGP04.phx.gbl... > Newbie question. > > In my application I display an Image and I want to also be able to display > parts of the image in another location on my screen, for instance, I'd > like to be able to set the height and width to 100 and 100 and get a 100 x > 100px square from the top left corner of the image. Or something similiar > to that effect. > > |
My System Specs![]() |
| | #3 (permalink) |
| Guest | Re: How to get a area of an image Thanks for your repsonse Adam, after trying many things I decided the Visual Brush was my best bet but now I have another problem once I get area of my image i'm interested in then I want to set the Opacity of my main image, because i'm using a Visual Brush the area is also displayed with the same Opacity which is not what I want, is there a way to convert the visual brush to a bitmap then use the bitmap. Here is the code I've got so far. Rectangle myRectangle = new Rectangle(); myRectangle.Height = 100; myRectangle.Width = DocGrid.Width; VisualBrush myBrush = new VisualBrush(DocImage); myBrush.Viewbox = new Rect(0,620,500,400); myBrush.ViewboxUnits = BrushMappingMode.Absolute; myBrush.Stretch = Stretch.None; myRectangle.Fill = myBrush; DocGrid.Children.Add(myRectangle); //Todo Set DocImage.Opacity to 20; "Adam Smith [MS]" <Adam.Smith@microsoft.com> wrote in message news:urXN6Zb1GHA.1300@TK2MSFTNGP05.phx.gbl... > I'd recommend using a TileBrush for this purpose. Since your content is > known to be an Image, you can use an ImageBrush elsewhere in your scene to > reference the Image.Source and set the ViewBox to 0,0,100,100 and > ViewboxUnits to Absolute. Alternately, and more generally, you can set > the same on a VisualBrush which references the Image Element itself - this > will work for any Element. You can then display different parts of the > ImageSource/Element by manipulating the ViewBox or the Brush.Transform > property, whichever you prefer. > > -Adam Smith [MS] > > "John Lorenzen" <lorenzen_J@hotmail.com> wrote in message > news:OLp8KCQ1GHA.4108@TK2MSFTNGP04.phx.gbl... >> Newbie question. >> >> In my application I display an Image and I want to also be able to >> display parts of the image in another location on my screen, for >> instance, I'd like to be able to set the height and width to 100 and 100 >> and get a 100 x 100px square from the top left corner of the image. Or >> something similiar to that effect. >> >> > > |
My System Specs![]() |
| | #4 (permalink) |
| Guest | Re: How to get a area of an image There are ways to flatten using RenderTargetBitmap, but I'd recommend against it in this situation - it'll add memory usage, and it won't allow dynamic changes if you ever want to go that route. Rather, what I'd recommend is that you wrap DocImage in another Element (probably Border) and change the Opacity on that Element rather than the DocImage itself. -Adam Smith [MS] "John Lorenzen" <johnl@fidlar.com> wrote in message news:euCFbte1GHA.1268@TK2MSFTNGP02.phx.gbl... > Thanks for your repsonse Adam, after trying many things I decided the > Visual Brush was my best bet but now I have another problem once I get > area of my image i'm interested in then I want to set the Opacity of my > main image, because i'm using a Visual Brush the area is also displayed > with the same Opacity which is not what I want, is there a way to convert > the visual brush to a bitmap then use the bitmap. Here is the code I've > got so far. > Rectangle myRectangle = new Rectangle(); > > > myRectangle.Height = 100; > > myRectangle.Width = DocGrid.Width; > > > VisualBrush myBrush = new VisualBrush(DocImage); > > > myBrush.Viewbox = new Rect(0,620,500,400); > > myBrush.ViewboxUnits = BrushMappingMode.Absolute; > > myBrush.Stretch = Stretch.None; > > > myRectangle.Fill = myBrush; > > > DocGrid.Children.Add(myRectangle); > > > > //Todo Set DocImage.Opacity to 20; > > > > "Adam Smith [MS]" <Adam.Smith@microsoft.com> wrote in message > news:urXN6Zb1GHA.1300@TK2MSFTNGP05.phx.gbl... >> I'd recommend using a TileBrush for this purpose. Since your content is >> known to be an Image, you can use an ImageBrush elsewhere in your scene >> to reference the Image.Source and set the ViewBox to 0,0,100,100 and >> ViewboxUnits to Absolute. Alternately, and more generally, you can set >> the same on a VisualBrush which references the Image Element itself - >> this will work for any Element. You can then display different parts of >> the ImageSource/Element by manipulating the ViewBox or the >> Brush.Transform property, whichever you prefer. >> >> -Adam Smith [MS] >> >> "John Lorenzen" <lorenzen_J@hotmail.com> wrote in message >> news:OLp8KCQ1GHA.4108@TK2MSFTNGP04.phx.gbl... >>> Newbie question. >>> >>> In my application I display an Image and I want to also be able to >>> display parts of the image in another location on my screen, for >>> instance, I'd like to be able to set the height and width to 100 and 100 >>> and get a 100 x 100px square from the top left corner of the image. Or >>> something similiar to that effect. >>> >>> >> >> > > |
My System Specs![]() |
![]() |
| Thread Tools | |
| Display Modes | |
| |
Similar Threads | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Acronis True Image recovery of Vista Image | mrh981 | Vista General | 1 | 07-01-2008 09:57 PM |
| Notofication Area | Mark | Vista General | 5 | 09-08-2007 05:22 PM |
| Image Restore Problem: Can't Locate Image | Paputxi | Vista General | 4 | 07-13-2007 05:52 PM |
| Ntivfication Area | Martin Racette | Vista General | 0 | 02-22-2007 09:18 AM |
| Button with regular image and disabled image | loumfranco@gmail.com | Avalon | 1 | 05-31-2006 02:47 PM |