[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
RE: [ft] rasterize outline with antialias or clear type
From: |
Matteo Lanzi |
Subject: |
RE: [ft] rasterize outline with antialias or clear type |
Date: |
Mon, 11 Oct 2010 11:09:45 +0200 |
Hi Werner,
it works fine for the antialias except that the background is gray instead
of white... any suggestion
Anyway is there a module to use as standalone for CLEAR TYPE ?
This is the modified coded if someone needs it (I just changed the 3 lines
about the raster )
If you want to use it as standalone please remember to put
#include "freetype/fttypes.h" in ftgrays.c .. that worked for me
///////////////////////////
// RASTERIZE
FT_Memory mem;
mem = new FT_MemoryRec_;
mem->alloc = MY_Alloc_Func;
mem->free = MY_Free_Func;
mem->realloc = MY_Realloc_Func;
const int width = 500;
const int rows = 600;
// 8 bits per pixel; must be a multiple of four.
const int pitch_gray = width;
FT_Bitmap bmp;
FT_Raster raster;
FT_Raster_Params params;
// Allocate a chunk of memory for the render pool.
const int kRenderPoolSize = 1024 * 768;
unsigned char *renderPool = new unsigned
char[kRenderPoolSize];
// Set up a pixmap.
bmp.buffer = new unsigned char[rows * pitch_gray];
memset(bmp.buffer, 0, rows * pitch_gray);
bmp.width = width;
bmp.rows = rows;
bmp.pitch = pitch_gray;
bmp.pixel_mode = FT_PIXEL_MODE_GRAY;
bmp.num_grays = 0xFF;
// Set up the necessary raster parameters.
memset(¶ms, 0, sizeof (params));
params.source = &outline;
params.target = &bmp;
params.flags = FT_RASTER_FLAG_AA | FT_RASTER_FLAG_CLIP ;
ft_grays_raster.raster_new (mem, &raster ) ;
ft_grays_raster.raster_reset(raster, renderPool,
kRenderPoolSize ) ;
error = ft_grays_raster.raster_render(raster, ¶ms ) ;
ft_grays_raster.raster_done ( raster ) ;
> -----Original Message-----
> From: Werner LEMBERG [mailto:address@hidden
> Sent: venerdì 8 ottobre 2010 00:14
> To: address@hidden
> Cc: address@hidden
> Subject: Re: [ft] rasterize outline with antialias or clear type
>
>
> > - Is it possible to rasterize one outline with cleartype rasterizer?
>
> It depends what you mean with `ClearType'. If you mean a threefold
> increase in horizontal resolution which gets squeezed back in the
> proper LCD mode, then yes. If you mean the special handling of
> TrueType instructions, then no since it is not implemented yet (but
> there will be soon something into this direction).
>
> > - I tried to rasterize some outline extract from a glyph with Werner
> > Lemberg' example3 in the documentation; it works fine but there is
> > no antialias even if I have setted
> >
> > bmp.pixel_mode = FT_PIXEL_MODE_GRAY;
> > bmp.num_grays = 256;
>
> example3.cpp uses the B/W renderer (in ftraster.c). You need
> ftgrays.c instead which works in standalone mode too.
>
>
> Werner