简体   繁体   English

在 Open Frameworks 中将 RGB32 图像转换为 ofPixels

[英]Convert RGB32 image to ofPixels in Open Frameworks

I am trying to display a video from a video decoder library.我正在尝试显示来自视频解码器库的视频。 The video is delivered as a byte array with RGB32 pixel format.视频以 RGB32 像素格式的字节数组形式提供。 Meaning every pixel is represented by 32 bits.这意味着每个像素都由 32 位表示。

RRBBGGFF - 8bit R, 8bit G, 8bit B, 8bit 0xFF. RRBBGGFF - 8 位 R、8 位 G、8 位 B、8 位 0xFF。

Similar to QT Qimage Format_RGB32.类似于 QT Qimage Format_RGB32。

I thnik I need to convert the pixel array to ofPixels, Then load the pixels to ofTexture.我想我需要将像素数组转换为 ofPixels,然后将像素加载到 ofTexture。 Then I can draw the texture.然后我可以绘制纹理。

I don't know how to convert/set the ofPixels from this pixel format.我不知道如何从这种像素格式转换/设置 ofPixels。

Any tips/ideas are so so welcome.任何提示/想法都非常受欢迎。

Thanks!谢谢!

Try using a ofThreadChannel as described in this example in order to avoid writing and reading from your ofTexture / ofPixels .尝试使用本例中描述的ofThreadChannel以避免从您的ofTexture / ofPixels写入和读取。

Then you can load a uint8_t* by doing:然后您可以通过执行以下操作加载uint8_t*

by using an ofTexture 's method loadFromPixels() :通过使用ofTexture的方法loadFromPixels()

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

Hope this helps,希望这可以帮助,

Best,最好,

P P

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM