如何在C#中获取图像的DPI

时间:2010-01-13 05:00:18

标签: c# dpi

如何使用asp.net c#

获取图像的dpi

2 个答案:

答案 0 :(得分:23)

Image.HorizontalResolutionImage.VerticalResolution怎么样?像这样:

System.Drawing.Image image = System.Drawing.Image.FromFile("TestImage.bmp");
var dpiX = image.HorizontalResolution;
var dpiY = image.VerticalResolution;

答案 1 :(得分:0)

答案在this post中说明,它从here获取代码:

using System;
using System.Drawing;

namespace BitmapDpi
{
    class Program
    {
        static void Main(string[] args)
        {
            Bitmap bmp = new Bitmap("winter.jpg");
            Console.WriteLine("Image resolution: " + bmp.HorizontalResolution + "DPI");
        }
    }
}