[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [ft] Determining pixel dimensions for bitmap
From: |
Marco Wertz |
Subject: |
Re: [ft] Determining pixel dimensions for bitmap |
Date: |
Tue, 4 Nov 2014 23:17:45 +0100 |
> > The problem for me is that I'm not using the glyph API but the
> > FT_Stroker and FT_Outline APIs directly. Of course I can detect an
> > empty row or column on my own, but if I want to have a bitmap that
> > doesn't contain any empty rows or columns, I'm forced to copy the
> > pixels to another bitmap because the current APIs don't give me the
> > chance to allocate a bitmap of the *exact* dimensions before drawing
> > to it.
>
> Just to be sure: You have an outline, you apply FT_Stroker stuff, then
> you want to get the exact dimensions of the outline for a given
> resolution, right?
Actually, I first create an FT_Stroker, begin a subpath on it, add several
cubic splines using FT_Stroker_CubicTo(), close the subpath and then
export it into an FT_Outline using FT_Stroker_Export().
Now I want to be able to get the exact dimensions of the outline
in pixels.
>
> My guess is that `FT_Outline_Get_BBox' + rounding as described above
> should deliver exact results in almost all cases.
Unfortunately not. Taking Alexei's feedback into account, I'm
now calculating the pixel dimensions for the bitmap like this:
(xyMin is rounded down, xyMax is rounded up)
int xmin = bbox.xMin >> 6, ymin = bbox.yMin >> 6;
int xmax = bbox.xMax >> 6, ymax = bbox.yMax >> 6;
if(bbox.xMax & 0x3f) xmax++;
if(bbox.yMax & 0x3f) ymax++;
pixelwidth = xmax - xmin;
pixelheight = ymax - ymin;
This calculation gives me an exact fit only if I don't apply any
rotation to the shape using FT_Outline_Transform(). As soon as I
apply a transformation matrix on my FT_Outline, it happens very
often that either the very first row is empty or the very last
column is empty.
Also note that I do a
FT_Outline_Translate(&outline, -bbox.xMin, -bbox.yMin);
before calling FT_Outline_Get_Bitmap().
Marco
- Re: [ft] Determining pixel dimensions for bitmap, Marco Wertz, 2014/11/02
- Re: [ft] Determining pixel dimensions for bitmap, J Decker, 2014/11/02
- Re: [ft] Determining pixel dimensions for bitmap, Marco Wertz, 2014/11/02
- Re: [ft] Determining pixel dimensions for bitmap, Werner LEMBERG, 2014/11/03
- Re: [ft] Determining pixel dimensions for bitmap, Alexei Podtelezhnikov, 2014/11/03
- Re: [ft] Determining pixel dimensions for bitmap, Marco Wertz, 2014/11/03
- Re: [ft] Determining pixel dimensions for bitmap, Dave Arnold, 2014/11/03
- Re: [ft] Determining pixel dimensions for bitmap, Werner LEMBERG, 2014/11/04
- Re: [ft] Determining pixel dimensions for bitmap,
Marco Wertz <=
- Re: [ft] Determining pixel dimensions for bitmap, Werner LEMBERG, 2014/11/05
- Re: [ft] Determining pixel dimensions for bitmap, Marco Wertz, 2014/11/06
- Re: [ft] Determining pixel dimensions for bitmap, Werner LEMBERG, 2014/11/07
- Re: [ft] Determining pixel dimensions for bitmap, Marco Wertz, 2014/11/07