void SwapBufferFromBgraToRgba(void* _dest, const void* _src, int width, \
int height) {
int32_t* dest = (int32_t*)_dest;
int32_t* src = (int32_t*)_src;
int32_t rgba;
int32_t bgra;
int length = width*height;
for (int i = 0; i < length; i++) {
bgra = src[i];
// BGRA in hex = 0xAARRGGBB.
rgba = (bgra & 0x00ff0000) >> 16 // Red >> Blue.
| (bgra & 0xff00ff00) // Green Alpha.
| (bgra & 0x000000ff) << 16; // Blue >> Red.
dest[i] = rgba;
}
}
Czarek wrote:Why is it a huge impact to convert from bgra to rgba? Did you make any performance tests?
In CEF Python I wrote this function to swap the channels, you might find it useful:
BenjiSBRK wrote:Ok. Another question : the buffer passed to OnPaint is in BGRA, and I need it in RGBA. Making the conversion each frame has a huge impact on performance. Is there a way to get the buffer in RGBA ?
magreenblatt wrote:BenjiSBRK wrote:Ok. Another question : the buffer passed to OnPaint is in BGRA, and I need it in RGBA. Making the conversion each frame has a huge impact on performance. Is there a way to get the buffer in RGBA ?
How are you rendering the buffer? Both OpenGL and Direct3D support BGRA.
Users browsing this forum: No registered users and 222 guests