Should we support 16-24 bit color modes?

BlitzMax Forums/BlitzMax Beginners Area/Should we support 16-24 bit color modes?

MGE(Posted 2008) [#1]
I cranked up one of my old pcs, and it only supports 16-24 bit modes. Think it's worth supporting these modes?


GfK(Posted 2008) [#2]
Well, yes, since 32-bit is really 24-bit + alpha.

Wouldn't bother with 16-bit personally, as everything looks crap in it.


MGE(Posted 2008) [#3]
Do we have to do anything special via our code to support 24bit mode or is it biz as usual? Thanks..


GfK(Posted 2008) [#4]
Dunno - can't remember the last time I saw any hardware that claimed to support 24-bit colour.

I'd probably make a gradient-filled square and write a little app to draw it in 16 and 32 bit color, and see what happens. You should notice a 'banding' effect in 16 bit which goes away in 32 bit.


Azathoth(Posted 2008) [#5]
How is alpha done in 24-bit then?


Grey Alien(Posted 2008) [#6]
yeah good question Azathoth. If no alpha it would look BAD, but I've got a feeling I asked something like this before and it was fine.


ImaginaryHuman(Posted 2008) [#7]
Don't worry, the alpha channel in the *display* has absolutely nothing to do with drawing alpha-blended objects. Your objects have an alpha channel of their own - the `source alpha` and that is the only value that gets used to scale the contribution of the source pixels and the existing screen pixels. The screen's alpha channel doesn't even come into it. In fact Max2D doesn't even use the screen's alpha channel to do anything at all.

Opening a 24-bit screen therefore should work perfectly fine to do any alphablended drawing that you like, exactly the same as a 32-bit screen. The colors will be exactly the same.

16-bit and 15-bit and 256-color screens also have nothing to do with whether alphablending works or not, but the quality of the results will vary.

Note that a user's desktop defines the color depth of your display so if you're planning to open in Windowed mode it's going to adapt to whatever the user has set, be it 32-bit, 24-bit or 16-bit. OpenGL may even work on a 256-color desktop with dithering and a system palette.

One thing to keep in mind, I found, is you can request a 16-bit OpenGL display in windowed mode even if the desktop is in 32-bit - I can't remember how that's possible but oh well - and when you do that, GL may try to scale the colors or dither them. Oh... I think it was a 16-bit screen where you try to use 32-bit textures. I just remember it would slow down because it wasn't a natively supported combination in hardware.

You can use the screen's alpha channel for stuff, it's just that people hardly ever use it. I use it to do a faster blobby-object thing where I draw only to the screen's alpha channel using a blend mode that copies the alpha values to the RGB components. But Max2D isn't using it at all.


Grey Alien(Posted 2008) [#8]
haha, in fact it was ImaginaryHuman who cleared this up for me last time.


Azathoth(Posted 2008) [#9]
So 32-bit pictures can still be drawn on a 24-bit display?


ImaginaryHuman(Posted 2008) [#10]
Of course. The color of the pixel is stored in 24 bits, 8-bit red, 8-bit green and 8-bit blue. The screen doesn't need any further bits at all. A 32-bit display is really just a 24-bit color display with extra room in the screen to store alpha values *if* you wanted to use them for something, but like I said hardly any one uses them for anything and it's not a part of alphablending the graphics that you draw. Your sprite has its own alpha channel which is used for scaling the color contributions.


MGE(Posted 2008) [#11]
hmm... so it appears 24 bit support is a 100% yes. Thanks IH.


ImaginaryHuman(Posted 2008) [#12]
Sure. I don't see why not. So long as you have a GL or DX driver which supports the blend modes that Max2D uses, it should work. Max2D isn't exactly doing anything advanced, just throwing some quads on the screen, setting colors and doing a bit of blending. It should work fine in 16-bit too.