Answered by:
Bitmap resolution

Question
-
Question 1:
When i create a bitmap object from a bitmap file, and check it's horizontal resolution, sometimes the resolution is the same like when i open the same image in MS Paint and sometime is not. What is going on? For example, I open an image in my program and it's 96dpi, and that same image in MS Paint shows 72dpi. But they appear to be exactly the same size on the screen when I line up both programs and compare images visually. My desktop dpi is 96. I think, but I'm not sure, with JPG files this problem doesn't exist.
Question 2:
When I create a new blank image in MS Paint it's always 72dpi regardless of the screen dpi which is 96. Why is that?Tuesday, May 26, 2009 4:10 PM
Answers
-
1) The DPI settings in a bitmap really have nothing to do with the data in the image itself - they are just hints for printing. They just say "if you're going to print this image, make each pixel 1/72 inces or 1/96 inches wide" - but the image data is in pixels, and saved in a certain number of (usually 24) bits per pixel of the image. When you display the image on the screen, it's going to display in pixels, not in DPI - so if your screen is a certain resolution, you'll normally just see the image in it's full pixel resolution directly (unless you've scaled the image for display). You can take an image and change it's DPI hint settings, and it will have no effect on the image itself - the file won't get bigger or smaller, and the image will display on screen identically, whether it's at 50dpi or 4000dpi.
2) 72dpi is kind of the default standard for printing. Many layout programs will take an image and say it's 72dpi if the DPI settings aren't specified explicitly. MS Paint doesn't give you as much control as most full-featured image editing software. Try this in Photoshop, or Paint.NET, or another image editing program that gives more control over your images, and you'll be able to set it however you want.
Reed Copsey, Jr. - http://reedcopsey.com- Proposed as answer by JohnWein Tuesday, May 26, 2009 8:43 PM
- Marked as answer by Stardust1611 Tuesday, May 26, 2009 8:44 PM
Tuesday, May 26, 2009 5:49 PM
All replies
-
1) The DPI settings in a bitmap really have nothing to do with the data in the image itself - they are just hints for printing. They just say "if you're going to print this image, make each pixel 1/72 inces or 1/96 inches wide" - but the image data is in pixels, and saved in a certain number of (usually 24) bits per pixel of the image. When you display the image on the screen, it's going to display in pixels, not in DPI - so if your screen is a certain resolution, you'll normally just see the image in it's full pixel resolution directly (unless you've scaled the image for display). You can take an image and change it's DPI hint settings, and it will have no effect on the image itself - the file won't get bigger or smaller, and the image will display on screen identically, whether it's at 50dpi or 4000dpi.
2) 72dpi is kind of the default standard for printing. Many layout programs will take an image and say it's 72dpi if the DPI settings aren't specified explicitly. MS Paint doesn't give you as much control as most full-featured image editing software. Try this in Photoshop, or Paint.NET, or another image editing program that gives more control over your images, and you'll be able to set it however you want.
Reed Copsey, Jr. - http://reedcopsey.com- Proposed as answer by JohnWein Tuesday, May 26, 2009 8:43 PM
- Marked as answer by Stardust1611 Tuesday, May 26, 2009 8:44 PM
Tuesday, May 26, 2009 5:49 PM -
I open the image from file like this:
Bitmap b = new Bitmap(openFileDialog1.FileName); b.SetResolution(g.DpiX, g.DpiY);
g is my graphics object created earlier from an empty bitmap image b, which has screen resolution 96. I set the resolution of the opened file to the resolution of the graphics g, which also has screen resolution, and the picture appears like in MS Paint. If i don't set the resolution of the image, the image appears bigger or smaller. So this means that MS Paint changes resolution of the images to the screen resolution. I opened the same image in Photoshop, and it's the same size, which means Photoshop changes the image resolution on the screen too. If I save the image changed like this, is the saved image going to be in the screen resolution?Tuesday, May 26, 2009 6:43 PM -
I saved the image in a different file and it did change resolution indeed. It was 300x300 and when I saved it it changed to 96x96 which is my screen resolution. Does this mean that my image quality deteriorated, and it's size became smaller?
Tuesday, May 26, 2009 6:52 PM -
I checked this too. The image has remained the same size in pixel, and the file size didn't change. So the image did not deteriorate. The resolution setting of a saved image in file only indicates how large the picture will be on the screen or on the printer. Now I understand, thank you Reed. But still, why some BMP images have 72x72 in MS Paint and my code reads 96x96 from the same image created from a file?Tuesday, May 26, 2009 7:09 PM
-
MS Paint is not a reliable image editor. I would recommend sticking to Photoshop, Paint.NET, or other more sophisticated paint editors for this type of information. I don't think MS Paint recognizes DPI settings on bitmaps (only JPEG files), so it thinks all bitmaps are 72dpi.
Reed Copsey, Jr. - http://reedcopsey.comTuesday, May 26, 2009 7:28 PM -
Just forget DPI. Think of it as an arbitrary number that some programs use to store clandestine information.Tuesday, May 26, 2009 8:46 PM
-
Thanks for the clarification. I about panicked when I saw the 300ppi image I was processing was "96Dpi". Then i thought about the fact that you can explicitly set the Dpi after loading an image (and it takes no time at all). It had to be a presentation parameter. I found your post as I tried to verify that.
But the doc could be clearer on the issue.
Tuesday, December 30, 2014 11:35 PM