freetype-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

RE: [Devel] bitmap rendering


From: Achim Hasenmueller
Subject: RE: [Devel] bitmap rendering
Date: Tue, 20 Feb 2001 10:59:36 +0100

Graham,

thanks for your help. I was not aware of the pitch value. However, I still
don't understand why it fails.

I am trying to paint an "a" and the FT_Load_Char gives me the following
information:

bitmap.rows == 59
bitmap.width == 51
bitmap.pitch == 51
bitmap_left == 4
bitmap_top == 58

A letter "b" that looks perfect gives me:

bitmap.rows == 89
bitmap.width == 60
bitmap.pitch == 60
bitmap_left == 0
bitmap_top == 87

So pitch is always the width here. Still the a fails and b works. The problem
can only be that the buffer does not match the width I pass to my blitting
routine (bitmap.width). What am I doing wrong here?

Thanks!

Kind regards / mit freundlichen Gruessen,
    Achim Hasenmueller

InnoTek Systemberatung GmbH
phon: +49 7151 9965-30
address@hidden
http://www.innotek.de
Germany






Graham Asher <address@hidden> on 19.02.2001 21.16.23

Please respond to "address@hidden" <address@hidden>

To:   "'Achim Hasenmueller'" <address@hidden>
cc:   "'address@hidden'" <address@hidden>

Subject:  RE: [Devel] bitmap rendering


Achim,

You need to tell your blitting routine the width of the bitmap in bytes, as
well as in pixels, so it knows how many bytes to skip when going from one
from to the next. This is called the 'stride' or 'pitch' and is given by
'pitch' in the FT_Bitmap structure.

The pitch is not necessarily the minimum number of bytes that would hold
the pixels in a row. Sometimes rows are padded to be an exact multiple of 2
or 4 bytes.

This would explain the distortion of some characters and not others; where
your blitting routine's idea of the pitch happens to be right, there is no
distortion.

Also, the following code is wrong - but I guess you know that, because it
will not even compile:

<<<<<<
char szString[20];
strcpy(szString, "a");
error = FT_Load_Char(face, szString, FT_LOAD_RENDER);
>>>>>>

FT_Load_Char takes not a char* but an integer character code as its second
argument, so this is better:

error = FT_Load_Char(face, 'a', FT_LOAD_RENDER);

And don't get me started about Hungarian notation ;-) (yeah, I know, it's a
matter of taste).

Best regards

Graham Asher










reply via email to

[Prev in Thread] Current Thread [Next in Thread]