[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
RE: [ft] reading glyph bitmap
From: |
Minhaj Ahmed |
Subject: |
RE: [ft] reading glyph bitmap |
Date: |
Thu, 2 Sep 2010 14:51:43 +0000 |
Corrected and functional code attached...I guess I was distracted by other
problems in the code too much
/////////////////////////////////////////////////////////
//
void PrintLetter(unsigned char *my_buf, FT_Bitmap *bmp)
{
FT_Int i, j, p, q;
FT_Int x_max = bmp->pitch;
FT_Int y_max = bmp->rows;
printf("In %s\n", __FUNCTION__);
for (i = 0, p = 0; p < y_max ; i+=x_max, p++ )
{
for ( j = i, q=0; q < x_max; q++, j++)
{
putchar(my_buf[j] == 0 ? ' ' : my_buf[j] < 128 ? '-' :
'.');
}
putchar('\n');
}
}
________________________________________
From: Minhaj Ahmed
Sent: Wednesday, September 01, 2010 12:12 PM
To: address@hidden
Cc: Werner LEMBERG
Subject: RE: [ft] reading glyph bitmap
Here is the sample code which fails to retrieve the bitmap glyph properly, I
see all white space with a
...................
at the end for number 3 for example..yet example1.c here
http://freetype.freedesktop.org/freetype2/docs/tutorial/
works well with letters/numbers oriented as provided in the original email
below...
/////////////////////////////////////////////////////////
//
void PrintLetter(
unsigned char *my_buf, //this buffer is
face->glyph->bitmap->buffer
FT_Bitmap *bmp //same bitmap struct to which the buffer above
belongs
)
{
FT_Int i, j, p;
FT_Int x_max = bmp->pitch;
FT_Int y_max = bmp->rows;
//
// i each time should equal the first pixel in each row and
// should move upward every iteration
// j would print one by one each byte in a given row
//
for (i = (y_max-1)*x_max, p = 0; p < y_max ; i-=x_max, p++ )
{
for ( j = i; j < x_max; j++)
{
putchar(my_buf[j] == 0 ? ' ' : my_buf[j] < 128 ? '-' :
'.');
}
putchar('\n');
}
}
________________________________________
From: Werner LEMBERG address@hidden
Sent: Wednesday, September 01, 2010 10:39 AM
To: Minhaj Ahmed
Subject: Re: [ft] reading glyph bitmap
> Thanx for the reply, I am using exactly the same method & it works
> but orients the glyph horizontally, was wondering why I am unable to
> read it row by row instead?
Without a (working) code snippet, I can't help. And please don't
write to me privately but to the freetype list.
Werner
From: Minhaj Ahmed
Sent: Tuesday, August 31, 2010 4:30 PM
To: address@hidden
Subject: reading glyph bitmap
Hope I am sending this on the right email list. I am new to fonts in general
and am trying to render the bitmap of various glyphs on to a label. I can only
read the bitmap using the index
y_offset * width_of_bmp + x_offset . Starting for x and y offsets of 0 this as
expected reads in the first vertical line in the bitmap into the first scanline
and orients the glyph horizontally. Every time I’ve tried to scan the bitmap
from top left down or from bottom left up I’ve failed. Can anybody explain
why? Also how do you flip the glyph, I ask because rotation is not enough to
fix the glyph read in the way I’ve been able to so far. Thanx in advance!
... -..- ......
... -...- ......-
... -....- .......-
... ......- ........
... -......- ........
... -.......- ........
... -........- ........
... -.........- ...
... -..........- ...
... -...........- ...
... -............- ...
...--......--.....- ...
..........- -.......................
.........- -......................
........- -....................-
.......- ..................-
......- -...............-
.....- -..............
....- -............-