I'm trying to extract some color codes from an image buffer. When I read out a memory adres from the buffer it returns an int value that contains the color codes of two pixels. My goal is to get each color code as an separate int value.
For example when I read out a memory adres from the image buffer it returns the decimal value: 142149753.
Because this decimal value it's 9 characters long I can't simply spit it into two int values. So I tried to convert the value to a hexadecimal with the printf function which gave me the value: 08790879.
Now I can see de two 16-bit color codes I need: 0879 and 0879.
int firstColorCode;
int secondColorCode;
int colorcodes = IORD_ALTERA_AVALON_PIO_DATA(0x08000000 + 123204);
printf("%08x\n", colorcodes);
How can I get the two color codes into the corresponding int variables in code?
Disclaimer: I'm new to C and it feels like I'm asking a stupid question :/