Ich habe rohe Pixeldaten von einer Kamera im RGB8-Format, die ich in eine Bitmap
konvertieren muss. Die Bitmap PixelFormat
scheint jedoch nur die Formate RGB 16, 24, 32 und 48 zu unterstützen.Convert RGB8 byte [] in Bitmap
Ich habe versucht, PixelFormat.Format8bppIndexed
zu verwenden, aber das Bild erscheint verfärbt und invertiert.
public static Bitmap CopyDataToBitmap(byte[] data)
{
var bmp = new Bitmap(640, 480, PixelFormat.Format8bppIndexed);
var bmpData = bmp.LockBits(
new Rectangle(0, 0, bmp.Width, bmp.Height),
ImageLockMode.WriteOnly, bmp.PixelFormat);
Marshal.Copy(data, 0, bmpData.Scan0, data.Length);
bmp.UnlockBits(bmpData);
return bmp;
}
Gibt es eine andere Möglichkeit, diesen Datentyp korrekt zu konvertieren?
Hilfreiche Artikel: [dieser] (http://msdn.microsoft.com/en-us/library/ Windows/Desktop/ee719797 (v = vs.85) .aspx) und [dies] (http://msdn.microsoft.com/en-us/library/ms969901.aspx) –
Neugierig: Welcher Typ/Modell der Kamera produziert dieses Format? Auch: [http://www.theimagingsource.com/de_DE/support/documentation/icimagingcontrol-activex/PixelformatRGB8.htm] Quelle sagt, es ist ein 8-Bit-Monochrom-Format. – TaW
Ein anderes Zitat aus [dieser Quelle] (http://www.theimagingsource.com/en_US/support/documentation/icimagingcontrol-activex/PixelformatRGB8.htm): _RGB ist von unten nach oben, die erste Zeile hat Index (Zeilen-1_ – TaW