简体   繁体   English

根据高度/宽度C#设置图像DPI

[英]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. 我正在写一个应用程序将一些图像发送给第三方,图像必须是200x200 DPI。 The image is a Bitmap and is sized at 500 width and 250 height. 图像是位图,大小为500宽度和250高度。

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. 我只使用image.SetResolution(200,200)将其正确设置为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? 是否有一个比例,我可以使用,以便每增加一个分辨率的X单位,我只增加相应的高度或宽度Y单位? 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概念。 DPI comes into play when reproducing an image on a physical device. DPI在物理设备上再现图像时起作用。

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. 您需要根据物理设备的DPI以及该设备上所需的输出大小来调整图像大小。

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. 例如,如果打印机告诉您需要300dpi的图像来填充4in x 4in的空间,那么您将为它们提供尺寸为1200x1200像素的位图。 This image would end up with a physical size of 4in x 4in on a 300dpi output device. 该图像最终在300dpi输出设备上的物理尺寸为4英寸x 4英寸。 On a 600dpi device the same image would have an output size of 2in x 2in. 在600dpi设备上,相同的图像输出大小为2英寸x 2英寸。

When dealing with digital images, you usually refer to PPI, which is pixels per inch. 处理数字图像时,通常会参考PPI,即每英寸像素数。 DPI is not directly related to digital image resolution. DPI与数字图像分辨率没有直接关系。

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. 因此,如果你看一张200px×200px @ 200PPI的图像,你的图像将是1英寸×1英寸。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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