0

So, in the project I am working on one of the images has a source controlled by a converter to determine which picture is displayed (for quick status type indicators).

The image size is determined by screen size, as it is in a Grid Row that gets resized as the screen view changes.

When I run the app the image is very pixelated. Other similar images that do not use the converter are not. The converter only changes the source of the image, it does not apply any image manipulation.

I tried a different approach that I found on Stack Overflow (below), but I need it to resize without me specifying the width/height.

<Image Stretch="UniformToFill" Grid.Row="1">
      <Image.Source>
            <BitmapImage UriSource="{Binding MainReport.ReportStatusAndDate, Source={StaticResource globalController},Converter={StaticResource StatusToColor}}" DecodePixelType="Logical" DecodePixelWidth="50"/>
       </Image.Source>
 </Image>

This did not work.

Here is the current image and another icon for comparison. The one on the left is sized correctly. They are both of similar resolutions, much larger than displayed.

enter image description here

Here is the current code, modified to preserve image source privacy.

<Image Grid.Row="1" Source="{Binding BindingSource, Source={StaticResource globalController},Converter={StaticResource StatusToColor}}"/>

As you can see, size is left open to adapt to current screen size.

And again, the converter does NOT manipulate size in any way, it just changes the file path.

Marian Dolinský
  • 3,312
  • 3
  • 15
  • 29
K.Devillier
  • 15
  • 1
  • 5
  • What are the real pixel height n width of the two images you provided? – Justin XL Jul 03 '17 at 20:58
  • If you mean the original dimensions, the left is 2047x2047, and the right is 2083x2083. From the screenshot provided, they are about 40x40 – K.Devillier Jul 03 '17 at 22:12
  • They are huge for icons. That's why you should manually set the decode pixel width n height to something much smaller than that. Note the image control itself can still have dynamic width n height (it's inner bitmap image will simply scale up n down), it's just the inner bitmap image should have a max w n height to suit your case. – Justin XL Jul 03 '17 at 22:59
  • Does your converter simply return a String / Uri? If it's actually returning something that inherits from ImageSource that'd be a problem. Otherwise, any chance you could actually do the conversion as a property on the model? When you don't *explictly* specify an ImageSource but use string / URI bindings with {Binding } syntax, Windows will automatically control and update the DecodePixelWidth for you. As soon as you provide any other ImageSource however, it's up to you. So basically, what's the converter look like? – Johnny Westlake Jul 05 '17 at 07:47
  • The converter only changes the URI, and the images are in the project's assets folder. I will try resizing the images smaller and see if it helps. I will also try setting the bitmap height/width again – K.Devillier Jul 05 '17 at 13:41
  • Ok, so I resized the image smaller (500x500) and then set the bitmap image and now it's fine. I'm not sure why it didn't work the first time I tried it. – K.Devillier Jul 05 '17 at 15:14
  • If you want to post your answer, I will go ahead and mark it :) – K.Devillier Jul 05 '17 at 15:15

0 Answers0