Convert RGB32 image to ofPixels in Open Frameworks

89 Views Asked by At

I am trying to display a video from a video decoder library. The video is delivered as a byte array with RGB32 pixel format. Meaning every pixel is represented by 32 bits.

RRBBGGFF - 8bit R, 8bit G, 8bit B, 8bit 0xFF.

Similar to QT Qimage Format_RGB32.

I thnik I need to convert the pixel array to ofPixels, Then load the pixels to ofTexture. Then I can draw the texture.

I don't know how to convert/set the ofPixels from this pixel format.

Any tips/ideas are so so welcome.

Thanks!

1

There are 1 best solutions below

0
pierre tardif On

Try using a ofThreadChannel as described in this example in order to avoid writing and reading from your ofTexture / ofPixels.

Then you can load a uint8_t* by doing :

by using an ofTexture's method loadFromPixels() :

// assuming data is populating the externalBuffer
void* externalBuffer;
tex.loadFromPixels((uint8*)externalData, width, height, GL_RGBA);

Hope this helps,

Best,

P