![]() |
![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
| Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks. |
| |||||||
| |
| | #1 (permalink) |
| | 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) |
| | 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) |
| | 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) |
| | 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 | |
| |
Similar Threads | ||||
| Thread | Forum | |||
| Short Cut area | Live Mail | |||
| Various Errors - winlogon.exe Bad Image, Windows - Bad Image & Window Defender | General Discussion | |||
| Acronis True Image recovery of Vista Image | Vista General | |||
| Image Restore Problem: Can't Locate Image | Vista General | |||