. net调整大小的图像无法在Adobe软件中打开

本文关键字:Adobe 软件 调整 图像 net | 更新日期: 2023-09-27 18:19:03

我正在按如下方式调整图像大小:

private byte[] ResizeImage(System.Drawing.Image image, double scaleFactor)
{
    //a holder for the result
    int newWidth = (int)(image.Width * scaleFactor);
    int newHeight = (int)(image.Height * scaleFactor);
    Bitmap result = new Bitmap(newWidth, newHeight);
    //use a graphics object to draw the resized image into the bitmap
    using (Graphics graphics = Graphics.FromImage(result))
    {
        //set the resize quality modes to high quality
        graphics.CompositingQuality = System.Drawing.Drawing2D.CompositingQuality.HighQuality;
        graphics.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.HighQualityBicubic;
        graphics.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighQuality;
        //draw the image into the target bitmap
        graphics.DrawImage(image, 0, 0, result.Width, result.Height);
    }
    //return the resulting bitmap
    ImageConverter converter = new ImageConverter();
    return (byte[])converter.ConvertTo(result, typeof(byte[]));
}

虽然这一切看起来都很完美,而且大部分都很好,但用户说当他们试图在Adobe软件中打开调整大小的图像时,他们会收到错误信息。

Illustrator错误:

文件" mphoto .jpg"格式未知,无法打开。

Photoshop错误:

无法完成您的请求,因为存在未知或无效的JPEG找到标记类型。

正如我所说,我可以在Windows查看器,Picasa, GIMP等中打开图像。似乎是Adobe软件出了问题。

任何想法?由于

. net调整大小的图像无法在Adobe软件中打开

这可以通过在保存时包含ImageFormat来解决。

image.Save("filename.jpg", ImageFormat.Jpeg)