【发布时间】: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[]));
}
虽然这一切似乎都运行良好,而且大部分都很好,但用户说他们尝试在 Adobe 软件中打开调整大小的图像时收到错误消息。
插画错误:
“MyPhoto.jpg”文件格式未知,无法打开。
Photoshop 错误:
无法完成您的请求,因为 JPEG 未知或无效 找到了标记类型。
正如我所说,我可以在 Windows 查看器、Picasa、GIMP 等中正常打开图像。 似乎只是 Adobe 软件有问题。
有什么想法吗?谢谢
【问题讨论】:
-
你可以试试
Bitmap result = new Bitmap(newWidth, newHeight, Format24bppRgb); -
@TaW 试一试,但同样的错误,感谢您的建议
-
你能发一张那些可疑的图片吗?
-
你有没有想过这个问题?我遇到了同样的问题。
-
@Andrew 不,抱歉。我从没干过。我换了工作,这不再是一个问题。如果您发现了它,我真的很乐意为您发布答案。
标签: c# .net-4.0 photoshop image-resizing adobe-illustrator