RE: [ft-devel] ftgray.c STANDALONE module demo?

2007-12-18 Thread Allan Yang, Jian Hua - SH
> I'm not sure if this is helpful, since I don't define _STANDALONE_, I

> use the whole FreeType library; but I do use a callback function with

> ft_raster_flag_direct. The following code works with FreeType version

> 2.1.4 (sorry, haven't updated for a while).

Thank you Wenlin!


Allan


___
Freetype-devel mailing list
[email protected]
http://lists.nongnu.org/mailman/listinfo/freetype-devel


Re: [ft-devel] ftgray.c STANDALONE module demo?

2007-12-17 Thread Wenlin Institute


On Dec 17, 2007, at 1:34 AM, Werner LEMBERG wrote:


Referenced to ftgray.c's comments, I have compile `ftgrays' with the
_STANDALONE_ macro defined.  [...]  My question is how to us this
lib after compile it?  Anybody would give a usage demo?


I believe that such a demo usage has never been given on the list.  In
case someone can provide this I would be glad to add it as a very
simple demo to the ft2demos bundle.


I'm not sure if this is helpful, since I don't define _STANDALONE_, I  
use the whole FreeType library; but I do use a callback function with  
ft_raster_flag_direct. The following code works with FreeType version  
2.1.4 (sorry, haven't updated for a while).


params.flags = ft_raster_flag_aa | ft_raster_flag_direct;
params.gray_spans = WenlinGrayRenderSpan; // callback
wenlinGrayTarget = &ttMap;
FT_Outline_Render(ttEngine, &ftOutline, ¶ms);

static void WenlinGrayRenderSpan(int y, int count, FT_Span* spans,  
void *raster)

/* Callback function.
See FT_Raster_Span_Func in ftimage.h, and model gray_render_span 
() in ftgrays.c
The original fourth parameter was "PRaster", but that's only  
defined in ftgrays.c,
so we just set wenlinGrayTarget to point to the bitmap (same as  
raster->target).
The difference from the original function is that we require  
that the new value
for a pixel ("coverage") is "darker" (numerically greater) than  
the current
value; if not darker, keep the current color. This allows us to  
rasterize Hanzi
one stroke at a time; otherwise, the anti-aliasing looks wrong  
when strokes overlap.  */

{
FT_Bitmap *map = wenlinGrayTarget; // = &raster->target;
size_t scanlineOffset, offsetLimit;

/* First of all, compute the scanline offset. */
if (map->pitch >= 0) {
if (y + 1 > map->rows) {
 return;
}
scanlineOffset = (map->rows - 1 - y) * map->pitch;
}
else {
scanlineOffset = y * (0 - map->pitch);
}
/* Make it bomb-proof, don't write outside bitmap! */
offsetLimit = map->width * map->rows;
if (scanlineOffset >= offsetLimit) {
SorryGenericWarning("WenlinGrayRenderSpan");
return;
}
for ( ; count > 0; count--, spans++) {
uc c = spans->coverage;
if (c) {
size_t ofs = scanlineOffset + spans->x;
size_t len = spans->len;
if (ofs + len <= offsetLimit) {
while (len--) {
// This test is unique to the Wenlin version.
if (c > map->buffer[ofs]) {
map->buffer[ofs] = c;
}
++ofs;
}
}
}
}
} // WenlinGrayRenderSpan

文林 Wenlin Institute, Inc.Software for Learning Chinese
E-mail: [EMAIL PROTECTED] Web: http://www.wenlin.com
Telephone: 1-877-4-WENLIN (1-877-493-6546)
☯







___
Freetype-devel mailing list
[email protected]
http://lists.nongnu.org/mailman/listinfo/freetype-devel


Re: [ft-devel] ftgray.c STANDALONE module demo?

2007-12-17 Thread Werner LEMBERG
> Referenced to ftgray.c's comments, I have compile `ftgrays' with the
> _STANDALONE_ macro defined.  [...]  My question is how to us this
> lib after compile it?  Anybody would give a usage demo?

I believe that such a demo usage has never been given on the list.  In
case someone can provide this I would be glad to add it as a very
simple demo to the ft2demos bundle.


Werner


___
Freetype-devel mailing list
[email protected]
http://lists.nongnu.org/mailman/listinfo/freetype-devel


[ft-devel] ftgray.c STANDALONE module demo?

2007-12-16 Thread Allan Yang, Jian Hua - SH
Referenced to ftgray.c's comments, I have compile `ftgrays' with the
_STANDALONE_ macro defined. And It looks like I wonder that *directly
render* glyph to own display surface
(http://www.nabble.com/How-can-I-directly-rendering-bitmap-object-on-my-
specified-memory--to14164356.html). The comments as:

It doesn't need an intermediate bitmap.  Instead, one can supply a
callback function that will be called by the renderer to draw gray spans
on any target surface.  You can thus do direct composition on any kind
of bitmap, provided that you give the renderer the right callback.

 

My question is how to us this lib after compile it? Anybody would give a
usage demo?

 

Thanks.

 

 

 

--BTW, I found ftraster.c cannot compile with _STANDALONE_ macro as it
said.

 

Allan

___
Freetype-devel mailing list
[email protected]
http://lists.nongnu.org/mailman/listinfo/freetype-devel