martinyyyy
martinyyyy

Reputation: 1660

Photo Dimensions wrong in WPF

I have a picture here with a width of 2008px. If I read this picture with WPF using this code:

            byte[] baSource = File.ReadAllBytes(strFileName);
        using (Stream streamPhoto = new MemoryStream(baSource))
        {
            BitmapFrame bfPhoto = ReadBitmapFrame(streamPhoto);
            Console.WriteLine(bfPhoto.Width);       }

It tells me the picture is 52607,9686523093px width .. I don't understand why. (same for the heigtht)

Upvotes: 1

Views: 175

Answers (1)

Gabe
Gabe

Reputation: 86838

If you go to http://msdn.microsoft.com/en-us/library/system.windows.media.imaging.bitmapframe.aspx you will see that the Width property "Gets the width of the bitmap in device-independent units (1/96th inch per unit)." What you want is PixelWidth: "Gets the width of the bitmap in pixels."

Upvotes: 1

Related Questions