gbadev.org forum archive

This is a read-only mirror of the content originally found on forum.gbadev.org (now offline), salvaged from Wayback machine copies. A new forum can be found here.

Graphics > Image Brightness!

#43296 - _Dan - Sat May 21, 2005 6:34 pm

Hello!

I've just started coding for my GBA and it's all very exciting but I have a problem.

I've wrote some code turn a bitmap into a .h file (as a C array), and it's working, however, when I use the images in my GBA program, some of the brighter areas of the graphics appear too bright...an example:

The original:
[Images not permitted - Click here to view it]
The GBA version:
[Images not permitted - Click here to view it]

The code I use to convert colours is:

unsigned short int colour = ((r>>3) | ((g>>3)<<5) | ((b>>3)<<10));

Where r,g,b are the colour componants from a 24 bitmap. And "colour" is the two byte GBA pixel.

Can anyone tell me why it's so bright?
(it's not because it's in an emulator or anything is it?)

I am using mode 3 which I think is correct:
Code:
    unsigned short *video = (unsigned short *)0x6000000;
    *(unsigned long *)0x4000000 = (0x3 | 0x400); // set video mode 3 (240x160 16-bit)


Any help appreciated!
Thanks.

#43297 - tepples - Sat May 21, 2005 6:39 pm

What types are the variables r, g, b? Remember that 'char' is signed by default on many platforms and unsigned on others; always use 'signed char' or 'unsigned char'.
_________________
-- Where is he?
-- Who?
-- You know, the human.
-- I think he moved to Tilwick.

#43298 - sajiimori - Sat May 21, 2005 6:45 pm

Looks fine to me. It might be the way you're reading the 8-bit color components from the image, so let's have a look at that.

#43299 - _Dan - Sat May 21, 2005 6:45 pm

Yes, that was it. It's working beautifully now, thanks very much :-)