BitmapImage (System.Windows.Media.Imaging)를 memorystream을 통해 저장하려고하므로 결과를 사용하여 비트 맵 (System.Drawing)을 만들 수 있습니다. MemoryStream을로 인코딩 된 결과를 저장하려고 할 때MemoryStream으로 저장할 때 BitmapImage AccessViolationException이 발생합니다.
나는 간헐적으로 오류가 발생합니다 :
An exception of type 'System.AccessViolationException' occurred in PresentationCore.dll but was not handled in user code
Additional information: Attempted to read or write protected memory. This is often an indication that other memory is corrupt.
MemoryStream을의 속성은 읽기 또는 제한 시간을 쓰기가 발생한 것을 나타 내기 위해서 보인다.
WriteTimeout = 'msOut.WriteTimeout' threw an exception of type 'System.InvalidOperationException'
코드 아래의 오류가 저장 명령에 발생합니다 : 해당
System.Windows.Media.Imaging.CroppedBitmap cbi = new System.Windows.Media.Imaging.CroppedBitmap(bi, new System.Windows.Int32Rect(
(int)(imageViewBox[2] * imageViewBox[10]), (int)(imageViewBox[3] * imageViewBox[11]),
(int)((imageViewBox[4] - imageViewBox[2]) * imageViewBox[10]), (int)((imageViewBox[5] - imageViewBox[3]) * imageViewBox[11])));
newImageSize = new Size(cbi.PixelWidth, cbi.PixelHeight);
using (MemoryStream msOut = new MemoryStream())
{
System.Windows.Media.Imaging.BmpBitmapEncoder enc = new System.Windows.Media.Imaging.BmpBitmapEncoder();
enc.Frames.Add(System.Windows.Media.Imaging.BitmapFrame.Create(cbi));
// Throws access violation exception when zoomed on some images. Why?
enc.Save(msOut);
using (Bitmap temp = new Bitmap(msOut))
{ ...
이미지는 일반적으로 1000px X 500 그렇게 엄청난 수 없습니다. 어떤 아이디어가 원인 일 수 있습니까? 또는 성능을 저하시키지 않고 memorystream을 사용하지 않고 변환 작업을 수행 할 수있는 다른 방법은 무엇입니까?