0

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
user1182735
  • 764
  • 9
  • 21

1 Answers1

3

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

mathieu
  • 30,974
  • 4
  • 64
  • 90
  • DPI * dimensions is the same as number of pixels - so A4 * 96 DPI is what the OP said right? So you are basically saying "that's right, but I'd look at the number of pixels instead of using the dimensions/DPI" – Charleh Jul 25 '12 at 16:32
  • exact, because your image is stored as w*h pixels, regardless of DPIS. IE increasing DPI settings of your image will not "add" pixels to it. Just a hint for displaying/printing it properly. – mathieu Jul 26 '12 at 06:57
  • Yeah I got someone asking me to send my images as 300 DPI (with no dimension information) - I just changed the DPI setting in the image header and they accepted them. The pictures were huge for print, but they wouldn't accept them because of the header being wrong - people that don't know what DPI relates to can get confused.. DPI does not give you pixels unless you also have physical dimensions - hence Dots Per **Inch** – Charleh Jul 26 '12 at 09:51
  • FYI: I asked for A4 * DPI and not about pixel width and pixel height because I get the pictures from a scanner. And I have to reduce memory consumption in my application. My advice to the user was to reduce the DPI of the scans. With the post I wanted the confirmation that this would reduce memory consumption. E.G., if the DPI of the scans would be reduced from 300 DPI to 96 DPI, the memory consumption would be reduced from 20 something MB to 2,6 MB. – user1182735 Jul 27 '12 at 08:56
  • ok that explains it all :) If images are in jpeg format, you should have a look at this : http://www.codinghorror.com/blog/2006/07/a-comparison-of-jpeg-compression-levels-and-recompression.html . Adjusting compression level of your jpeg files can save lots of space – mathieu Jul 27 '12 at 08:59
  • I had a short look at the link. But this would only the reduce file size of the jpeg, right? Not the memory consumption of the bitmap?! – user1182735 Jul 27 '12 at 09:36
  • Yes it will reduce jpeg size. The bitmap size wont change – mathieu Jul 27 '12 at 09:42