[q-lang-cvs] q/modules/ggi ggi.c,1.6,1.7
Brought to you by:
agraef
From: <ag...@us...> - 2003-12-20 17:25:48
|
Update of /cvsroot/q-lang/q/modules/ggi In directory sc8-pr-cvs1:/tmp/cvs-serv21472 Modified Files: ggi.c Log Message: fixed rendering of mono text, optimizations Index: ggi.c =================================================================== RCS file: /cvsroot/q-lang/q/modules/ggi/ggi.c,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** ggi.c 20 Dec 2003 11:51:56 -0000 1.6 --- ggi.c 20 Dec 2003 17:25:45 -0000 1.7 *************** *** 1409,1439 **** FT_BitmapGlyph bit = (FT_BitmapGlyph)image; FT_Bitmap *bitmap = &bit->bitmap; ! unsigned char *buf = bitmap->buffer; ! int p, q, w = bitmap->width, h = bitmap->rows, ! startx = bit->left - bbox.xMin, starty = bbox.yMax - bit->top, ! actx, acty; ! for (actx = startx, p = 0; p < w; actx++, p++) ! for (acty = starty, q = 0; q < h; acty++, q++) { ! int i = acty*wd+actx; ! int j = q*w+p; ! if (buf[j]) { #if 1 ! /* shades of fg color -- I hope that's the right way to do ! it? */ ! col[i].r = ((long)fgcol.r)*buf[j]/0xff; ! col[i].g = ((long)fgcol.g)*buf[j]/0xff; ! col[i].b = ((long)fgcol.b)*buf[j]/0xff; ! col[i].a = ((long)fgcol.a)*buf[j]/0xff; #else ! /* blend fg with bg color -- this looks odd with some fg/bg ! combinations */ ! col[i].r = (((long)fgcol.r)*buf[j]+ ! ((long)bgcol.r)*(0xff-buf[j]))/0xff; ! col[i].g = (((long)fgcol.g)*buf[j]+ ! ((long)bgcol.g)*(0xff-buf[j]))/0xff; ! col[i].b = (((long)fgcol.b)*buf[j]+ ! ((long)bgcol.b)*(0xff-buf[j]))/0xff; ! col[i].a = (((long)fgcol.a)*buf[j]+ ! ((long)bgcol.a)*(0xff-buf[j]))/0xff; #endif } --- 1409,1439 ---- FT_BitmapGlyph bit = (FT_BitmapGlyph)image; FT_Bitmap *bitmap = &bit->bitmap; ! unsigned char *buf = bitmap->buffer, *bufp; ! int p, q, r, w = bitmap->width, h = bitmap->rows, ! pitch = bitmap->pitch, ! startx = bit->left - bbox.xMin, starty = bbox.yMax - bit->top; ! for (bufp = buf, r = starty*wd+startx, q = 0; q < h; ! bufp += pitch, r += wd, q++) ! for (p = 0; p < w; p++) { ! int i = r+p; ! if (bufp[p]) { #if 1 ! /* for now we just do shades of the foreground color -- is this ! the right way to do it? */ ! col[i].r = ((long)fgcol.r)*bufp[p]/0xff; ! col[i].g = ((long)fgcol.g)*bufp[p]/0xff; ! col[i].b = ((long)fgcol.b)*bufp[p]/0xff; ! col[i].a = ((long)fgcol.a)*bufp[p]/0xff; #else ! /* here's an alternative implementation: blend fg with bg color ! -- but this looks odd with some fg/bg combinations */ ! col[i].r = (((long)fgcol.r)*bufp[p]+ ! ((long)bgcol.r)*(0xff-bufp[p]))/0xff; ! col[i].g = (((long)fgcol.g)*bufp[p]+ ! ((long)bgcol.g)*(0xff-bufp[p]))/0xff; ! col[i].b = (((long)fgcol.b)*bufp[p]+ ! ((long)bgcol.b)*(0xff-bufp[p]))/0xff; ! col[i].a = (((long)fgcol.a)*bufp[p]+ ! ((long)bgcol.a)*(0xff-bufp[p]))/0xff; #endif } *************** *** 1443,1459 **** } } else { ! error = FT_Glyph_To_Bitmap(&image, FT_RENDER_MODE_NORMAL, &pen, 1); if (!error) { FT_BitmapGlyph bit = (FT_BitmapGlyph)image; FT_Bitmap *bitmap = &bit->bitmap; ! unsigned char *buf = bitmap->buffer; ! int p, q, w = bitmap->width, h = bitmap->rows, ! startx = bit->left - bbox.xMin, starty = bbox.yMax - bit->top, ! actx, acty; ! for (actx = startx, p = 0; p < w; actx++, p++) ! for (acty = starty, q = 0; q < h; acty++, q++) { ! int i = acty*wd+actx; ! int j = q*w+p; ! if (buf[j]) col[i] = fgcol; } --- 1443,1460 ---- } } else { ! error = FT_Glyph_To_Bitmap(&image, FT_RENDER_MODE_MONO, &pen, 1); if (!error) { FT_BitmapGlyph bit = (FT_BitmapGlyph)image; FT_Bitmap *bitmap = &bit->bitmap; ! unsigned char *buf = bitmap->buffer, *bufp; ! int p, q, r, w = bitmap->width, h = bitmap->rows, ! pitch = bitmap->pitch, ! startx = bit->left - bbox.xMin, starty = bbox.yMax - bit->top; ! for (bufp = buf, r = starty*wd+startx, q = 0; q < h; ! bufp += pitch, r += wd, q++) ! for (p = 0; p < w; p++) { ! int i = r+p; ! int j = p>>3, k = 7-(p&7); ! if (bufp[j] & (1<<k)) col[i] = fgcol; } |