I just cannot wrap my head around this.... I need to convert some image in MFDB structure into 24bit RGB image. The MFDB will be in VDI standard format.

My guess is I need to pick each corresponding bit in each plane and turn it into the index of colour look up table (CLUT), then figure our what that colour is and turn that into 24bits RBG data. This should be for each pixel.

I cannot figure out a code to do this. I am not good using C bit-wise ops. Does anyone know of code fragment to do this?Any docs ?

Sorry I don't have time to test this quickly cobbled piece of code - so a big caution - but you probably want something like the code below. Assuming you want to convert a 4-plane VDI image with an arbitrary plane format, stored in Motorola/BigEndian order.

If the planes are stored separately, 'planestride' should be 1. If they are stored interleaved as they are on an ST screen, 'planestride' should be 4.

If it's being used on an Intel/ARM/LittleEndian host, then the plane words *might* be byte-swapped. In which case you'll need to un-swap them as they are fetched (This will be easy to spot because the output image will be correct but in fractured columns of 8 pixels).

If the image appears correct, but colours are wrong, the planes might be back-to-front. Just reverse the order.

The C fragment below just produces the 8-bit indexed colourmap from raw plane data. And no - it's not the fastest way to do it. But the idea should be clear. You'll need to convert to RGB by looking up each palette entry with each index. That's easy enough, but detail depends on how the palette is formatted so I didn't bother...