Mercurial > hg > dmlib
comparison dmtext_bm.c @ 100:f16d102dbbac
Add a function for setting bitmapped font palette.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Tue, 02 Oct 2012 20:33:01 +0300 |
parents | e1e308167991 |
children | 8bba97252d85 |
comparison
equal
deleted
inserted
replaced
99:7a59611f9d4f | 100:f16d102dbbac |
---|---|
104 font->glyphs[i] = NULL; | 104 font->glyphs[i] = NULL; |
105 } | 105 } |
106 } | 106 } |
107 | 107 |
108 dmFree(font); | 108 dmFree(font); |
109 return DMERR_OK; | |
110 } | |
111 | |
112 | |
113 /* Set the palette for each glyph. While the function allows you to | |
114 * specify 'start' and 'end' indices and palette array freely, you should | |
115 * typically use DMFONT_NPALETTE size palette starting at index 0. | |
116 */ | |
117 int dmSetBitmapFontPalette(DMBitmapFont *font, SDL_Color *pal, int start, int size) | |
118 { | |
119 int i; | |
120 | |
121 if (font == NULL) | |
122 return DMERR_NULLPTR; | |
123 | |
124 if (start < 0 || end < start) | |
125 return DMERR_INVALID_ARGS; | |
126 | |
127 for (i = 0; i < font->nglyphs; i++) | |
128 { | |
129 SDL_Surface *glyph = font->glyphs[i]; | |
130 if (glyph != NULL) | |
131 { | |
132 if (glyph->format->BitsPerPixel == 8) | |
133 SDL_SetColors(glyph, pal, start, end); | |
134 } | |
135 } | |
136 | |
109 return DMERR_OK; | 137 return DMERR_OK; |
110 } | 138 } |
111 | 139 |
112 | 140 |
113 int dmCreateBitmapFontFromImage(SDL_Surface *image, int width, int height, DMBitmapFont **pfont) | 141 int dmCreateBitmapFontFromImage(SDL_Surface *image, int width, int height, DMBitmapFont **pfont) |