Saint Domino
Saint Domino

Reputation: 1412

WPF JpegBitmapDecoder creating different height and width

I'm attempting to read in a Jpeg image and bind it to a rectangle's fill property with the following code:

Dim filePath as string = "PathToJpeg.jpg"     
Dim imageStreamSource As New FileStream(filePath, FileMode.Open, FileAccess.Read, FileShare.Read)
Dim decoder As New JpegBitmapDecoder(imageStreamSource, BitmapCreateOptions.PreservePixelFormat, BitmapCacheOption.Default)
Dim bitmapSource As BitmapSource = decoder.Frames(0)

When I read this in with smaller images, this works ok. But when I point it to a graphic that's 3840 by 3024, bitmmapSource.Height reads 924 and bitmapSource.Width reads 1174

From what I can tell, it's almost like 1024x768 is the upper limit

Am I missing something obvious here?

Upvotes: 2

Views: 753

Answers (1)

0xBADF00D
0xBADF00D

Reputation: 1034

I do not really know why you are using a JpegBitmapDecoder explicitly. My C# code for this is pretty simple:

BitmapSource bitmapSource = new BitmapImage(new Uri(@"PathToJpeg.jpg"));

The BitmapSource class offers two width and height properties:

Width: Gets the width of the bitmap in device-independent units (1/96th inch per unit). (From MSDN)

PixelWidth: Gets the width of the bitmap in pixels.(From MSDN)

I tested this with a 111 MPixel image and it works fine.

Upvotes: 1

Related Questions