相关疑难解决方法(0)

获取图像尺寸而不读取整个文件

有没有一种廉价的方式来获得图像的尺寸(jpg,png,...)?最好,我想只使用标准类库(因为托管限制)来实现这一点.我知道读取图像标题并自己解析它应该相对容易,但似乎这样的东西应该已经存在了.此外,我已经验证以下代码片段读取整个图像(我不想要):

using System;
using System.Drawing;

namespace Test
{
    class Program
    {
        static void Main(string[] args)
        {
            Image img = new Bitmap("test.png");
            System.Console.WriteLine(img.Width + " x " + img.Height);
        }
    }
}
Run Code Online (Sandbox Code Playgroud)

.net c# image-manipulation image

103
推荐指数
7
解决办法
8万
查看次数

标签 统计

.net ×1

c# ×1

image ×1

image-manipulation ×1