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 - ImageBrush Bugs?

 
 
Old 04-11-2006   #1 (permalink)
HolaMan


 
 

ImageBrush Bugs?

Hi all

I use imagebrush to fill a rectangle
But I found the image will stretch a little for special size.
<StackPanel Background="Red">
<Rectangle Width="500" Height="300" x:Name="r">
<Rectangle.Fill>
<ImageBrush x:Name="imgBrush" ImageSource="d:\\op.png"

Stretch="None"
Viewport="0,0,27,27" ViewportUnits="Absolute"
AlignmentX="Left" AlignmentY="Top"/>
</Rectangle.Fill>
</Rectangle>
</StackPanel>

What I test is use two different size png file with alpha channel.
One is 216x108, the other one is 248x124.
But I found 248x124 is fine (mean didn't stretch), and the other is
stretch a little.
I use viewport "0,0,27,27" to check if stretch or not.
Is there any ideas for the strange result?

Thanks,

HolaMan


My System SpecsSystem Spec
Old 04-13-2006   #2 (permalink)
Adam Smith [MS]


 
 

Re: ImageBrush Bugs?

One thing to check is whether one of the .pngs has a different DPI than the
other. You can check this by right-clicking on the file and looking at the
properties dialog, then the summary tab (click the "Advanced>>>" button if
you need to on that tab).

-Adam Smith [MS]

"HolaMan" <reality.chang@gmail.com> wrote in message
news:1144813198.091445.226410@z34g2000cwc.googlegroups.com...
> Hi all
>
> I use imagebrush to fill a rectangle
> But I found the image will stretch a little for special size.
> <StackPanel Background="Red">
> <Rectangle Width="500" Height="300" x:Name="r">
> <Rectangle.Fill>
> <ImageBrush x:Name="imgBrush" ImageSource="d:\\op.png"
>
> Stretch="None"
> Viewport="0,0,27,27" ViewportUnits="Absolute"
> AlignmentX="Left" AlignmentY="Top"/>
> </Rectangle.Fill>
> </Rectangle>
> </StackPanel>
>
> What I test is use two different size png file with alpha channel.
> One is 216x108, the other one is 248x124.
> But I found 248x124 is fine (mean didn't stretch), and the other is
> stretch a little.
> I use viewport "0,0,27,27" to check if stretch or not.
> Is there any ideas for the strange result?
>
> Thanks,
>
> HolaMan
>



My System SpecsSystem Spec
Old 04-17-2006   #3 (permalink)
HolaMan


 
 

Re: ImageBrush Bugs?

Thanks for you reply
I have checked the pngs and you are right.
They have different DPI value, one is 72 and the other is 96.

:which DPI will result the right size of ImageBrush? seems 96
Thank you.

My System SpecsSystem Spec
Old 04-17-2006   #4 (permalink)
Adam Smith [MS]


 
 

Re: ImageBrush Bugs?

> which DPI will result in the right size of ImageBrush

Well, that's sort of a trick question - both DPIs can result in the
"correct" size. If, however, you always want the size WPF
reports/measures/etc to be the same as the pixel dimensions, then yes, 96
DPI will produce that mapping. When you look at the Width or Height of a
Bitmap in Avalon, this value is the width (or height) in pixels of the
Bitmap divided by the DPI * 96, because all of WPF's units are 96'ths of an
inch. This is why a bitmap with 96DPI measures at its pixel dimensions,
because the mapping is identity.

Note that a 72x72 pixel bitmap at 72 DPI is really 1 inch by 1 inch and a
96x96 pixel bitmap at 96 DPI is *also* 1 inch by 1 inch, which is why they
will measure the same in WPF even though they have different pixel
dimensions.

-Adam Smith [MS]


"HolaMan" <reality.chang@gmail.com> wrote in message
news:1145263146.871828.266720@e56g2000cwe.googlegroups.com...
> Thanks for you reply
> I have checked the pngs and you are right.
> They have different DPI value, one is 72 and the other is 96.
>
> :which DPI will result the right size of ImageBrush? seems 96
> Thank you.
>



My System SpecsSystem Spec
 

Thread Tools


Similar Threads
Thread Forum
Binding an ImageBrush Problem .NET 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