BitmapImage에 비트 맵 변환에 대한 나의 이전 방법이었다 :
MemoryStream ms = new MemoryStream();
bitmap.Save(ms, ImageFormat.Png);
ms.Position = 0;
BitmapImage bi = new BitmapImage();
bi.BeginInit();
bi.StreamSource = ms;
bi.EndInit();
내가 사용하여 속도를 높일 수 있었다
Imaging.CreateBitmapSourceFromHBitmap(bitmap.GetHbitmap(),
IntPtr.Zero,
Int32Rect.Empty,
System.Windows.Media.Imaging.BitmapSizeOptions.FromEmptyOptions());
편집 : 이것을 사용하는 사람은 비트 맵을 알아야합니다 .GetHbitmap cre 이는 .NET 가비지 컬렉터에 의해 뽑힐 실 거예요 및 메모리 누수를 방지하기 위해 삭제해야합니다 관리되지 않는 때문에 ATES가 관리되지 않는 개체가, 주위에 거짓말을, 다음 코드를 사용하여이를 해결하기 위해 :
[System.Runtime.InteropServices.DllImport("gdi32.dll")]
public static extern bool DeleteObject(IntPtr hObject);
IntPtr hBitmap = bitmap.GetHbitmap();
try
{
imageSource = Imaging.CreateBitmapSourceFromHBitmap(hBitmap,
IntPtr.Zero,
Int32Rect.Empty,
System.Windows.Media.Imaging.BitmapSizeOptions.FromEmptyOptions());
}
catch (Exception e) { }
finally
{
DeleteObject(hBitmap);
}
을 (이 아니 같은 깔끔한 DLL을 가져올 필요가 있지만 이것은 msdn에서 찍은이 문제를 해결할 수있는 유일한 방법 인 것 같습니다 - http://msdn.microsoft.com/en-us/library/1dz311e4.aspx