0
이 질문에 대한 답변은 이미 빠졌으나 어떻게 든 문제를 해결할 수는 없습니다.gdi + 콘솔 응용 프로그램에서 이미지를 저장하는 중 오류가 발생했습니다.
using (var stream = new FileStream(@"D:\test\6.png", FileMode.Open))
{
var path = @"D:\test1\";
using (var image = Image.FromStream(stream))
{
var newWidth = (int)(image.Width * 0.5);
var newHeight = (int)(image.Height * 0.5);
var thumbnailImg = new Bitmap(newWidth, newHeight);
var thumbGraph = Graphics.FromImage(thumbnailImg);
thumbGraph.CompositingQuality = CompositingQuality.HighQuality;
thumbGraph.SmoothingMode = SmoothingMode.HighQuality;
thumbGraph.InterpolationMode = InterpolationMode.HighQualityBicubic;
var imageRectangle = new Rectangle(0, 0, newWidth, newHeight);
thumbGraph.DrawImage(image, imageRectangle);
thumbnailImg.Save(path, image.RawFormat);
}
}
나는 다음과 같은 코드를 실행하면 내가 얻을 유형 'System.Runtime.InteropServices.ExternalException'처리되지 않은 예외는 System.Drawing.dll에서 발생
추가
같은 오류 정보 : GDI +에서 일반 오류가 발생했습니다.
'경로'변수는 무엇입니까? FileStream에서 현재 사용중인 동일한 이미지를 덮어 쓰려고하는 경우. 또한 newWidth와 newHeight는 0보다 크다 :-) 마지막 사항 : 어떤 식 으로든 입력 값 6.png이 손상되지 않았는지 확인하십시오. –
path 변수에 대해 내 게시물을 편집했습니다. newWidth 및 newHeight는 모두 0보다 큽니다. – user936999