![]() |
![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
|
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 | 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 Specs![]() |
| | #2 (permalink) |
| Guest | 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 Specs![]() |
| | #3 (permalink) |
| Guest | 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 Specs![]() |
| | #4 (permalink) |
| Guest | 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 Specs![]() |
![]() |
| Thread Tools | |
| Display Modes | |
| |
Similar Threads | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Binding an ImageBrush Problem | star-italia | .NET General | 5 | 06-13-2008 02:36 AM |
| Creating an BitmapImage from an ImageBrush? | scott.browse@gmail.com | Avalon | 0 | 08-13-2007 05:46 PM |
| ImageBrush & 3D | John | Avalon | 1 | 10-24-2006 11:01 AM |
| ImageBrush Tiling | Kevin Hoffman | Avalon | 2 | 03-03-2006 10:26 PM |
| ImageBrush TileMode not working? | Corrado Cavalli [MVP] | Avalon | 3 | 01-10-2006 03:52 PM |