Hallo,
naja "ohne Festplatte" geht immer. Zur Not speicherst du es in einem MemoryStream. Ich kann auch nicht nachvollziehen, warum es im .NET-Framework eine solche Methode nicht gibt. Ich habe damals folgende Hilfsfunktionen gefunden:
1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29: 30: 31: 32: 33:
| public static System.Drawing.Bitmap BitmapSourceToBitmap(BitmapSource srs) { System.Drawing.Bitmap btm = null;
int width = srs.PixelWidth; int height = srs.PixelHeight; int stride = width * ((srs.Format.BitsPerPixel + 7) / 8);
byte[] bits = new byte[height * stride]; srs.CopyPixels(bits, stride, 0);
unsafe { fixed (byte* pB = bits) { IntPtr ptr = new IntPtr(pB);
btm = new System.Drawing.Bitmap(width, height, stride, System.Drawing.Imaging.PixelFormat.Format32bppPArgb, ptr); } } return btm; }
public static BitmapSource ConvertToBitmapSource(System.Drawing.Bitmap gdiPlusBitmap) { IntPtr hBitmap = gdiPlusBitmap.GetHbitmap();
BitmapSource source = System.Windows.Interop.Imaging.CreateBitmapSourceFromHBitmap(hBitmap, IntPtr.Zero, Int32Rect.Empty, BitmapSizeOptions.FromEmptyOptions());
return source;
} |
Funktioniert tadellos, aber mehr (Performance, Speicher, ...) hab ich mich damit nicht beschäftigt...
Gruß