Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2010-03-21 02:31:48 +0300
committerCampbell Barton <ideasman42@gmail.com>2010-03-21 02:31:48 +0300
commitba2cfeefd0a6feb1b0a7a7eb2a00f5c265fd180f (patch)
treeb7494293f788b71353514ad8155a85d9f80db0dd /source/blender/blenfont
parentd904da1d03f2312944dc1b66215326aeefc0ec55 (diff)
drawing text in a byte buffer wasnt working (probably never tested since float buffer is used for rendering)
Diffstat (limited to 'source/blender/blenfont')
-rw-r--r--source/blender/blenfont/intern/blf_font.c60
1 files changed, 34 insertions, 26 deletions
diff --git a/source/blender/blenfont/intern/blf_font.c b/source/blender/blenfont/intern/blf_font.c
index 98044b965e1..35d7b6af19c 100644
--- a/source/blender/blenfont/intern/blf_font.c
+++ b/source/blender/blenfont/intern/blf_font.c
@@ -226,19 +226,21 @@ void blf_font_buffer(FontBLF *font, char *str)
for (y= 0; y < g->height; y++) {
for (x= 0; x < g->width; x++) {
- fbuf= font->b_fbuf + font->bch * ((chx + x) + ((pen_y + y)*font->bw));
- data= g->bitmap + x + (yb * g->pitch);
- a= data[0]/255.0f;
-
- if (a == 1.0) {
- fbuf[0]= font->b_col[0];
- fbuf[1]= font->b_col[1];
- fbuf[2]= font->b_col[2];
- }
- 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));
+
+ a= *(g->bitmap + x + (yb * g->pitch)) / 255.0f;
+
+ if(a > 0.0f) {
+ 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];
+ }
+ 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));
+ }
}
}
@@ -252,6 +254,11 @@ void blf_font_buffer(FontBLF *font, char *str)
if (font->b_cbuf) {
if (chx >= 0 && chx < font->bw && pen_y >= 0 && pen_y < font->bh) {
+ char b_col_char[3];
+ 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;
+
if (g->pitch < 0)
yb= 0;
else
@@ -259,19 +266,20 @@ void blf_font_buffer(FontBLF *font, char *str)
for (y= 0; y < g->height; y++) {
for (x= 0; x < g->width; x++) {
- cbuf= font->b_cbuf + font->bch * ((chx + x) + ((pen_y + y)*font->bw));
- data= g->bitmap + x + (yb * g->pitch);
- a= data[0];
-
- if (a == 256) {
- cbuf[0]= font->b_col[0];
- cbuf[1]= font->b_col[1];
- cbuf[2]= font->b_col[2];
- }
- else {
- cbuf[0]= (font->b_col[0]*a) + (cbuf[0] * (256-a));
- cbuf[1]= (font->b_col[1]*a) + (cbuf[1] * (256-a));
- cbuf[2]= (font->b_col[2]*a) + (cbuf[2] * (256-a));
+ a= *(g->bitmap + x + (yb * g->pitch)) / 255.0f;
+
+ if(a > 0.0f) {
+ 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];
+ }
+ 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));
+ }
}
}