Projectitis
Well-known member
Hi all,
A 24bit unsigned integer format question that is not audio related!
I'd like to use a 24bit pixel format to conserve space in teensy flash/PROGMEM: RGBA6666
This is similar to RGBA565 but an extra bit for R and B channels, plus 6 bits for alpha.
Internally I'll be storing this data as 16b RGB565 plus a separate 8b Alpha (I may end up changing the bits to RGBA5658 to suit).
The main thing I need to be able to do is step a packed const byte array for reading.
Once read, I don't mind storing the pixel data itself as either uint32_t or ( uint16t, uint8_t ).
Rather than use 32b per pixel in flash and 'waste' a byte, I'd really like to use packed data (3-byte words) and step them with a pointer. How can I do this most efficiently/quickly?
e.g. - something like:
Do I need to do something like this?
A 24bit unsigned integer format question that is not audio related!
I'd like to use a 24bit pixel format to conserve space in teensy flash/PROGMEM: RGBA6666
This is similar to RGBA565 but an extra bit for R and B channels, plus 6 bits for alpha.
Internally I'll be storing this data as 16b RGB565 plus a separate 8b Alpha (I may end up changing the bits to RGBA5658 to suit).
The main thing I need to be able to do is step a packed const byte array for reading.
Once read, I don't mind storing the pixel data itself as either uint32_t or ( uint16t, uint8_t ).
Rather than use 32b per pixel in flash and 'waste' a byte, I'd really like to use packed data (3-byte words) and step them with a pointer. How can I do this most efficiently/quickly?
e.g. - something like:
Code:
uint24_t *imageData = [pointer to image data in flash mem];
uint24_t pixel;
uint24_t *imageDataPtr = imageData;
while (some_exit_condition){
pixel = *imageDataPtr;
imageDataPtr++;
}
Do I need to do something like this?
Code:
uint8_t *imageData = [pointer to image data in flash mem];
uint16_t pixelRGB;
uint8_t pixelA;
uint8_t *imageDataRGBPtr = imageData;
uint8_t *imageDataAPtr = imageData + 2;
while (some_exit_condition){
pixelRGB= *(uint16_t*)imageDataRGBPtr;
pixelA = *imageDataAPtr;
imageDataRGBPtr+=3;
imageDataAPtr+=3;
}