[ Thread Index |
Date Index
| More lists.liballeg.org/allegro-developers Archives
]
Maybe the attached patch is interesting, it allows to do something like
in this screenshot:
http://allefant.sourceforge.net/allegro/translucent.png
--
Elias Pschernig
Index: include/allegro/font.h
===================================================================
--- include/allegro/font.h (revision 5626)
+++ include/allegro/font.h (working copy)
@@ -41,6 +41,8 @@
struct FONT_VTABLE *vtable;
} FONT;
+AL_FUNC(int, set_font_translucency, (int t));
+
AL_FUNC(int, is_color_font, (FONT *f));
AL_FUNC(int, is_mono_font, (FONT *f));
AL_FUNC(int, is_compatible_font, (FONT *f1, FONT *f2));
Index: src/font.c
===================================================================
--- src/font.c (revision 5626)
+++ src/font.c (working copy)
@@ -438,8 +438,23 @@
*/
int allegro_404_char = '^';
+/* Translucent font rendering state. */
+static int _font_translucent = FALSE;
+
+/* set_font_translucency
+ * Set translucent font rendering state.
+ */
+int set_font_translucency(int t)
+{
+ int prev = _font_translucent;
+ _font_translucent = t;
+ return prev;
+}
+
+
+
/* font_height:
* (mono and color vtable entry)
* Returns the height, in pixels of the font.
@@ -920,9 +935,12 @@
}
}
else {
- if (bitmap_color_depth(g) == bitmap_color_depth(bmp)) {
- masked_blit(g, bmp, 0, 0, x, y + (h-g->h)/2, g->w, g->h);
+ if (_font_translucent) {
+ draw_trans_sprite(bmp, g, x, y + (h-g->h)/2);
}
+ else if (bitmap_color_depth(g) == bitmap_color_depth(bmp)) {
+ masked_blit(g, bmp, 0, 0, x, y + (h-g->h)/2, g->w, g->h);
+ }
else {
int color_conv_mode;
BITMAP *tbmp;
Index: src/fontbmp.c
===================================================================
--- src/fontbmp.c (revision 5626)
+++ src/fontbmp.c (working copy)
@@ -32,12 +32,7 @@
{
int c;
- if (bitmap_color_depth(bmp) == 8) {
- c = 255;
- }
- else {
- c = makecol_depth(bitmap_color_depth(bmp), 255, 255, 0);
- }
+ c = getpixel(bmp, 0, 0);
/* look for top left corner of character */
while ((getpixel(bmp, *x, *y) != c) ||