freetype
[Top][All Lists]
Advanced

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

Re: [ft] Determining pixel dimensions for bitmap


From: Werner LEMBERG
Subject: Re: [ft] Determining pixel dimensions for bitmap
Date: Wed, 29 Oct 2014 08:25:55 +0100 (CET)

> when using FT_Outline_Get_BBox() to get the dimensions of the
> outline, the values are all in the 26.6 fixed point format. How do I
> determine the optimal pixel size for a bitmap to pass to
> FT_Outline_Get_Bitmap() so that the outline fits *exactly* into the
> bitmap dimensions?
>
> The obvious approach would be something like this:
>
> width = bbox.xMax - bbox.xMin;
> height = bbox.yMax - bbox.yMin;
>
> pixelwidth = width >> 6;
> pixelheight = height >> 6;
>
> if((width & 0x3f) > 31) pixelwidth++;
> if((height & 0x3f) > 31) pixelheight++;
>
> This will add another pixel in case the fractional part of the 26.6
> fixed point value is >= 0.5. But I'm not sure if this is the right
> approach....

Yes, this looks good.

> is there maybe an "official" way of determining the pixel allocation
> size for the bitmap passed to FT_Outline_Get_Bitmap() in order to
> get an *exact* fit?

No.


    Werner



reply via email to

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