🎉 Celebrating 25 Years of GameDev.net! 🎉

Not many can claim 25 years on the Internet! Join us in celebrating this milestone. Learn more about our history, and thank you for being a part of our community!

Pixelformat conversions

Started by
0 comments, last by Cthulhu 24 years, 8 months ago
I'm currently making a graphics engine and I'd like to support various bit depths, but that makes things like alpha blending little difficult. I thought about doing everything in 32 bits per pixel and finally convert the picture before displaying it.

And it seems DirectDraw doesn't do conversions so I'll have to do it myself. Are there any good algorithms for converting 32 bit pixels to 24 and 16 bits (both 1555 and 565), splitting color values is very slow to do for 640x480=307200 pixels.

I'm using Visual c++ 6.0, assembly tips are also welcome.

------------------
"Tank, I need an exit. Fast!"

Advertisement
I think the best way to approach this would be to use function pointers.

Setup a system that swaps in the correct functions for the bitdepth you are working in so you don't have to have switch() statements in your code..

You'll want to change all your data from 32 bits to 24, 16 or 8 at load time. Doing it realtime will be too slow, and you'll be moving twice as much data as needed for 16 bit users.

32 to 24 is easy - just drop the least significant data by shifting. 32 to 16 is the same, but be sure you check which mode the card requires, 555 or 565 - shift appropriately. 8 bit will be a disaster, and if you really want to use it you'll either have to dither your images, or keep a seperate set of 8 bit bitmaps. Most people don't bother with 8 bit anymore. (except us slow pokes with P166's.)

This topic is closed to new replies.

Advertisement