Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/image-processing/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# DPI、图像宽度和高度与质量的对比_C#_Image Processing_Graphics_Dpi - Fatal编程技术网

C# DPI、图像宽度和高度与质量的对比

C# DPI、图像宽度和高度与质量的对比,c#,image-processing,graphics,dpi,C#,Image Processing,Graphics,Dpi,我正在使用以下功能创建jpeg图像 private static void Save(Bitmap bmp1, string path, ImageFormat format) { bmp1.SetResolution(72,72); ImageCodecInfo jpgEncoder = GetEncoder(format); System.Drawing.Imaging.Encoder myEncoder = System.Drawing.Imaging.Encode

我正在使用以下功能创建jpeg图像

private static void Save(Bitmap bmp1, string path, ImageFormat format)
{
    bmp1.SetResolution(72,72);
    ImageCodecInfo jpgEncoder = GetEncoder(format);
    System.Drawing.Imaging.Encoder myEncoder = System.Drawing.Imaging.Encoder.Quality;
    EncoderParameters myEncoderParameters = new EncoderParameters(1);
    myEncoderParameters.Param[0] = new EncoderParameter(myEncoder, 100L);

    bmp1.Save(path, jpgEncoder, myEncoderParameters);
}

private static ImageCodecInfo GetEncoder(ImageFormat format)
{

    ImageCodecInfo[] codecs = ImageCodecInfo.GetImageDecoders();
    foreach (ImageCodecInfo codec in codecs)
    {
        if (codec.FormatID == format.Guid)
        {
            return codec;
        }
    }

    return null;
}
正如你所见,我只使用这行代码中的DPI
bmp1.SetResolution(72,72)

我想知道,如果输出看起来相同,72 DPI版本将如何适用于网络,以及DPI在这种情况下的真正效果是什么
提示:位图是由Bézier曲线生成的。首先,72 DPI是显示设备的默认DPI。300美元用于印刷

SetResolution
实际上不会改变外观。"".

它通常会影响应用于设备时的“大小”。调用
SetResolution
对它的性能没有影响

打印时,设置图像的DPI;对于物理尺寸;和地图模式。试图通过300 DPI激光打印机在A4纸张上打印逻辑尺寸为210 mm x 294 mm的72 DPI图像将出现像素化(因为它被拉伸以填充整张纸张)

但是,如果您保持DPI,并告诉Windows该图像实际上是50 mm x 50 mm,然后在同一台300 DPI打印机上再次打印到A4,它将不会出现像素化,因为它接近1:1(尽管现在图像相当小)


重要的是要注意,在上面的两个例子中,位图并没有仅仅物理上改变它的元维度,从而改变纸上的结果大小



非常感谢你的回答,你能不能再详细解释一下这句话“它会影响”应用到设备上的东西会有多大。”@AMH,好了。同样,对于web/display,此属性不应成为问题,因为显示器通常为72 dpit。注意:MSDN使用了一个模棱两可的术语imo:“物理大小”是指磁盘或内存中的存储空间。但它也可能被(错误地)解读为打印输出的大小,这至少是“物理的”。。将“dpi”视为“像素大小”——同样:Jpg将不允许贝塞尔曲线或文本(主要是贝塞尔曲线)的清晰图像,因为它是用于摄影的;我会考虑使用PNG。但是,有一件事,特别是会降低你的图像质量,但是,是使用有损JPEG压缩。而且,不,将其保存质量设置为100%不会改变这一点。它会更大,而且还是有损耗的。对于保存到图像中的简单曲线,使用PNG可能更好。