From 79249f8aede5c5481c625335b5ef7bd9b4cf28cc Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Wed, 31 Aug 2011 01:05:40 +0000 Subject: fix [#28430] Image with Stampinfo does not get saved correctly with alpha --- source/blender/blenfont/intern/blf_font.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'source/blender/blenfont') diff --git a/source/blender/blenfont/intern/blf_font.c b/source/blender/blenfont/intern/blf_font.c index 708b3708ab7..fb6505fe935 100644 --- a/source/blender/blenfont/intern/blf_font.c +++ b/source/blender/blenfont/intern/blf_font.c @@ -213,7 +213,7 @@ void blf_font_buffer(FontBLF *font, const char *str) { unsigned char *cbuf; unsigned int c; - unsigned char b_col_char[3]; + unsigned char b_col_char[4]; GlyphBLF *g, *g_prev; FT_Vector delta; FT_UInt glyph_index; @@ -232,6 +232,7 @@ void blf_font_buffer(FontBLF *font, const char *str) b_col_char[0]= font->b_col[0] * 255; b_col_char[1]= font->b_col[1] * 255; b_col_char[2]= font->b_col[2] * 255; + b_col_char[3]= font->b_col[3] * 255; while (str[i]) { int pen_y; @@ -296,16 +297,19 @@ void blf_font_buffer(FontBLF *font, const char *str) a= *(g->bitmap + x + (yb * g->pitch)) / 255.0f; if(a > 0.0f) { + float alphatest; fbuf= font->b_fbuf + font->bch * ((chx + x) + ((pen_y + y)*font->bw)); if (a >= 1.0f) { fbuf[0]= font->b_col[0]; fbuf[1]= font->b_col[1]; fbuf[2]= font->b_col[2]; + fbuf[3]= (alphatest= (fbuf[3] + (font->b_col[3]))) < 1.0f ? alphatest : 1.0f; } else { fbuf[0]= (font->b_col[0]*a) + (fbuf[0] * (1-a)); fbuf[1]= (font->b_col[1]*a) + (fbuf[1] * (1-a)); fbuf[2]= (font->b_col[2]*a) + (fbuf[2] * (1-a)); + fbuf[3]= (alphatest= (fbuf[3] + (font->b_col[3]*a))) < 1.0f ? alphatest : 1.0f; } } } @@ -324,16 +328,19 @@ void blf_font_buffer(FontBLF *font, const char *str) a= *(g->bitmap + x + (yb * g->pitch)) / 255.0f; if(a > 0.0f) { + int alphatest; cbuf= font->b_cbuf + font->bch * ((chx + x) + ((pen_y + y)*font->bw)); if (a >= 1.0f) { cbuf[0]= b_col_char[0]; cbuf[1]= b_col_char[1]; cbuf[2]= b_col_char[2]; + cbuf[3]= (alphatest= ((int)cbuf[3] + (int)b_col_char[3])) < 255 ? alphatest : 255; } else { cbuf[0]= (b_col_char[0]*a) + (cbuf[0] * (1-a)); cbuf[1]= (b_col_char[1]*a) + (cbuf[1] * (1-a)); cbuf[2]= (b_col_char[2]*a) + (cbuf[2] * (1-a)); + cbuf[3]= (alphatest= ((int)cbuf[3] + (int)((font->b_col[3]*a)*255.0f))) < 255 ? alphatest : 255; } } } -- cgit v1.2.3