I'm trying to create a bitmap from separate Red, Green, and blue arrays so I can use this bitmap later to create a frame for an avi file (SharpAVI). I've tried the following code which works:
Bitmap Bmp = new Bitmap(Width, Height);
for (int ii = 0; ii < (Width*Height); ii++)
{
ypos = ii / Width;
xpos = ii % Width;
Bmp.SetPixel(xpos, ypos, Color.FromArgb(dataR[ii], dataG[ii], dataB[ii]));
}
the arrays dataR, dataG, and dataB contain the values (0 to 255) of the colors starting from 0,0 and ending on width,height. However, this code is rather slow. I would prefer to directly produce the bitmap from the data, but I'm not sure how. I've seached around and found something in the direction of:
Bitmap bm_Image = new Bitmap(Width, Height, Stride, PixelFormat.Format24bppRgb, ipPtrRGB);
but I don't fully understand how this works. I've read something about padding the data etc. Does anybody know a method to do this fast?