From 8d1b10574ec9fbabaa49a6caecc8e85e348fbbb9 Mon Sep 17 00:00:00 2001 From: Crayon2000 Date: Fri, 15 Jan 2010 06:55:22 +0000 Subject: [PATCH] [CHG] TTF functions are now using RGBA color instead of RGB --- GRRLIB/GRRLIB/GRRLIB_ttf.c | 20 +++++++++++--------- examples/ttf/source/main.c | 6 +++--- 2 files changed, 14 insertions(+), 12 deletions(-) diff --git a/GRRLIB/GRRLIB/GRRLIB_ttf.c b/GRRLIB/GRRLIB/GRRLIB_ttf.c index 25317c0..f09ef00 100644 --- a/GRRLIB/GRRLIB/GRRLIB_ttf.c +++ b/GRRLIB/GRRLIB/GRRLIB_ttf.c @@ -72,9 +72,11 @@ GRRLIB_ttfFont* GRRLIB_LoadTTF (const u8* file_base, s32 file_size) { * @param myFont A TTF. */ void GRRLIB_FreeTTF (GRRLIB_ttfFont *myFont) { - FT_Done_Face(myFont->face); - free(myFont); - myFont = NULL; + if(myFont) { + FT_Done_Face(myFont->face); + free(myFont); + myFont = NULL; + } } /** @@ -84,7 +86,7 @@ void GRRLIB_FreeTTF (GRRLIB_ttfFont *myFont) { * @param myFont A TTF. * @param string Text to draw. * @param fontSize Size of the font. - * @param color Text color in RGB format. + * @param color Text color in RGBA format. */ void GRRLIB_PrintfTTF(int x, int y, GRRLIB_ttfFont *myFont, const char *string, unsigned int fontSize, const u32 color) { if(myFont == NULL || string == NULL) @@ -110,7 +112,7 @@ void GRRLIB_PrintfTTF(int x, int y, GRRLIB_ttfFont *myFont, const char *string, * @param myFont A TTF. * @param utf32 Text to draw. * @param fontSize Size of the font. - * @param color Text color in RGB format. + * @param color Text color in RGBA format. */ void GRRLIB_PrintfTTFW(int x, int y, GRRLIB_ttfFont *myFont, const wchar_t *utf32, unsigned int fontSize, const u32 color) { if(myFont == NULL || utf32 == NULL) @@ -159,7 +161,7 @@ void GRRLIB_PrintfTTFW(int x, int y, GRRLIB_ttfFont *myFont, const wchar_t *utf3 * @param bitmap Bitmap to draw. * @param offset x-coordinate offset. * @param top y-coordinate. - * @param color character color in RGB format. + * @param color character color in RGBA format. */ static void DrawBitmap(FT_Bitmap *bitmap, int offset, int top, const u32 color) { FT_Int i, j, p, q; @@ -169,9 +171,9 @@ static void DrawBitmap(FT_Bitmap *bitmap, int offset, int top, const u32 color) for ( i = offset, p = 0; i < x_max; i++, p++ ) { for ( j = top, q = 0; j < y_max; j++, q++ ) { GRRLIB_Plot( i, j, - RGBA((color >> 16) & 0xFF, - (color >> 8) & 0xFF, - color & 0xFF, + RGBA(R(color), + G(color), + B(color), bitmap->buffer[ q * bitmap->width + p ]) ); } } diff --git a/examples/ttf/source/main.c b/examples/ttf/source/main.c index 1b85471..6c3f248 100644 --- a/examples/ttf/source/main.c +++ b/examples/ttf/source/main.c @@ -59,13 +59,13 @@ int main(int argc, char **argv) { myFont, Letter, rand() % 180 + 20, - rand() % 0xFFFFFF); + ((rand() % 0xFFFFFF) << 8) | 0xFF); GRRLIB_Screen2Texture(0, 0, CopiedImg, false); if(ShowFPS) { sprintf(FPS, "Current FPS: %d", CalculateFrameRate()); - GRRLIB_PrintfTTF(500+1, 25+1, myFont, FPS, 12, 0x000000); - GRRLIB_PrintfTTF(500, 25, myFont, FPS, 12, 0xFFFFFF); + GRRLIB_PrintfTTF(500+1, 25+1, myFont, FPS, 12, 0x000000FF); + GRRLIB_PrintfTTF(500, 25, myFont, FPS, 12, 0xFFFFFFFF); } GRRLIB_Render(); // Render the frame buffer to the TV