JPG format is not working but BMP is OK

I am trying to display a bitmap image on the UI but it doesn’t work if I use a JPG file in the resources. BMP works fine but the files are 25 times the size.

Smaller bitmaps seem to work fine. The test one is 445 x 500 pixels. I preload the bitmap when the class is created and then use this code to draw the bitmap onto the Image.

            clockDisplay.Clear();
            clockDisplay.DrawImage(number0, 0, 0);
            clockImage.Source = BitmapImage.FromGraphics(clockDisplay);
            clockImage.Invalidate();

This what is looks like with BMP format in the resources.

and this is what it looks like in the JPG format in the resources

Have you tried other images?

The image size much be even number, try 444 x 500 or 446x500

That fixed it. Thanks Dat.

1 Like