【问题标题】:.NET resized images can't be opened in Adobe software.NET 调整大小的图像无法在 Adob​​e 软件中打开
【发布时间】:2014-08-22 12:16:31
【问题描述】:

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

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[]));
}

虽然这一切似乎都运行良好,而且大部分都很好,但用户说他们尝试在 Adob​​e 软件中打开调整大小的图像时收到错误消息。

插画错误:

“MyPhoto.jpg”文件格式未知,无法打开。

Photoshop 错误:

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

正如我所说,我可以在 Windows 查看器、Picasa、GIMP 等中正常打开图像。 似乎只是 Adob​​e 软件有问题。

有什么想法吗?谢谢

【问题讨论】:

  • 你可以试试Bitmap result = new Bitmap(newWidth, newHeight, Format24bppRgb);
  • @TaW 试一试,但同样的错误,感谢您的建议
  • 你能发一张那些可疑的图片吗?
  • 你有没有想过这个问题?我遇到了同样的问题。
  • @Andrew 不,抱歉。我从没干过。我换了工作,这不再是一个问题。如果您发现了它,我真的很乐意为您发布答案。

标签: c# .net-4.0 photoshop image-resizing adobe-illustrator


【解决方案1】:

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

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

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2019-02-16
    • 1970-01-01
    • 2020-02-07
    • 2018-06-17
    • 2011-06-28
    • 1970-01-01
    • 1970-01-01
    • 2013-08-02
    相关资源
    最近更新 更多