Je sais comment convertir un tableau d'octets en image. Voici mon code:comment convertir un tableau d'octets BGR en image
//Here create the Bitmap to the know height, width and format
Bitmap bmp = new Bitmap(width, height, System.Drawing.Imaging.PixelFormat.Format32bppArgb);
//Bitmap bmp = new Bitmap(width, height);
//Create a BitmapData and Lock all pixels to be written
System.Drawing.Imaging.BitmapData bmpData = bmp.LockBits(
new Rectangle(0, 0, bmp.Width, bmp.Height),
ImageLockMode.WriteOnly, bmp.PixelFormat);
//Copy the data from the byte array into BitmapData.Scan0
Marshal.Copy(imgDataArray, 0, bmpData.Scan0, imgDataArray.Length);
//Unlock the pixels
bmp.UnlockBits(bmpData);
bmp.Save("output1.png", System.Drawing.Imaging.ImageFormat.Png);
Mais quand tableau d'octets est le format BGR, la couleur d'image est fausse (rouge est bleu, le bleu est rouge). Tout le monde peut m'aider à comprendre cela? Merci.
Oui, cela fonctionne. Mais cela prend trop de temps à traiter. –
Eh bien, toute exigence de vitesse n'était pas spécifiée. Il devrait être possible de faire une telle conversion très rapidement. Vous devez écrire votre propre fonction de conversion d'image optimisée, ou évaluer les bibliothèques de traitement d'image tierces jusqu'à ce que vous en trouviez une qui fonctionne assez rapidement pour vos besoins. Peut-être pourriez-vous également obtenir vos données sources dans un autre format. – djdanlib