Fast DX texture pixel color conversion?directx
Posted 15 November 2012 - 09:07 PM
I've tried to use D3DFMT_A8R8G8B8 directly, but in this case my color values are changed and my texture appears blue. If I use D3DFMT_A8B8G8R8 instead,
I get in trouble because the returned surface format is D3DFM_A8R8G8B8 instead of my requested format. So I've to iterate over each pixel and bring it to the
correct pixel format. But this is a huge bottleneck on large images and not usable.
How would you handle this missmatch? Is there a faster way to convert those pixel colors?
Posted 15 November 2012 - 10:43 PM
Posted 16 November 2012 - 01:00 AM
As reed said, just convert it over at load time. I have to do a similar thing by flipping textures in OpenGL since top is bottom and bottom is top (o¿O). It's pretty fast. 250MB worth of graphics and other stuff going on loads in just 6 seconds from a zip package. Most images are large, like upwards to 4096x4096, so you shouldn't have any performance problems. A quick way to convert your bitmap over would be to use bitshift operators. Typecast your 4byte RGBA pixels into an integer pointer and: (rgba >> 8) | (rgba << 24). You could optionally store your images in ARGB format and directly load them in like that.
Posted 16 November 2012 - 06:54 AM
Thanks for your hints!
1 user(s) are reading this topic
0 members, 1 guests, 0 anonymous users