简体   繁体   中英

Setting image DPI in relation to height/width C#

I'm writing an application to send some images to a third party, and the images must be 200x200 DPI. The image is a Bitmap and is sized at 500 width and 250 height.

The first time I tested the images with the third party, my resolution was incorrect. I merely used image.SetResolution(200,200) to correctly set it to 200x200. This, however, only changed the resolution tag for the image and did not properly, according to my third party technical contact, adjust the image height and width.

Is there a ratio that I can use so that for each X units I increment the resolution, I merely increment the corresponding height or width Y units? I thought that I could just increment resolution without having to increment height or width.

Thank you, Aaron.

An image stored digitally has no meaningful concept of DPI. DPI comes into play when reproducing an image on a physical device.

You need to adjust the image size with regard to the DPI of the physical device, and the desired size of the output on that device.

For example, if a printer tells you they need an image at 300dpi to fill a space of 4in x 4in then you would provide them a bitmap with a size of 1200x1200 pixels. This image would end up with a physical size of 4in x 4in on a 300dpi output device. On a 600dpi device the same image would have an output size of 2in x 2in.

When dealing with digital images, you usually refer to PPI, which is pixels per inch. DPI is not directly related to digital image resolution.

So, if you look at a image that is 200px by 200px @ 200PPI, you will have an image that is 1 inch by 1 inch.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM