0

I am working on a device that is using an image sensor and a USB microcontroller that will continuously stream frames from the sensor to be drawn on a GUI using C#.

My image sensor is outputing data in RGB565, and I am converting this array of bytes to an image using the following function:

public static Bitmap BytesToBmp(byte[] bmpBytes, int w, int h)
{
    Bitmap functionReturnValue = default(Bitmap);
    Bitmap bmp = new Bitmap(w, h ,System.Drawing.Imaging.PixelFormat.Format16bppRgb565);

    System.Drawing.Imaging.BitmapData bdata = bmp.LockBits(new Rectangle(new Point(), bmp.Size), System.Drawing.Imaging.ImageLockMode.WriteOnly, System.Drawing.Imaging.PixelFormat.Format16bppRgb565);
    Marshal.Copy(bmpBytes, 0, bdata.Scan0, bmpBytes.Length - 1);
    bmp.UnlockBits(bdata);
    functionReturnValue = bmp;

    return functionReturnValue;
}

Unfortantely I am getting a very pink image and wanted to try and fix this by converting the image from RBG565 to RGB888. Let me know if you have any suggestions.

ArchiFloyd
  • 1,274
  • 13
  • 20

0 Answers0