Efficient way of converting an 8bit array of grayscale pixel data into 24bpp bitmap for GDI+?
-
Hello, I have access to array of pixel data (size:512x512x8bpp) from a framegrabber which I currently assign to a 8bpp bitmap which is assigned to a GDI+ graphics object later on. Now, I would like to convert my array of 8bpp pixel data into 24bpp (BGRA, but I have no use for Alpha channel) and assign it to my bitmap and then modify individual pixel data to different colors depending on other conditions. When I say efficient, I want it to be done in real-time without much delay. Any suggestions? thanks
PKNT
-
Hello, I have access to array of pixel data (size:512x512x8bpp) from a framegrabber which I currently assign to a 8bpp bitmap which is assigned to a GDI+ graphics object later on. Now, I would like to convert my array of 8bpp pixel data into 24bpp (BGRA, but I have no use for Alpha channel) and assign it to my bitmap and then modify individual pixel data to different colors depending on other conditions. When I say efficient, I want it to be done in real-time without much delay. Any suggestions? thanks
PKNT
-
Hello, I have access to array of pixel data (size:512x512x8bpp) from a framegrabber which I currently assign to a 8bpp bitmap which is assigned to a GDI+ graphics object later on. Now, I would like to convert my array of 8bpp pixel data into 24bpp (BGRA, but I have no use for Alpha channel) and assign it to my bitmap and then modify individual pixel data to different colors depending on other conditions. When I say efficient, I want it to be done in real-time without much delay. Any suggestions? thanks
PKNT
When the input data are 8 bit gray scale values just assign them to the R, G, and B values and set the aplha value to zero:
// Assuming RGBA is an uint32_t / DWORD type and
// *in an unsigned char / uint8_t pointer.
RGBA *out = new RGBA[512 * 512];
for (unsigned i = 0; i < 512 * 512; i++)
{
out[i] = (in[i] << 16) + (in[i] << 8) + in[i];
}