Windows Vista Forums
Vista Forums Home Join Vista Forums Windows 7 Forum Vista Tutorials Tags
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.

Go Back   Vista Forums > Misc Newsgroups > Avalon

Vista - How to get a area of an image

 
 
Old 09-10-2006   #1 (permalink)
John Lorenzen


 
 

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 SpecsSystem Spec
Old 09-11-2006   #2 (permalink)
Adam Smith [MS]


 
 

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 SpecsSystem Spec
Old 09-11-2006   #3 (permalink)
John Lorenzen


 
 

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 SpecsSystem Spec
Old 09-14-2006   #4 (permalink)
Adam Smith [MS]


 
 

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 SpecsSystem Spec
 

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


Vista Forums is an independent web site and has not been authorized,
sponsored, or otherwise approved by Microsoft Corporation.
"Windows Vista", the Start Orb, and related materials are trademarks of Microsoft Corp.
© Designer Media Ltd

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46