Memory usage of images in WPF

681 views Asked by At

This is a comprehension question.

When I have an jpeg image (A4, 96DPI, 24 bits per pixel) which takes up 200KB at 90% quality level on the disk and I load it in WPF (e.g. with XAML).

<Image Source="MyJpeg.jpg"></Image>

WPF would have memory consumption for the image of not (only) 200KB but at least 8.27 x 11.69 X 96² X 24 / 8 / 1024 = 2610.26KB, right?

with:

Size of A4 =  8.27 inch  x 11.69 inch 
Pixels in the whole picture = [Size of A4] x 96²
Bits for the whole picture = [Pixels in the whole picture] x 24
Bytes for the whole picture = [Bits for the whole picture] / 8
1

There are 1 answers

7
mathieu On BEST ANSWER

The DPI is only useful when you want to know the physical size of your image on a physical display (screen, paper).

Your jpg image has a width and a height, in pixels. When used as an image source, it will get converted to a bitmap, whose size will roughly be, in bits :

width * height * bits per pixel