如何使用分辨率计算图像dpi。 [英] How to calculate image dpi using resolution.

查看:285
本文介绍了如何使用分辨率计算图像dpi。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述





可以告诉我如何使用图像分辨率计算图像dpi吗?



dpi计算的公式是什么?



请帮帮我。



谢谢你。



我尝试过的事情:



  Dim 图像 As  Image = Image.FromFile(Image_Path)
Dim unit As GraphicsUnit = GraphicsUnit.Point
Dim rect As RectangleF = Image.GetBounds(unit)
Dim hres As Single = Image.Horizo​​ntalResolution
Dim vres As Single = Image.VerticalResolution

解决方案

Image.Horizo​​ntalResolution属性(System.Drawing) [ ^ ]和 Image.VerticalResolution Property(System.Drawing) [ ^ ]已经为您提供了 DPI (水平和垂直)。

但是,正如 Peter_in_2780 指出的那样,这只是一个提示。


引用:

可以告诉我如何使用图像分辨率计算图像dpi吗?你没有一个不暗示另一个。



Horizo​​ntalResolution和VerticalResolution是像素的图像大小。

DPI设置是用于减小物理印刷的尺寸。

印刷宽度= Horizo​​ntalResolution / DPI

印刷高度= VerticalResolution / DPI



了解DPI,分辨率和打印与Web图像 [ ^ ]


 ' 找到它。 
Dim dx As Single,dy As Single
Dim imageFile1 As Image = Image.FromFile(SourcePath)
Dim g As Graphics = Graphics.FromImage(imageFile1)

尝试
dx = g.DpiX'
// 所选文件DPI
dy = g.DpiY

最后
g.Dispose()
结束尝试


Hi,

can any one tell me how to calculate image dpi by using resolution of an image?

what is the formula for the dpi calculation?

please help me.

Thank you.

What I have tried:

Dim Image As Image = Image.FromFile(Image_Path)
Dim unit As GraphicsUnit = GraphicsUnit.Point
Dim rect As RectangleF = Image.GetBounds(unit)
Dim hres As Single = Image.HorizontalResolution
Dim vres As Single = Image.VerticalResolution

解决方案

The Image.HorizontalResolution Property (System.Drawing)[^] and Image.VerticalResolution Property (System.Drawing)[^] already gives you the DPI (horizontal and vertical).
However, as Peter_in_2780 pointed out, that is just a hint.


Quote:

can any one tell me how to calculate image dpi by using resolution of an image?

You don't one does not imply the other.

HorizontalResolution and VerticalResolution are image size in pixels.
The DPI setting is used to reduce the size of physical printing.
printed Width = HorizontalResolution / DPI
printed Height = VerticalResolution / DPI

Understanding DPI, Resolution and Print vs. Web Images[^]


'found it.
Dim dx As Single, dy As Single
Dim imageFile1 As Image = Image.FromFile(SourcePath)
Dim g As Graphics = Graphics.FromImage(imageFile1)

Try
dx = g.DpiX '// selected file DPI
dy = g.DpiY

Finally
g.Dispose()
End Try


这篇关于如何使用分辨率计算图像dpi。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆