I'm new to converting image types. I would like to determine the color of each pixel on the screen. I can read the colors from the frame buffer, but they are all in RGB565. For tracking a certain color, I would like to convert the RGB565 to HSV so I can check the hue.
I've already tried converting it via an online converter from RGB565 to RGB888. For example the RGB565 '08F5' to RGB888 '081BAA'. And then from RGB888 to HSL '233 91% 35%'. However, I can't get this working with c code. The colors are in HEX format and stored per 2 in one register. I made a char array of four for each color.
int colorcodes = IORD_ALTERA_AVALON_PIO_DATA(0x08000000 + 123204);
char colorcodesInHex[9];
snprintf(colorcodesInHex, 9, "%08x\n", colorcodes);
char firstColor[4];
char secondColor[4];
for(int i = 0; i <= 7; i++)
{
if(i <= 3)
{
firstColor[i] = colorcodesInHex[i];
}
else if (i >= 4 && i <= 7)
{
secondColor[i - 4] = colorcodesInHex[i];
}
}
Does someone know how to convert the RGB565 to RGB888 and then to HSL in C?