C# .NET调整大小的图像可以';不能在Adobe软件中打开
我正在按如下方式调整图像大小:C# .NET调整大小的图像可以';不能在Adobe软件中打开,c#,.net-4.0,photoshop,image-resizing,adobe-illustrator,C#,.net 4.0,Photoshop,Image Resizing,Adobe Illustrator,我正在按如下方式调整图像大小: 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
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错误:
文件“MyPhoto.jpg”的格式未知,无法打开
Photoshop错误:
无法完成您的请求,因为存在未知或无效的JPEG
找到标记类型
正如我所说,我可以在Windows viewer、Picasa、GIMP等中打开图像。
似乎只是Adobe软件的问题
有什么想法吗?谢谢保存时只需包含
ImageFormat
即可解决此问题
image.Save("filename.jpg", ImageFormat.Jpeg)
您可以尝试
位图结果=新位图(newWidth、newHeight、Format24bppRgb)
@TaW尝试了一下,但还是出现了同样的错误,谢谢你的建议。你能发布一张可疑的图片吗?你有没有发现这个问题?我遇到了同样的问题。@Andrew不,对不起。我从来没有这样做过。我换了工作,这不再是一个问题。如果你发现了这件事,我真的很希望你能给我一个答案。