Windows Vista Forums
Vista Forums Home Join Vista Forums Webcasts Vista Tutorials Tags

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.
Register at Vista forums...the world biggest Windows Vista resource Join Vista Forums Now

Go Back   Vista Forums > Microsoft Technical Newsgroups > Avalon

How to get a area of an image

Update your Vista Drivers Update Your Drivers Now!!
Closed Thread
 
Thread Tools Display Modes
Old 09-10-2006   #1 (permalink)
John Lorenzen
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 SpecsSystem Spec
Old 09-11-2006   #2 (permalink)
Adam Smith [MS]
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 SpecsSystem Spec
Old 09-11-2006   #3 (permalink)
John Lorenzen
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 SpecsSystem Spec
Old 09-14-2006   #4 (permalink)
Adam Smith [MS]
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 SpecsSystem Spec
Closed Thread

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


Vistax64.com 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 2005-2008

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 47 48 49 50 51