Re: [AD] Component ordering and mixing color depths

[ Thread Index | Date Index | More lists.liballeg.org/allegro-developers Archives ]


Eric Botcazou wrote:
If you are using a 32-bpp overlay, then bmp_color_depth(screen) == 32, no?


No, I can use 32-bpp overlays with bmp_color_depth(screen) == 15 on my ATI card.

If you're not using the overlay as the screen bitmap, then what for?



I thought you were pushing for an arbitrarily fixed RGBA layout... it's not the case, is it ?

No! I was asking if we should do something like:

int set_gfx_mode() {
        call_driver_specific_code();

	if (depth == 16) {
		_r_shift_16 = /* whatever the driver gives us */
                _r_shift_32 = scale16_to_32[r_shift_16];
                /* repeat for all components */
         }
}

This way, the RGBA component ordering is the same in between 16 and 32-bpp bitmaps, but the ordering itself (RGB vs BGR) can vary depending on the driver/platform/hardare.

Code is so much less ambiguous ^_^

In the end, I realized that users may have set a 32-bpp mode, loaded some bitmaps, then switched to a 16-bpp mode which may have a different component ordering from the 32-bpp mode. If set_gfx_mode would reset the 32-bpp component shift values, then both color conversion and blending would come out wrong.

So I coded up two functions, one for blending RGB over RGB (or BGR over BGR - it's the same code), and one for RGB over BGR (or BGR over RGB).


--
- Robert Jr Ohannessian
http://bob.allegronetwork.com/
The peer will come and reset your connection. RUN WHILE YOU STILL CAN!





Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/