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.

DS development > Beginner Greyscale Palettes Question

#101441 - Moeity - Tue Sep 05, 2006 3:55 pm

I'm coding up a little ebook reader software for the DS. I've got Freetype compiled, and can load a TrueType font and print basic glyph outlines to the screen. However, I can't get the colours right.

This is my first console system devel, and I'm not sure how these palettes work. Freetype is giving me back a 256 greyscale bitmap byte array. How can I tell the DS to render my byte buffer is in greyscale? As near as I can tell, I have to set the layer palette to greyscale, but I don't understand how to do this.

Any tips, or pointers to relevant documentation would be wonderful.

Thanks,
Moeity

#101445 - Lick - Tue Sep 05, 2006 5:02 pm

According to thise website: http://www.dfanning.com/ip_tips/color2gray.html, there is a standard ratio between the R, G, B values when converting to grayscale. However, if I see it right, there is too little information in the grayscale value to convert it back to the original RGB value. So in your case, I'd just set the R G B values (all three of them) to the grayscale value.

There is no way to set a layer/background to grayscale mode. They're always 24-bit (RGB or BGR). It gets even harder when you account for the fact that the the topscreen of a Phat is RGB, while all other screens (including the topscreen of Lite) are BGR.

But if you combine these 2 problems, they solve eachother out. Since the R G B values are all equal, that means RGB == BGR.

So yeah, just set the same greyscale value for the R, G, B channels.
_________________
http://licklick.wordpress.com