How to Get DPI of Image in C#

爷,独闯天下 提交于 2019-12-08 15:46:35

问题


how can i get dpi of an image using asp.net c#


回答1:


How about Image.HorizontalResolution and Image.VerticalResolution? Like this:

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



回答2:


The answer is stated in this post, which sources it's code from 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");
        }
    }
}


来源:https://stackoverflow.com/questions/2054540/how-to-get-dpi-of-image-in-c-sharp

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!