q-lang-cvs Mailing List for Q - Equational Programming Language (Page 131)
Brought to you by:
agraef
You can subscribe to this list here.
2003 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
(106) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2004 |
Jan
(219) |
Feb
(152) |
Mar
|
Apr
(92) |
May
(45) |
Jun
(3) |
Jul
|
Aug
(3) |
Sep
(111) |
Oct
(52) |
Nov
|
Dec
|
2005 |
Jan
|
Feb
(1) |
Mar
(1) |
Apr
(2) |
May
(23) |
Jun
(46) |
Jul
(158) |
Aug
(22) |
Sep
|
Oct
(26) |
Nov
(11) |
Dec
(49) |
2006 |
Jan
(57) |
Feb
(196) |
Mar
(10) |
Apr
(41) |
May
(149) |
Jun
(308) |
Jul
(11) |
Aug
(25) |
Sep
(15) |
Oct
|
Nov
|
Dec
(15) |
2007 |
Jan
|
Feb
|
Mar
|
Apr
(15) |
May
(204) |
Jun
(112) |
Jul
(7) |
Aug
(16) |
Sep
(134) |
Oct
(313) |
Nov
(262) |
Dec
(83) |
2008 |
Jan
(81) |
Feb
(83) |
Mar
(21) |
Apr
|
May
|
Jun
(1) |
Jul
(2) |
Aug
(6) |
Sep
|
Oct
|
Nov
|
Dec
(2) |
2015 |
Jan
|
Feb
|
Mar
|
Apr
|
May
(2) |
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
From: <ag...@us...> - 2003-12-21 10:54:39
|
Update of /cvsroot/q-lang/q/modules/ggi In directory sc8-pr-cvs1:/tmp/cvs-serv32361 Modified Files: ggi.c Log Message: more bug fixes in text renderer Index: ggi.c =================================================================== RCS file: /cvsroot/q-lang/q/modules/ggi/ggi.c,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -d -r1.12 -r1.13 *** ggi.c 20 Dec 2003 22:06:16 -0000 1.12 --- ggi.c 21 Dec 2003 10:54:35 -0000 1.13 *************** *** 1562,1567 **** /* blit the rendered string to the visual */ - if (!(pixel = malloc(pack_size(v->vis, dim)))) return 0; - error = ggiPackColors(v->vis, pixel, col, dim); if (!error) { #ifdef HAVE_GGIBUF --- 1562,1565 ---- *************** *** 1577,1586 **** n = j*wd+i; ggiBufSetGCForeground(v->b[0], col[n].a/0x101); ! ggiPutPixel(vis, x+i, y+j, pixel[n]); } ggiBufSetGCForeground(v->b[0], val); ! } else #endif ! error = ggiPutBox(v->vis, x, y, wd, ht, pixel); } free(col); --- 1575,1590 ---- n = j*wd+i; ggiBufSetGCForeground(v->b[0], col[n].a/0x101); ! ggiPutPixel(vis, x+i, y+j, ggiMapColor(vis, &col[n])); } ggiBufSetGCForeground(v->b[0], val); ! } else { #endif ! if (!(pixel = malloc(pack_size(v->vis, dim)))) { ! free(col); ! return 0; ! } ! error = ggiPackColors(v->vis, pixel, col, dim) || ! ggiPutBox(v->vis, x, y, wd, ht, pixel); ! } } free(col); |
From: <ag...@us...> - 2003-12-20 22:17:54
|
Update of /cvsroot/q-lang/q In directory sc8-pr-cvs1:/tmp/cvs-serv29381 Modified Files: ChangeLog Log Message: updated ChangeLog; call it a day :) Index: ChangeLog =================================================================== RCS file: /cvsroot/q-lang/q/ChangeLog,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** ChangeLog 19 Dec 2003 21:31:34 -0000 1.5 --- ChangeLog 20 Dec 2003 22:17:50 -0000 1.6 *************** *** 1,2 **** --- 1,17 ---- + 2003-12-20 Albert Graef <Dr....@t-...> + + * ggi.q, ggi.c: added ggi_get_string_bbox operation to determine + the bounding box of a string relative to the baseline, more + elaborate ggi_get_font_info, additional operations to retrieve + antialiasing status and current transform, more bug fixes + + * ggi.c: fixed mono text rendering, optimizations in renderer, bug + fix in bbox calculation + + * ggi.c: implemented alpha blending in text renderer + + * ggi.c: make transformed glyphs work in text renderer, plug + memory leaks + 2003-12-19 Albert Graef <Dr....@t-...> |
From: <ag...@us...> - 2003-12-20 22:06:20
|
Update of /cvsroot/q-lang/q/modules/ggi In directory sc8-pr-cvs1:/tmp/cvs-serv27867 Modified Files: ggi.c ggi.q Log Message: added functions to retrieve the current antialias mode and transform Index: ggi.c =================================================================== RCS file: /cvsroot/q-lang/q/modules/ggi/ggi.c,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** ggi.c 20 Dec 2003 21:41:27 -0000 1.11 --- ggi.c 20 Dec 2003 22:06:16 -0000 1.12 *************** *** 1115,1118 **** --- 1115,1133 ---- } + FUNCTION(ggi,ggi_get_antialias,argc,argv) + { + #ifdef HAVE_FT2 + visual_t *v; + if (init && argc == 1 && isobj(argv[0], type(GGIVisual), (void**)&v) && + v->vis && v->face) { + if (v->aa) + return mktrue; + else + return mkfalse; + } else + #endif + return __FAIL; + } + FUNCTION(ggi,ggi_set_transform,argc,argv) { *************** *** 1159,1162 **** --- 1174,1212 ---- } return mkvoid; + } else + #endif + return __FAIL; + } + + FUNCTION(ggi,ggi_get_transform_vector,argc,argv) + { + #ifdef HAVE_FT2 + visual_t *v; + if (init && argc == 1 && isobj(argv[0], type(GGIVisual), (void**)&v) && + v->vis && v->face) { + if (v->vect) + return mktuplel(2, mkfloat(((double)v->vect->x)/0x40), + mkfloat(((double)v->vect->y)/0x40)); + else + return mktuplel(2, mkfloat(0.0), mkfloat(0.0)); + } else + #endif + return __FAIL; + } + + FUNCTION(ggi,ggi_get_transform_matrix,argc,argv) + { + #ifdef HAVE_FT2 + visual_t *v; + if (init && argc == 1 && isobj(argv[0], type(GGIVisual), (void**)&v) && + v->vis && v->face) { + if (v->matrix) + return mktuplel(4, mkfloat(((double)v->matrix->xx)/0x10000L), + mkfloat(((double)v->matrix->xy)/0x10000L), + mkfloat(((double)v->matrix->yx)/0x10000L), + mkfloat(((double)v->matrix->yy)/0x10000L)); + else + return mktuplel(4, mkfloat(1.0), mkfloat(0.0), mkfloat(0.0), + mkfloat(1.0)); } else #endif Index: ggi.q =================================================================== RCS file: /cvsroot/q-lang/q/modules/ggi/ggi.q,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** ggi.q 20 Dec 2003 21:29:36 -0000 1.6 --- ggi.q 20 Dec 2003 22:06:16 -0000 1.7 *************** *** 377,392 **** /* Specify whether the font should be antialiased. If true (which is the default), text will be rendered in up to 256 different shades of the ! foreground color, to give it a smoother appearance. */ ! public extern ggi_set_antialias VIS FLAG; /* Specify an affine transformation to be applied before a string is rendered on the visual. The font must be scalable for this to work. This can be used to print translated, rotated and stretched text. The transformation is ! given by a translation vector VECT = (X,Y) and a 2x2 matrix MATRIX = (XX,XY,YX,YY). E.g., to rotate text by an angle A counter-clockwise, you would use a transform matrix of the form (cos A, -sin A, sin A, cos A). */ ! public extern ggi_set_transform VIS VECT MATRIX; /* Retrieve general information about the loaded font. The ggi_get_font_info --- 377,399 ---- /* Specify whether the font should be antialiased. If true (which is the default), text will be rendered in up to 256 different shades of the ! foreground color, to give it a smoother appearance. The ggi_get_antialias ! function is used to retrieve the current setting. */ ! public extern ggi_set_antialias VIS FLAG, ggi_get_antialias VIS; /* Specify an affine transformation to be applied before a string is rendered on the visual. The font must be scalable for this to work. This can be used to print translated, rotated and stretched text. The transformation is ! given by a translation vector VECTOR = (X,Y) and a 2x2 matrix MATRIX = (XX,XY,YX,YY). E.g., to rotate text by an angle A counter-clockwise, you would use a transform matrix of the form (cos A, -sin A, sin A, cos A). */ ! public extern ggi_set_transform VIS VECTOR MATRIX; ! ! /* The following functions can be used to retrieve the current transform ! vector and matrix. */ ! ! public extern ggi_get_transform_vector VIS; ! public extern ggi_get_transform_matrix VIS; /* Retrieve general information about the loaded font. The ggi_get_font_info |
From: <ag...@us...> - 2003-12-20 21:41:30
|
Update of /cvsroot/q-lang/q/modules/ggi In directory sc8-pr-cvs1:/tmp/cvs-serv24153 Modified Files: ggi.c Log Message: more bug fixes in text renderer Index: ggi.c =================================================================== RCS file: /cvsroot/q-lang/q/modules/ggi/ggi.c,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** ggi.c 20 Dec 2003 21:29:36 -0000 1.10 --- ggi.c 20 Dec 2003 21:41:27 -0000 1.11 *************** *** 1471,1484 **** int i = r+p; if (bufp[p]) { ! #if 1 ! /* for now we just do shades of the foreground color -- is this ! the right way to do it? */ ! col[i].r = ((long)fgcol.r)*bufp[p]/0xff; ! col[i].g = ((long)fgcol.g)*bufp[p]/0xff; ! col[i].b = ((long)fgcol.b)*bufp[p]/0xff; ! col[i].a = ((long)fgcol.a)*bufp[p]/0xff; ! #else ! /* here's an alternative implementation: blend fg with bg color ! -- but this looks odd with some fg/bg combinations */ col[i].r = (((long)fgcol.r)*bufp[p]+ ((long)bgcol.r)*(0xff-bufp[p]))/0xff; --- 1471,1476 ---- int i = r+p; if (bufp[p]) { ! /* blend fg with bg color -- this looks odd with some fg/bg ! combinations, is there a better way to do this? */ col[i].r = (((long)fgcol.r)*bufp[p]+ ((long)bgcol.r)*(0xff-bufp[p]))/0xff; *************** *** 1489,1493 **** col[i].a = (((long)fgcol.a)*bufp[p]+ ((long)bgcol.a)*(0xff-bufp[p]))/0xff; - #endif } --- 1481,1484 ---- |
From: <ag...@us...> - 2003-12-20 21:29:46
|
Update of /cvsroot/q-lang/q/modules/ggi In directory sc8-pr-cvs1:/tmp/cvs-serv22227 Modified Files: ggi.c ggi.q Log Message: improved ggi_get_font_info Index: ggi.c =================================================================== RCS file: /cvsroot/q-lang/q/modules/ggi/ggi.c,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** ggi.c 20 Dec 2003 19:09:34 -0000 1.9 --- ggi.c 20 Dec 2003 21:29:36 -0000 1.10 *************** *** 182,190 **** #endif FUNCTION(ggi,ggi_vars,argc,argv) { if (argc != 0) return __FAIL; return mktuplel ! (105, mkuint(GGIFLAG_ASYNC), mkuint(GGIFLAG_TIDYBUF), /* buffer flags */ --- 182,206 ---- #endif + #ifndef HAVE_FT2 + #define FT_FACE_FLAG_SCALABLE 0 + #define FT_FACE_FLAG_FIXED_SIZES 0 + #define FT_FACE_FLAG_FIXED_WIDTH 0 + #define FT_FACE_FLAG_SFNT 0 + #define FT_FACE_FLAG_HORIZONTAL 0 + #define FT_FACE_FLAG_VERTICAL 0 + #define FT_FACE_FLAG_KERNING 0 + #define FT_FACE_FLAG_FAST_GLYPHS 0 + #define FT_FACE_FLAG_MULTIPLE_MASTERS 0 + #define FT_FACE_FLAG_GLYPH_NAMES 0 + #define FT_FACE_FLAG_EXTERNAL_STREAM 0 + #define FT_STYLE_FLAG_ITALIC 0 + #define FT_STYLE_FLAG_BOLD 0 + #endif + FUNCTION(ggi,ggi_vars,argc,argv) { if (argc != 0) return __FAIL; return mktuplel ! (118, mkuint(GGIFLAG_ASYNC), mkuint(GGIFLAG_TIDYBUF), /* buffer flags */ *************** *** 246,250 **** mkuint(GII_PT_VOLTAGE), mkuint(GII_PT_RESISTANCE), mkuint(GII_PT_CAPACITY), ! mkuint(GII_PT_INDUCTIVITY)); } --- 262,280 ---- mkuint(GII_PT_VOLTAGE), mkuint(GII_PT_RESISTANCE), mkuint(GII_PT_CAPACITY), ! mkuint(GII_PT_INDUCTIVITY), ! /* font properties */ ! mkuint(FT_FACE_FLAG_SCALABLE), ! mkuint(FT_FACE_FLAG_FIXED_SIZES), ! mkuint(FT_FACE_FLAG_FIXED_WIDTH), ! mkuint(FT_FACE_FLAG_SFNT), ! mkuint(FT_FACE_FLAG_HORIZONTAL), ! mkuint(FT_FACE_FLAG_VERTICAL), ! mkuint(FT_FACE_FLAG_KERNING), ! mkuint(FT_FACE_FLAG_FAST_GLYPHS), ! mkuint(FT_FACE_FLAG_MULTIPLE_MASTERS), ! mkuint(FT_FACE_FLAG_GLYPH_NAMES), ! mkuint(FT_FACE_FLAG_EXTERNAL_STREAM), ! mkuint(FT_STYLE_FLAG_ITALIC), ! mkuint(FT_STYLE_FLAG_BOLD)); } *************** *** 1140,1144 **** if (init && argc == 1 && isobj(argv[0], type(GGIVisual), (void**)&v) && v->vis && v->face) { ! expr flag, *sizes = NULL; int i, n = v->face->num_fixed_sizes; if (n > 0 && !(sizes = xvalloc(n))) return __ERROR; --- 1170,1174 ---- if (init && argc == 1 && isobj(argv[0], type(GGIVisual), (void**)&v) && v->vis && v->face) { ! expr *sizes = NULL; int i, n = v->face->num_fixed_sizes; if (n > 0 && !(sizes = xvalloc(n))) return __ERROR; *************** *** 1147,1156 **** mkint(v->face->available_sizes[i].height)); if (FT_IS_SCALABLE(v->face)) ! flag = mktrue; else ! flag = mkfalse; ! return mktuplel(4, mkstr(strdup(v->face->family_name)), ! mkstr(strdup(v->face->style_name)), ! flag, mklistv(n, sizes)); } else #endif --- 1177,1209 ---- mkint(v->face->available_sizes[i].height)); if (FT_IS_SCALABLE(v->face)) ! return mktuplel(18, mkint(v->face->num_faces), ! mkint(v->face->face_index), ! mkuint(v->face->face_flags), ! mkuint(v->face->style_flags), ! mkstr(strdup(v->face->family_name)), ! mkstr(strdup(v->face->style_name)), ! mklistv(n, sizes), ! mkuint(v->face->units_per_EM), ! mkuint(v->face->size->metrics.x_ppem), ! mkuint(v->face->size->metrics.y_ppem), ! mktuplel(4, mkint(v->face->bbox.xMin), ! mkint(v->face->bbox.xMax), ! mkint(v->face->bbox.yMin), ! mkint(v->face->bbox.yMax)), ! mkint(v->face->ascender), ! mkint(v->face->descender), ! mkint(v->face->height), ! mkint(v->face->max_advance_width), ! mkint(v->face->max_advance_height), ! mkint(v->face->underline_position), ! mkint(v->face->underline_thickness)); else ! return mktuplel(7, mkint(v->face->num_faces), ! mkint(v->face->face_index), ! mkuint(v->face->face_flags), ! mkuint(v->face->style_flags), ! mkstr(strdup(v->face->family_name)), ! mkstr(strdup(v->face->style_name)), ! mklistv(n, sizes)); } else #endif Index: ggi.q =================================================================== RCS file: /cvsroot/q-lang/q/modules/ggi/ggi.q,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** ggi.q 20 Dec 2003 19:09:34 -0000 1.5 --- ggi.q 20 Dec 2003 21:29:36 -0000 1.6 *************** *** 117,120 **** --- 117,139 ---- GGI_PT_INDUCTIVITY; /* base unit Vs/A (Henry) */ + /* The following FreeType2 flag values describe various font properties. These + values, bitwise or'ed together, are returned by ggi_get_font_info in the + FACE_FLAGS and STYLE_FLAGS fields of a font info structure. */ + + public var const + FT_FACE_FLAG_SCALABLE, + FT_FACE_FLAG_FIXED_SIZES, + FT_FACE_FLAG_FIXED_WIDTH, + FT_FACE_FLAG_SFNT, + FT_FACE_FLAG_HORIZONTAL, + FT_FACE_FLAG_VERTICAL, + FT_FACE_FLAG_KERNING, + FT_FACE_FLAG_FAST_GLYPHS, + FT_FACE_FLAG_MULTIPLE_MASTERS, + FT_FACE_FLAG_GLYPH_NAMES, + FT_FACE_FLAG_EXTERNAL_STREAM, + FT_STYLE_FLAG_ITALIC, + FT_STYLE_FLAG_BOLD; + private extern ggi_vars; *************** *** 165,169 **** GGI_PT_FORCE, GGI_PT_PRESSURE, GGI_PT_TORQUE, GGI_PT_ENERGY, GGI_PT_POWER, GGI_PT_TEMPERATURE, GGI_PT_CURRENT, GGI_PT_VOLTAGE, ! GGI_PT_RESISTANCE, GGI_PT_CAPACITY, GGI_PT_INDUCTIVITY ) = ggi_vars; --- 184,196 ---- GGI_PT_FORCE, GGI_PT_PRESSURE, GGI_PT_TORQUE, GGI_PT_ENERGY, GGI_PT_POWER, GGI_PT_TEMPERATURE, GGI_PT_CURRENT, GGI_PT_VOLTAGE, ! GGI_PT_RESISTANCE, GGI_PT_CAPACITY, GGI_PT_INDUCTIVITY, ! /* font properties */ ! FT_FACE_FLAG_SCALABLE, FT_FACE_FLAG_FIXED_SIZES, ! FT_FACE_FLAG_FIXED_WIDTH, FT_FACE_FLAG_SFNT, ! FT_FACE_FLAG_HORIZONTAL, FT_FACE_FLAG_VERTICAL, ! FT_FACE_FLAG_KERNING, FT_FACE_FLAG_FAST_GLYPHS, ! FT_FACE_FLAG_MULTIPLE_MASTERS, FT_FACE_FLAG_GLYPH_NAMES, ! FT_FACE_FLAG_EXTERNAL_STREAM, FT_STYLE_FLAG_ITALIC, ! FT_STYLE_FLAG_BOLD ) = ggi_vars; *************** *** 330,334 **** metric file. The font metric data is needed to do proper kerning in proportional fonts, and should be loaded immediately after calling ! ggi_set_font. Not that this is only necessary for some types of fonts which have their metrics in a separate file. A typical example are Type 1 font files, which have the font data in a file with extension .pfa or .pfb, and --- 357,361 ---- metric file. The font metric data is needed to do proper kerning in proportional fonts, and should be loaded immediately after calling ! ggi_set_font. Note that this is only necessary for some types of fonts which have their metrics in a separate file. A typical example are Type 1 font files, which have the font data in a file with extension .pfa or .pfb, and *************** *** 339,344 **** /* Set the character size SIZE (in pt = 1/72 of an inch, this can be a floating point value to denote fractional sizes) and display resolution RES ! (in dpi = dots per inch). The actual size of the characters on the display ! in pixels will be calculated from these values according to the formula PIXEL_SIZE = SIZE*RES/72. SIZE and RES can also be specified as pairs of values, to indicate different values for the x and y direction. Moreover, a --- 366,371 ---- /* Set the character size SIZE (in pt = 1/72 of an inch, this can be a floating point value to denote fractional sizes) and display resolution RES ! (in dpi = dots per inch). The actual display size of the characters in ! pixels will be calculated from these values according to the formula PIXEL_SIZE = SIZE*RES/72. SIZE and RES can also be specified as pairs of values, to indicate different values for the x and y direction. Moreover, a *************** *** 354,361 **** public extern ggi_set_antialias VIS FLAG; ! /* Specify an arbitrary affine transformation to be applied before a string is ! rendered on the visual. The font must be scalable for this to work. This ! can be used, e.g., to print rotated or stretched text. The transformation ! is given by a translation vector VECT = (X,Y) and a 2x2 matrix MATRIX = (XX,XY,YX,YY). E.g., to rotate text by an angle A counter-clockwise, you would use a transform matrix of the form (cos A, -sin A, sin A, cos A). */ --- 381,388 ---- public extern ggi_set_antialias VIS FLAG; ! /* Specify an affine transformation to be applied before a string is rendered ! on the visual. The font must be scalable for this to work. This can be used ! to print translated, rotated and stretched text. The transformation is ! given by a translation vector VECT = (X,Y) and a 2x2 matrix MATRIX = (XX,XY,YX,YY). E.g., to rotate text by an angle A counter-clockwise, you would use a transform matrix of the form (cos A, -sin A, sin A, cos A). */ *************** *** 363,377 **** public extern ggi_set_transform VIS VECT MATRIX; ! /* Retrieve information about the loaded font. Only the most important font ! attributes are supported right now. (TODO: Add info about available glyphs, ! charmaps, and global font metrics of scalable fonts here.) Returns a tuple ! with the following information: ! - FAMILY, STYLE: strings describing the family and style of the font ! - SCALABLE: a flag indicating whether the font is scalable ! - SIZES: list of character sizes ((WD,HT) in pixels) of included bitmap ! fonts */ public extern ggi_get_font_info VIS; --- 390,443 ---- public extern ggi_set_transform VIS VECT MATRIX; ! /* Retrieve general information about the loaded font. The ggi_get_font_info ! function returns a tuple with the following information: ! - NFACES, INDEX: The total number of faces in this font, and the index of ! the selected face. ! - FACE_FLAGS: A bitset (bitwise or'ed FT_FACE_FLAG_* values) describing ! various properties of the face. The most interesting one is ! FT_FACE_FLAG_SCALABLE which is set for scalable fonts. ! - STYLE_FLAGS: A bitset (bitwise or'ed FT_STYLE_FLAG_* values) describing ! various style properties of the face (bold, italic, etc.). ! ! - FAMILY, STYLE: These are string values describing the family and style of ! the font. ! ! - SIZES: A list of character sizes ((W,H) in pixels) of included bitmap ! fonts. ! ! The remaining fields are only available for scalable fonts. Please refer to ! the FreeType2 documentation for a closer description of these values. Note ! that all given dimensions, with the exception of X_PPEM and Y_PPEM, are in ! design a.k.a. font units; once the actual character size has been set with ! ggi_set_char_size, you can translate these values to pixels according to ! the formula PIXELS = FONT_UNITS*PPEM/UNITS_PER_EM. ! ! - UNITS_PER_EM: The size of the EM square for the font face. ! ! - X_PPEM, Y_PPEM: The horizontal and vertical size of the EM square in ! pixels. These values are meaningful only after a character size has been ! set. ! ! - BBOX: A tuple (XMIN,XMAX,YMIN,YMAX) describing the maximum bounding box ! for all glyphs in the font ! ! - ASCENDER, DESCENDER: The vertical distance from the horizontal baseline ! to the highest and lowest "character" coordinate in a font face, ! respectively. (Unfortunately, just what "character" means in this context ! is defined differently for different fonts.) ! ! - HEIGHT: The default line spacing (baseline-to-baseline distance) for the ! font. ! ! - MAX_ADVANCE_WIDTH, MAX_ADVANCE_HEIGHT: The maximum horizontal and ! vertical cursor advance for all glyphs in the font. (Note that the latter ! is only defined for vertical fonts which currently aren't supported ! anyway.) ! ! - UNDERLINE_POSITION, UNDERLINE_THICKNESS: The vertical position, relative ! to the baseline, of the underline bar, and its vertical thickness. */ public extern ggi_get_font_info VIS; |
From: <ag...@us...> - 2003-12-20 19:09:37
|
Update of /cvsroot/q-lang/q/modules/ggi In directory sc8-pr-cvs1:/tmp/cvs-serv4723 Modified Files: ggi.c ggi.q Log Message: added ggi_get_string_bbox operation Index: ggi.c =================================================================== RCS file: /cvsroot/q-lang/q/modules/ggi/ggi.c,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** ggi.c 20 Dec 2003 17:34:36 -0000 1.8 --- ggi.c 20 Dec 2003 19:09:34 -0000 1.9 *************** *** 1505,1509 **** /* compute the bounding box of a rendered string */ ! static int bbox(visual_t *v, char *s, int *wd, int *ht) { ggi_visual_t vis = v->vis; --- 1505,1511 ---- /* compute the bounding box of a rendered string */ ! static int bbox(visual_t *v, char *s, ! int *xmin, int *xmax, ! int *ymin, int *ymax) { ggi_visual_t vis = v->vis; *************** *** 1516,1520 **** FT_BBox bbox; /* bounding box */ ! *wd = *ht = 0; if (!glyphs) return (l==0); --- 1518,1522 ---- FT_BBox bbox; /* bounding box */ ! *xmin = *xmax = *ymin = *ymax = 0; if (!glyphs) return (l==0); *************** *** 1567,1572 **** FT_Done_Glyph(glyphs[n].image); free(glyphs); ! *wd = bbox.xMax - bbox.xMin; ! *ht = bbox.yMax - bbox.yMin; return 1; } --- 1569,1576 ---- FT_Done_Glyph(glyphs[n].image); free(glyphs); ! *xmin = bbox.xMin; ! *xmax = bbox.xMax; ! *ymin = bbox.yMin; ! *ymax = bbox.yMax; return 1; } *************** *** 1574,1581 **** #endif ! FUNCTION(ggi,ggi_get_string_size,argc,argv) { visual_t *v; ! int w, h; char *s; if (init && argc == 2 && isobj(argv[0], type(GGIVisual), (void**)&v) && --- 1578,1585 ---- #endif ! FUNCTION(ggi,ggi_get_string_bbox,argc,argv) { visual_t *v; ! int xmin, xmax, ymin, ymax; char *s; if (init && argc == 2 && isobj(argv[0], type(GGIVisual), (void**)&v) && *************** *** 1583,1596 **** #ifdef HAVE_FT2 if (v->face) ! if (bbox(v, s, &w, &h)) ! return mktuplel(2, mkint(w), mkint(h)); else return __FAIL; else #endif ! if (ggiGetCharSize(v->vis, &w, &h)) return __FAIL; else ! return mktuplel(2, mkint(w*strlen(s)), mkint(h)); else return __FAIL; --- 1587,1601 ---- #ifdef HAVE_FT2 if (v->face) ! if (bbox(v, s, &xmin, &xmax, &ymin, &ymax)) ! return mktuplel(4, mkint(xmin), mkint(xmax), mkint(ymin), mkint(ymax)); else return __FAIL; else #endif ! if (ggiGetCharSize(v->vis, &xmax, &ymax)) return __FAIL; else ! return mktuplel(4, mkint(0), mkint(xmax*strlen(s)), mkint(0), ! mkint(ymax)); else return __FAIL; Index: ggi.q =================================================================== RCS file: /cvsroot/q-lang/q/modules/ggi/ggi.q,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** ggi.q 20 Dec 2003 18:09:39 -0000 1.4 --- ggi.q 20 Dec 2003 19:09:34 -0000 1.5 *************** *** 401,414 **** /* Drawing text on a visual. These operations use the current font (GGI's builtin font by default) and the current foreground and background colors ! to render text on a visual. Note that control characters in the text are ! *not* interpreted, and *no* word wrap is performed. So the correct layout ! of the text is up to you. To these ends, the ggi_get_string_size function ! allows you to calculate the width and height of the bounding box of a ! rendered string. Individual characters and character strings can be placed ! at the given position P = (X,Y) with the ggi_putc and ggi_puts operations, ! respectively. */ - public extern ggi_get_string_size VIS S; public extern ggi_putc VIS P C, ggi_puts VIS P S; /* Get and put operations. The get operations allow you to retrieve a pixel, --- 401,441 ---- /* Drawing text on a visual. These operations use the current font (GGI's builtin font by default) and the current foreground and background colors ! to render text on a visual. Individual characters and character strings can ! be placed at the given position P = (X,Y) with the ggi_putc and ggi_puts ! operations, respectively. Note that control characters in the text are ! *not* interpreted, and *no* word wrap is performed. So the entire layout of ! the text is up to you. Additional operations are provided to help with ! this, see below. */ public extern ggi_putc VIS P C, ggi_puts VIS P S; + + /* The following operations can be used to handle the layout of text in a + visual. Both operations take into account the current text transform set on + a visual. Thus, if the transform specifies a translation, rotation or + stretching of the text, the returned figures will change accordingly. + + The ggi_get_string_size function allows you to calculate the dimensions of + the bounding box of a rendered string, which is useful, e.g., for centering + text. It returns a pair (W,H), where W denotes the width and H the height + of the rendered text. + + The ggi_get_string_bbox function gives you finer control over the layout + process. It returns four values (XMIN,XMAX,YMIN,YMAX) which describe the + bounding box of the string in relationship to the baseline. For the default + font, the XMIN and YMIN values are always zero, and the XMAX and YMAX + values correspond to the width and height of the rendered string. For other + fonts, the XMIN value described the initial offset of the first character + in the string from adjacent characters. The YMIN value specifies the amount + of vertical space between the lowest pixel in the rendered string and the + baseline of the text; note that this value can be negative, indicating that + the string extends *below* the baseline. The YMIN value is useful, in + particular, if text is to be aligned properly w.r.t. the baseline. */ + + public extern ggi_get_string_bbox VIS S; + public ggi_get_string_size VIS S; + + ggi_get_string_size VIS:GGIVisual S:String + = (XMAX-XMIN,YMAX-YMIN) + where (XMIN,XMAX,YMIN,YMAX) = ggi_get_string_bbox VIS S; /* Get and put operations. The get operations allow you to retrieve a pixel, |
From: <ag...@us...> - 2003-12-20 18:09:42
|
Update of /cvsroot/q-lang/q/modules/ggi/examples In directory sc8-pr-cvs1:/tmp/cvs-serv28388/examples Modified Files: font_test.q Log Message: cosmetic changes in ggi.q comments and font example Index: font_test.q =================================================================== RCS file: /cvsroot/q-lang/q/modules/ggi/examples/font_test.q,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** font_test.q 20 Dec 2003 03:17:06 -0000 1.2 --- font_test.q 20 Dec 2003 18:09:39 -0000 1.3 *************** *** 14,18 **** INDEX = 0, // pt size and display resolution in pixels ! SIZE = 50, RES = 100, // some colors to play with RED = (0xffff,0,0), GREEN = (0,0xffff,0), BLUE = (0,0,0xffff), --- 14,18 ---- INDEX = 0, // pt size and display resolution in pixels ! SIZE = 50, RES = 72, // some colors to play with RED = (0xffff,0,0), GREEN = (0,0xffff,0), BLUE = (0,0,0xffff), |
From: <ag...@us...> - 2003-12-20 18:09:42
|
Update of /cvsroot/q-lang/q/modules/ggi In directory sc8-pr-cvs1:/tmp/cvs-serv28388 Modified Files: ggi.q Log Message: cosmetic changes in ggi.q comments and font example Index: ggi.q =================================================================== RCS file: /cvsroot/q-lang/q/modules/ggi/ggi.q,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** ggi.q 19 Dec 2003 21:31:34 -0000 1.3 --- ggi.q 20 Dec 2003 18:09:39 -0000 1.4 *************** *** 337,347 **** public extern ggi_set_font_metrics VIS NAME; ! /* Set the character size (in pt, can be a floating point value to denote ! fractional sizes) and display resolution (in pixels). Size and resolution ! can be specified either as single values (denoting identical sizes and/or ! resolutions in x and y direction) or as pairs of values (specifying ! different sizes/resolutions for x and y). Moreover, a size value of 0 means ! "same as the other dimension", whereas a resolution value of 0 indicates ! the default value (72 dpi). */ public extern ggi_set_char_size VIS SIZE RES; --- 337,348 ---- public extern ggi_set_font_metrics VIS NAME; ! /* Set the character size SIZE (in pt = 1/72 of an inch, this can be a ! floating point value to denote fractional sizes) and display resolution RES ! (in dpi = dots per inch). The actual size of the characters on the display ! in pixels will be calculated from these values according to the formula ! PIXEL_SIZE = SIZE*RES/72. SIZE and RES can also be specified as pairs of ! values, to indicate different values for the x and y direction. Moreover, a ! SIZE value of 0 means "same as the other dimension", whereas a RES value of ! 0 indicates the default value (72 dpi). */ public extern ggi_set_char_size VIS SIZE RES; *************** *** 353,363 **** public extern ggi_set_antialias VIS FLAG; ! /* Specify an arbitrary affine-linear transformation to be applied before a ! string is rendered on the visual. The font must be scalable for this to ! work. This can be used, e.g., to print rotated or stretched text. The ! transformation is given by a translation vector VECT = (X,Y) and a 2x2 ! matrix MATRIX = (XX,XY,YX,YY). E.g., to rotate text by an angle A ! counter-clockwise, you would use a transform matrix of the form (cos A, ! -sin A, sin A, cos A). */ public extern ggi_set_transform VIS VECT MATRIX; --- 354,363 ---- public extern ggi_set_antialias VIS FLAG; ! /* Specify an arbitrary affine transformation to be applied before a string is ! rendered on the visual. The font must be scalable for this to work. This ! can be used, e.g., to print rotated or stretched text. The transformation ! is given by a translation vector VECT = (X,Y) and a 2x2 matrix MATRIX = ! (XX,XY,YX,YY). E.g., to rotate text by an angle A counter-clockwise, you ! would use a transform matrix of the form (cos A, -sin A, sin A, cos A). */ public extern ggi_set_transform VIS VECT MATRIX; |
From: <ag...@us...> - 2003-12-20 17:34:39
|
Update of /cvsroot/q-lang/q/modules/ggi In directory sc8-pr-cvs1:/tmp/cvs-serv22675 Modified Files: ggi.c Log Message: bug fix in bbox calculation Index: ggi.c =================================================================== RCS file: /cvsroot/q-lang/q/modules/ggi/ggi.c,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** ggi.c 20 Dec 2003 17:25:45 -0000 1.7 --- ggi.c 20 Dec 2003 17:34:36 -0000 1.8 *************** *** 1540,1547 **** error = FT_Get_Glyph(face->glyph, &glyph->image); if (error) continue; - if (!previous) { - pen_x -= face->glyph->metrics.horiBearingX; - glyph->pos.x = pen_x; - } FT_Glyph_Transform(glyph->image, 0, &glyph->pos); pen_x += face->glyph->advance.x; --- 1540,1543 ---- |
From: <ag...@us...> - 2003-12-20 17:25:48
|
Update of /cvsroot/q-lang/q/modules/ggi In directory sc8-pr-cvs1:/tmp/cvs-serv21472 Modified Files: ggi.c Log Message: fixed rendering of mono text, optimizations Index: ggi.c =================================================================== RCS file: /cvsroot/q-lang/q/modules/ggi/ggi.c,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** ggi.c 20 Dec 2003 11:51:56 -0000 1.6 --- ggi.c 20 Dec 2003 17:25:45 -0000 1.7 *************** *** 1409,1439 **** FT_BitmapGlyph bit = (FT_BitmapGlyph)image; FT_Bitmap *bitmap = &bit->bitmap; ! unsigned char *buf = bitmap->buffer; ! int p, q, w = bitmap->width, h = bitmap->rows, ! startx = bit->left - bbox.xMin, starty = bbox.yMax - bit->top, ! actx, acty; ! for (actx = startx, p = 0; p < w; actx++, p++) ! for (acty = starty, q = 0; q < h; acty++, q++) { ! int i = acty*wd+actx; ! int j = q*w+p; ! if (buf[j]) { #if 1 ! /* shades of fg color -- I hope that's the right way to do ! it? */ ! col[i].r = ((long)fgcol.r)*buf[j]/0xff; ! col[i].g = ((long)fgcol.g)*buf[j]/0xff; ! col[i].b = ((long)fgcol.b)*buf[j]/0xff; ! col[i].a = ((long)fgcol.a)*buf[j]/0xff; #else ! /* blend fg with bg color -- this looks odd with some fg/bg ! combinations */ ! col[i].r = (((long)fgcol.r)*buf[j]+ ! ((long)bgcol.r)*(0xff-buf[j]))/0xff; ! col[i].g = (((long)fgcol.g)*buf[j]+ ! ((long)bgcol.g)*(0xff-buf[j]))/0xff; ! col[i].b = (((long)fgcol.b)*buf[j]+ ! ((long)bgcol.b)*(0xff-buf[j]))/0xff; ! col[i].a = (((long)fgcol.a)*buf[j]+ ! ((long)bgcol.a)*(0xff-buf[j]))/0xff; #endif } --- 1409,1439 ---- FT_BitmapGlyph bit = (FT_BitmapGlyph)image; FT_Bitmap *bitmap = &bit->bitmap; ! unsigned char *buf = bitmap->buffer, *bufp; ! int p, q, r, w = bitmap->width, h = bitmap->rows, ! pitch = bitmap->pitch, ! startx = bit->left - bbox.xMin, starty = bbox.yMax - bit->top; ! for (bufp = buf, r = starty*wd+startx, q = 0; q < h; ! bufp += pitch, r += wd, q++) ! for (p = 0; p < w; p++) { ! int i = r+p; ! if (bufp[p]) { #if 1 ! /* for now we just do shades of the foreground color -- is this ! the right way to do it? */ ! col[i].r = ((long)fgcol.r)*bufp[p]/0xff; ! col[i].g = ((long)fgcol.g)*bufp[p]/0xff; ! col[i].b = ((long)fgcol.b)*bufp[p]/0xff; ! col[i].a = ((long)fgcol.a)*bufp[p]/0xff; #else ! /* here's an alternative implementation: blend fg with bg color ! -- but this looks odd with some fg/bg combinations */ ! col[i].r = (((long)fgcol.r)*bufp[p]+ ! ((long)bgcol.r)*(0xff-bufp[p]))/0xff; ! col[i].g = (((long)fgcol.g)*bufp[p]+ ! ((long)bgcol.g)*(0xff-bufp[p]))/0xff; ! col[i].b = (((long)fgcol.b)*bufp[p]+ ! ((long)bgcol.b)*(0xff-bufp[p]))/0xff; ! col[i].a = (((long)fgcol.a)*bufp[p]+ ! ((long)bgcol.a)*(0xff-bufp[p]))/0xff; #endif } *************** *** 1443,1459 **** } } else { ! error = FT_Glyph_To_Bitmap(&image, FT_RENDER_MODE_NORMAL, &pen, 1); if (!error) { FT_BitmapGlyph bit = (FT_BitmapGlyph)image; FT_Bitmap *bitmap = &bit->bitmap; ! unsigned char *buf = bitmap->buffer; ! int p, q, w = bitmap->width, h = bitmap->rows, ! startx = bit->left - bbox.xMin, starty = bbox.yMax - bit->top, ! actx, acty; ! for (actx = startx, p = 0; p < w; actx++, p++) ! for (acty = starty, q = 0; q < h; acty++, q++) { ! int i = acty*wd+actx; ! int j = q*w+p; ! if (buf[j]) col[i] = fgcol; } --- 1443,1460 ---- } } else { ! error = FT_Glyph_To_Bitmap(&image, FT_RENDER_MODE_MONO, &pen, 1); if (!error) { FT_BitmapGlyph bit = (FT_BitmapGlyph)image; FT_Bitmap *bitmap = &bit->bitmap; ! unsigned char *buf = bitmap->buffer, *bufp; ! int p, q, r, w = bitmap->width, h = bitmap->rows, ! pitch = bitmap->pitch, ! startx = bit->left - bbox.xMin, starty = bbox.yMax - bit->top; ! for (bufp = buf, r = starty*wd+startx, q = 0; q < h; ! bufp += pitch, r += wd, q++) ! for (p = 0; p < w; p++) { ! int i = r+p; ! int j = p>>3, k = 7-(p&7); ! if (bufp[j] & (1<<k)) col[i] = fgcol; } |
From: <ag...@us...> - 2003-12-20 11:51:59
|
Update of /cvsroot/q-lang/q/modules/ggi In directory sc8-pr-cvs1:/tmp/cvs-serv3157 Modified Files: ggi.c Log Message: added proper alpha blending to text rendering Index: ggi.c =================================================================== RCS file: /cvsroot/q-lang/q/modules/ggi/ggi.c,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** ggi.c 20 Dec 2003 02:41:44 -0000 1.5 --- ggi.c 20 Dec 2003 11:51:56 -0000 1.6 *************** *** 1308,1311 **** --- 1308,1312 ---- ggi_color fgcol, bgcol, *col = NULL; ggi_pixel pix, *pixel = NULL; + unsigned fgalpha = 0xff, bgalpha = 0xff; if (!glyphs) return (l==0); *************** *** 1377,1391 **** dim = wd*ht; ! /* FIXME: handle alpha blending */ ! ! if (wd > INT_MAX/ht || ! !(col = malloc(dim*sizeof(ggi_color)))) goto errout; if (ggiGetGCForeground(vis, &pix) || ggiUnmapPixel(vis, pix, &fgcol)) goto errout; ! fgcol.a = 0xffff; if (ggiGetGCBackground(vis, &pix) || ggiUnmapPixel(vis, pix, &bgcol)) goto errout; ! bgcol.a = 0xffff; for (n = 0; n < dim; n++) col[n] = bgcol; --- 1378,1398 ---- dim = wd*ht; ! #ifdef HAVE_GGIBUF ! if (v->b[0] && ggiBufGetGCForeground(v->b[0], &fgalpha)) goto errout; + if (v->b[0] && ggiBufGetGCBackground(v->b[0], &bgalpha)) + goto errout; + #endif + fgalpha *= 0x101; + bgalpha *= 0x101; if (ggiGetGCForeground(vis, &pix) || ggiUnmapPixel(vis, pix, &fgcol)) goto errout; ! fgcol.a = fgalpha; if (ggiGetGCBackground(vis, &pix) || ggiUnmapPixel(vis, pix, &bgcol)) goto errout; ! bgcol.a = bgalpha; ! if (wd > INT_MAX/ht || ! !(col = malloc(dim*sizeof(ggi_color)))) ! goto errout; for (n = 0; n < dim; n++) col[n] = bgcol; *************** *** 1411,1414 **** --- 1418,1431 ---- int j = q*w+p; if (buf[j]) { + #if 1 + /* shades of fg color -- I hope that's the right way to do + it? */ + col[i].r = ((long)fgcol.r)*buf[j]/0xff; + col[i].g = ((long)fgcol.g)*buf[j]/0xff; + col[i].b = ((long)fgcol.b)*buf[j]/0xff; + col[i].a = ((long)fgcol.a)*buf[j]/0xff; + #else + /* blend fg with bg color -- this looks odd with some fg/bg + combinations */ col[i].r = (((long)fgcol.r)*buf[j]+ ((long)bgcol.r)*(0xff-buf[j]))/0xff; *************** *** 1419,1423 **** --- 1436,1442 ---- col[i].a = (((long)fgcol.a)*buf[j]+ ((long)bgcol.a)*(0xff-buf[j]))/0xff; + #endif } + } FT_Done_Glyph(image); *************** *** 1444,1453 **** } - /* clean up */ free(glyphs); if (!(pixel = malloc(pack_size(v->vis, dim)))) return 0; ! error = ggiPackColors(v->vis, pixel, col, dim) || ! ggiPutBox(v->vis, x, y, wd, ht, pixel); free(col); free(pixel); --- 1463,1492 ---- } free(glyphs); + /* blit the rendered string to the visual */ + if (!(pixel = malloc(pack_size(v->vis, dim)))) return 0; ! error = ggiPackColors(v->vis, pixel, col, dim); ! if (!error) { ! #ifdef HAVE_GGIBUF ! if (v->b[0]) { ! /* Ouch! Because of the function call overhead this is fairly slow. We'd ! need something like a ggiBufPutBoxWithAlpha operation here, but ! libggibuf doesn't provide it. :( */ ! int i, j; ! ggi_bufval val; ! ggiBufGetGCForeground(v->b[0], &val); ! for (i = 0; i < wd; i++) ! for (j = 0; j < ht; j++) { ! n = j*wd+i; ! ggiBufSetGCForeground(v->b[0], col[n].a/0x101); ! ggiPutPixel(vis, x+i, y+j, pixel[n]); ! } ! ggiBufSetGCForeground(v->b[0], val); ! } else ! #endif ! error = ggiPutBox(v->vis, x, y, wd, ht, pixel); ! } free(col); free(pixel); |
From: <ag...@us...> - 2003-12-20 03:17:15
|
Update of /cvsroot/q-lang/q/modules/ggi/examples In directory sc8-pr-cvs1:/tmp/cvs-serv2798/examples Modified Files: font_test.q Log Message: reworked font example Index: font_test.q =================================================================== RCS file: /cvsroot/q-lang/q/modules/ggi/examples/font_test.q,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** font_test.q 19 Dec 2003 21:37:17 -0000 1.1 --- font_test.q 20 Dec 2003 03:17:06 -0000 1.2 *************** *** 7,16 **** import ggi; ! def FONT = "/usr/X11R6/lib/X11/fonts/truetype/times.ttf", FONT_METRIC = (), ! INDEX = 0, SIZE = 50, RES = 100, RED = (0xffff,0,0), GREEN = (0,0xffff,0), BLUE = (0,0,0xffff), BLACK = (0,0,0), WHITE = (0xffff,0xffff,0xffff); def VIS = ggi_open (), _ = ggi_set_mode VIS "640x480" || ggi_set_foreground VIS WHITE || --- 7,24 ---- import ggi; ! def // name of font file; edit this as needed ! FONT = "/usr/X11R6/lib/X11/fonts/truetype/times.ttf", ! // for some font types you also have to set a font metric file here FONT_METRIC = (), ! // face index (0 will do for most purposes) ! INDEX = 0, ! // pt size and display resolution in pixels ! SIZE = 50, RES = 100, ! // some colors to play with RED = (0xffff,0,0), GREEN = (0,0xffff,0), BLUE = (0,0,0xffff), BLACK = (0,0,0), WHITE = (0xffff,0xffff,0xffff); + // set up the display + def VIS = ggi_open (), _ = ggi_set_mode VIS "640x480" || ggi_set_foreground VIS WHITE || *************** *** 19,27 **** ggi_set_char_size VIS SIZE RES; ! // set the font size size SIZE = ggi_set_char_size VIS SIZE RES; ! // set antialiasing mode antialias FLAG = ggi_set_antialias VIS FLAG; --- 27,44 ---- ggi_set_char_size VIS SIZE RES; ! // set foreground and background color ! ! fg COL = ggi_set_foreground VIS COL; ! bg COL = ggi_set_background VIS COL; ! ! // clear the display ! ! clr = ggi_clear VIS; ! ! // change the font size size SIZE = ggi_set_char_size VIS SIZE RES; ! // change the antialiasing mode antialias FLAG = ggi_set_antialias VIS FLAG; *************** *** 32,39 **** = ggi_set_transform VIS VECT MATRIX; ! // print a sample of the current font ! test P MSG = ggi_puts VIS P MSG || ! // draw bounding box ggi_draw_hline VIS (0,Y) 640 || ggi_draw_hline VIS (0,Y+H-1) 640 || --- 49,56 ---- = ggi_set_transform VIS VECT MATRIX; ! // print text in the current font ! print P MSG = ggi_puts VIS P MSG || ! // indicate bounding box ggi_draw_hline VIS (0,Y) 640 || ggi_draw_hline VIS (0,Y+H-1) 640 || *************** *** 42,51 **** where (X,Y) = P, (W,H) = ggi_get_string_size VIS MSG; ! // set foreground and background color ! fg COL = ggi_set_foreground VIS COL; ! bg COL = ggi_set_background VIS COL; ! // clear the display ! clr = ggi_clear VIS; --- 59,95 ---- where (X,Y) = P, (W,H) = ggi_get_string_size VIS MSG; ! // center text at the given point ! center (X,Y) MSG ! = ggi_puts VIS P MSG || ! ggi_draw_hline VIS (X-10,Y) 20 || ! ggi_draw_vline VIS (X,Y-10) 20 ! where (W,H) = ggi_get_string_size VIS MSG, ! P = (X - W div 2, Y - H div 2); ! // rotate text around the given point ! rotate A (X,Y) MSG ! = transform (0,0) (cos A,-sin A,sin A, cos A) || ! center (X,Y) MSG; ! ! // a little demo: rotate a text around a point until key hit ! ! def PI = 4.0*atan 1.0, P = (320,240), MSG = "Hello, world!"; ! ! demo = // make sure that async mode is set ! ggi_set_flags VIS GGI_FLAG_ASYNC || ! writes "Hit any key in the GGI window to stop\n" || ! loop 0 || ! // reset flag to original state ! ggi_set_flags VIS FLAGS || ! // reset transform to default ! transform (0,0) (1,0,0,1) ! where FLAGS = ggi_get_flags VIS; ! ! loop K = ggi_getc VIS || () if ggi_kbhit VIS; ! = clr || rotate (K*PI/18) P MSG || ggi_flush VIS || ! // 0.02 = 50 fps, change this as necessary ! sleep 0.02 || ! // advance by PI/18 (= 10 degrees) ! loop (K+1 mod 16) otherwise; |
From: <ag...@us...> - 2003-12-20 02:41:48
|
Update of /cvsroot/q-lang/q/modules/ggi In directory sc8-pr-cvs1:/tmp/cvs-serv30674 Modified Files: ggi.c Log Message: bug fixes: memory leaks in set_transform Index: ggi.c =================================================================== RCS file: /cvsroot/q-lang/q/modules/ggi/ggi.c,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** ggi.c 20 Dec 2003 02:30:37 -0000 1.4 --- ggi.c 20 Dec 2003 02:41:44 -0000 1.5 *************** *** 1102,1120 **** (isfloat(xv[2], &yx) || ismpz_float(xv[2], &yx)) && (isfloat(xv[3], &yy) || ismpz_float(xv[3], &yy))) { ! FT_Matrix *matrix = malloc(sizeof(FT_Matrix)); ! FT_Vector *vect = malloc(sizeof(FT_Vector)); ! if (!matrix || !vect) { ! if (matrix) free(matrix); ! if (vect) free(vect); ! return __ERROR; } - vect->x = (FT_Pos)(x*0x40); - vect->y = (FT_Pos)(y*0x40); - matrix->xx = (FT_Fixed)(xx*0x10000L); - matrix->xy = (FT_Fixed)(xy*0x10000L); - matrix->yx = (FT_Fixed)(yx*0x10000L); - matrix->yy = (FT_Fixed)(yy*0x10000L); - v->vect = vect; - v->matrix = matrix; return mkvoid; } else --- 1102,1131 ---- (isfloat(xv[2], &yx) || ismpz_float(xv[2], &yx)) && (isfloat(xv[3], &yy) || ismpz_float(xv[3], &yy))) { ! if (x == 0.0 && y == 0.0 && ! xx == 1.0 && xy == 0.0 && yx == 0.0 && yy == 1.0) { ! /* identity transform: remove any existing transform from the visual */ ! if (v->vect) free(v->vect); ! if (v->matrix) free(v->matrix); ! v->vect = NULL; ! v->matrix = NULL; ! } else { ! FT_Matrix *matrix = malloc(sizeof(FT_Matrix)); ! FT_Vector *vect = malloc(sizeof(FT_Vector)); ! if (!matrix || !vect) { ! if (matrix) free(matrix); ! if (vect) free(vect); ! return __ERROR; ! } ! vect->x = (FT_Pos)(x*0x40); ! vect->y = (FT_Pos)(y*0x40); ! matrix->xx = (FT_Fixed)(xx*0x10000L); ! matrix->xy = (FT_Fixed)(xy*0x10000L); ! matrix->yx = (FT_Fixed)(yx*0x10000L); ! matrix->yy = (FT_Fixed)(yy*0x10000L); ! if (v->vect) free(v->vect); ! if (v->matrix) free(v->matrix); ! v->vect = vect; ! v->matrix = matrix; } return mkvoid; } else |
From: <ag...@us...> - 2003-12-19 21:37:20
|
Update of /cvsroot/q-lang/q/modules/ggi/examples In directory sc8-pr-cvs1:/tmp/cvs-serv11589 Added Files: font_test.q Log Message: Added font test example --- NEW FILE: font_test.q --- /* $Id: font_test.q,v 1.1 2003/12/19 21:37:17 agraef Exp $ */ /* font_test.q: Little test script showing how to render text using Q-GGI's font interface. NOTE: This requires FreeType2 to work. */ import ggi; def FONT = "/usr/X11R6/lib/X11/fonts/truetype/times.ttf", FONT_METRIC = (), INDEX = 0, SIZE = 50, RES = 100, RED = (0xffff,0,0), GREEN = (0,0xffff,0), BLUE = (0,0,0xffff), BLACK = (0,0,0), WHITE = (0xffff,0xffff,0xffff); def VIS = ggi_open (), _ = ggi_set_mode VIS "640x480" || ggi_set_foreground VIS WHITE || ggi_set_font VIS FONT INDEX || ggi_set_font_metric VIS FONT_METRIC || ggi_set_char_size VIS SIZE RES; // set the font size size SIZE = ggi_set_char_size VIS SIZE RES; // set antialiasing mode antialias FLAG = ggi_set_antialias VIS FLAG; // set transform vector and matrix transform VECT MATRIX = ggi_set_transform VIS VECT MATRIX; // print a sample of the current font test P MSG = ggi_puts VIS P MSG || // draw bounding box ggi_draw_hline VIS (0,Y) 640 || ggi_draw_hline VIS (0,Y+H-1) 640 || ggi_draw_vline VIS (X,0) 480 || ggi_draw_vline VIS (X+W-1,0) 480 where (X,Y) = P, (W,H) = ggi_get_string_size VIS MSG; // set foreground and background color fg COL = ggi_set_foreground VIS COL; bg COL = ggi_set_background VIS COL; // clear the display clr = ggi_clear VIS; |
From: <ag...@us...> - 2003-12-19 21:31:37
|
Update of /cvsroot/q-lang/q In directory sc8-pr-cvs1:/tmp/cvs-serv9986 Modified Files: ChangeLog config.h.in configure.in Log Message: Added FreeType2 support Index: ChangeLog =================================================================== RCS file: /cvsroot/q-lang/q/ChangeLog,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** ChangeLog 16 Dec 2003 19:11:16 -0000 1.4 --- ChangeLog 19 Dec 2003 21:31:34 -0000 1.5 *************** *** 1,2 **** --- 1,14 ---- + 2003-12-19 Albert Graef <Dr....@t-...> + + * README-GGI: add information about FreeType support + + * ggi.q, ggi.c: replaced ggi_get_char_size with the more general + ggi_get_string_size function which calculates the dimensions of + the bounding box of a rendered string + + * ggi.q, ggi.c, configury: added FreeType2 support (TODO: add + support for linear transformations and alpha blending in the text + rendering algorithm) + 2003-12-16 Albert Graef <Dr....@t-...> Index: config.h.in =================================================================== RCS file: /cvsroot/q-lang/q/config.h.in,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** config.h.in 15 Dec 2003 12:07:13 -0000 1.2 --- config.h.in 19 Dec 2003 21:31:34 -0000 1.3 *************** *** 117,120 **** --- 117,123 ---- #undef HAVE_FTRUNCATE + /* Define if you have the `FT_Init_FreeType' function. */ + #undef HAVE_FT_INIT_FREETYPE + /* Define if you have the `getegid' function. */ #undef HAVE_GETEGID Index: configure.in =================================================================== RCS file: /cvsroot/q-lang/q/configure.in,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** configure.in 16 Dec 2003 19:11:16 -0000 1.3 --- configure.in 19 Dec 2003 21:31:34 -0000 1.4 *************** *** 235,239 **** GGI_LIBBUF="yes" AC_ARG_WITH(ggibuf, ! [ --with-ggibuf[[=LIBS]] use GGI libbuf (alpha/z buffer support)], [case "${withval}" in no) GGI_LIBBUF="" ;; --- 235,239 ---- GGI_LIBBUF="yes" AC_ARG_WITH(ggibuf, ! [ --with-ggibuf[[=LIBS]] use the GGI buffer extension (alpha/z buffer support)], [case "${withval}" in no) GGI_LIBBUF="" ;; *************** *** 247,251 **** AC_CHECK_LIB(ggibuf, ggiBufInit, [ GGI_LIBBUF="-lggibuf -lggigalloc" ]) if test "${GGI_LIBBUF}" = ""; then ! AC_MSG_WARN([could not find the GGI buffer library, building without buffer support]) else AC_MSG_RESULT([defining GGI_LIBBUF to be ${GGI_LIBBUF}]) --- 247,251 ---- AC_CHECK_LIB(ggibuf, ggiBufInit, [ GGI_LIBBUF="-lggibuf -lggigalloc" ]) if test "${GGI_LIBBUF}" = ""; then ! AC_MSG_WARN([could not find the GGI buffer extension, building without buffer support]) else AC_MSG_RESULT([defining GGI_LIBBUF to be ${GGI_LIBBUF}]) *************** *** 264,267 **** --- 264,302 ---- AC_SUBST(GGI_INCLUDES) + # FreeType2 + + FT2_LIBS="yes" + AC_ARG_WITH(ft2, + [ --with-ft2[[=LIBS]] use the FreeType2 library (font support for ggi)], + [case "${withval}" in + no) FT2_LIBS="" ;; + *) FT2_LIBS="${withval}" ;; + esac]) + ftconf=`which freetype-config 2>/dev/null` + if test "${FT2_LIBS}" = "yes"; then + FT2_LIBS="" + if test -x "$ftconf"; then + FT2_LIBS=`$ftconf --libs` + AC_MSG_RESULT([defining FT2_LIBS to be ${FT2_LIBS}]) + else + AC_MSG_WARN([could not find the FreeType2 library, building without font support]) + fi + fi + AC_SUBST(FT2_LIBS) + + if test -x "$ftconf"; then + FT2_INCLUDES=`$ftconf --cflags` + else + FT2_INCLUDES="" + fi + AC_ARG_WITH(ft2-includes, + [ --with-ft2-includes=INC extra includes for the FreeType2 library], + [case "${withval}" in + yes) ;; + no) FT2_INCLUDES="" ;; + *) FT2_INCLUDES="${withval}" ;; + esac]) + AC_SUBST(FT2_INCLUDES) + # ImageMagick *************** *** 554,557 **** --- 589,596 ---- AC_CHECK_FUNCS(ggiBufInit) LIBS=$OLDLIBS + dnl freetype2 support + LIBS="$LIBS ${FT2_LIBS}" + AC_CHECK_FUNCS(FT_Init_FreeType) + LIBS=$OLDLIBS dnl Configure readline support. *************** *** 666,669 **** --- 705,714 ---- else AC_MSG_RESULT([ GGI: disabled]) + fi + if test "${FT2_LIBS}" != ""; then + AC_MSG_RESULT([ FreeType2: libraries: ${FT2_LIBS}]) + AC_MSG_RESULT([ includes : ${FT2_INCLUDES}]) + else + AC_MSG_RESULT([ FreeType2: disabled]) fi if test "${MAGICK_LIBS}" != ""; then |
From: <ag...@us...> - 2003-12-16 19:11:20
|
Update of /cvsroot/q-lang/q/modules/magick In directory sc8-pr-cvs1:/tmp/cvs-serv655/modules/magick Added Files: Makefile.am Makefile.mingw README-Magick magick.c magick.q Log Message: Added magick module --- NEW FILE: Makefile.am --- ## Process this file with automake to generate a GNU Makefile ## only built if requested SUBDIRS = . examples INCLUDES = -I$(top_srcdir)/libq @MAGICK_INCLUDES@ @INCDMALLOC@ if MAGICK pkglib_LTLIBRARIES = magick.la endif magick_la_SOURCES = magick.c magick_la_LDFLAGS = -no-undefined -module -avoid-version magick_la_LIBADD = -L$(top_builddir)/libq -lq @LIBGMP@ @MAGICK_LIBS@ @LIBDMALLOCTH@ stdlibdir = $(pkgdatadir)/lib if MAGICK stdlib_DATA = magick.q endif etcdir = $(pkgdatadir)/etc if MAGICK etc_DATA = README-Magick endif EXTRA_DIST = magick.q README-Magick Makefile.mingw --- NEW FILE: Makefile.mingw --- # $Id: Makefile.mingw,v 1.1 2003/12/16 19:11:16 agraef Exp $ # this still needs testing QCC = ../../src/qcc QCCFLAGS = CFLAGS = -O3 SHLEXT = .dll DEFS = -DSTDC_HEADERS=1 -DHAVE_STRDUP=1 -DHAVE_MEMCPY=1 -DHAVE_LIMITS_H=1 .PHONY: all clean mostlyclean distclean maintainer-clean all: magick$(SHLEXT) magick$(SHLEXT): magick.c qcc -o magick$(SHLEXT) magick.c -- $(DEFS) -I. -I../../libq -I../../../magick/include -I../../../gmp --link -L. -L../../../magick/lib -lMagick -L../../../gmp -lgmp -L../../libq clean mostlyclean distclean maintainer-clean:: rm -f *.o *$(SHLEXT) *.a *.def *% *~ *.bak q.out .q_vars core distclean maintainer-clean:: rm -f TAGS Makefile config.h config.status config.cache config.log --- NEW FILE: README-Magick --- Q-Magick - ImageMagick interface for the Q programming language ======== = =========== ========= === === = =========== ======== This module implements a simple interface to the ImageMagick C API (libMagick), a comprehensive library for image manipulation, see http://www.imagemagick.org/. With this module, you can create, load, save and manipulate images stored in a plethora of different file formats. Operations to retrieve and modify the pixel data of an image are also provided. Since the external pixel representation is compatible with that of the Q-GGI module, you can easily exchange pixel data between images and GGI visuals as well. Please note that this is still work in progress. The basic operations to create, load and save images, and to retrieve and change image pixels are already in place. Things that still remain to be done are additional options for write_image (compression etc.), operations to convert between images and "blobs" (for external storage, e.g., in databases), operations to handle image lists (i.e., animations), and, last but not least, support for the advanced image manipulation operations provided by libMagick. The module requires that you have ImageMagick installed, which should be readily available in most Linux distributions. The Windows Qpad package already includes all necessary support files. Currently a fairly recent ImageMagick version (>= 5.5) is required, but support for older versions will be added in the near future. Please see magick.q for a description of the functions provided by this module. For more in-depth information about ImageMagick please refer to the corresponding manual pages. A few sample scripts are also provided; you can find these, once installed, in the <q-prefix>/share/q/examples/magick directory. Enjoy! :) Dec 16 2003 Albert Graef ag...@mu..., Dr....@t-... http://www.musikwissenschaft.uni-mainz.de/~ag --- NEW FILE: magick.c --- /* $Id: magick.c,v 1.1 2003/12/16 19:11:16 agraef Exp $ */ /* TODO: make this work with older libMagick versions which don't provide the ScaleQuantumToXYZ routines. */ /* This file is part of the Q programming system. The Q programming system is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2, or (at your option) any later version. The Q programming system is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #if defined (HAVE_CONFIG_H) # include "config.h" #endif #ifdef _WIN32 #define STDC_HEADERS 1 #define HAVE_STRDUP 1 #define HAVE_MEMCPY 1 #define HAVE_LIMITS_H 1 #include <windows.h> #endif /* system headers */ #include <stdio.h> #include <ctype.h> #include <math.h> /* check for standard C headers */ #if STDC_HEADERS # include <stdlib.h> # include <string.h> #else # ifndef HAVE_STRCHR # define strchr index # define strrchr rindex # endif char *strchr (), *strrchr (); #endif #ifdef HAVE_MALLOC_H #include <malloc.h> #endif #ifdef HAVE_LIMITS_H #include <limits.h> #endif #ifdef HAVE_UNISTD_H #include <unistd.h> #endif #ifdef DMALLOC #include <dmalloc.h> #endif #include <gmp.h> #include <libq.h> #include <magick/api.h> MODULE(magick) static ExceptionInfo exception; static char msg[1024]; static inline int check_exception(ExceptionInfo *exception) { int res = exception->severity != UndefinedException; if (res) sprintf(msg, "%d: %s%s%s%s", exception->severity, exception->reason?exception->reason:"ERROR", exception->description?" (":"", exception->description?exception->description:"", exception->description?")":""); else *msg = 0; SetExceptionInfo(exception, UndefinedException); return res; } INIT(magick) { InitializeMagick("magick"); GetExceptionInfo(&exception); } FINI(magick) { DestroyMagick(); } #define my_mpz_fits_slong_p(z) (mpz_size(z) == 0 || mpz_fits_slong_p(z)) #define my_mpz_fits_ulong_p(z) (mpz_size(z) == 0 || mpz_fits_ulong_p(z)) #define my_mpz_fits_uint_p(z) (mpz_size(z) == 0 || mpz_fits_uint_p(z)) static expr mkuint(unsigned long u) { mpz_t z; mpz_init(z); if (z->_mp_d) { mpz_set_ui(z, u); return mkmpz(z); } else return NULL; } static int isuint(expr x, unsigned long *u) { mpz_t z; if (ismpz(x, z) && mpz_sgn(z) >= 0 && my_mpz_fits_ulong_p(z)) { *u = mpz_get_ui(z); return 1; } else return 0; } /* ByteStr data structure, see clib.c */ typedef struct bstr { long size; unsigned char *v; } bstr_t; #if 0 /* manifest constants */ /* These aren't needed any more. We still leave it in here to have some boilerplate code when we have to add some manifest constants in the future. */ FUNCTION(magick,magick_vars,argc,argv) { if (argc != 0) return __FAIL; return mktuplel (16, mkuint(UndefinedColorspace), mkuint(RGBColorspace), mkuint(GRAYColorspace), mkuint(TransparentColorspace), mkuint(OHTAColorspace), mkuint(XYZColorspace), mkuint(YCbCrColorspace), mkuint(YCCColorspace), mkuint(YIQColorspace), mkuint(YPbPrColorspace), mkuint(YUVColorspace), mkuint(CMYKColorspace), mkuint(sRGBColorspace), mkuint(UndefinedClass), mkuint(DirectClass), mkuint(PseudoClass)); } #endif /* image type */ DESTRUCTOR(magick,Image,ptr) { Image *img = (Image*)ptr; DestroyImage(img); } /* Read RGBA pixels from a buffer. The color values are scaled to 16 bit and returned in RGBA order which matches the layout of GGI color values. */ static void get_pixels(unsigned char *dest, PixelPacket *source, unsigned long count) { unsigned long i; register PixelPacket *p; register unsigned short *q; p = source; q = (unsigned short*)dest; for (i = 0; i < count; i++) { *q++=ScaleQuantumToShort(p->red); *q++=ScaleQuantumToShort(p->green); *q++=ScaleQuantumToShort(p->blue); *q++=ScaleQuantumToShort(MaxRGB-p->opacity); p++; } } /* Write RGBA pixels to a buffer. */ static void set_pixels(PixelPacket *dest, unsigned char *source, unsigned long count) { unsigned long i; register unsigned short *p; register PixelPacket *q; p = (unsigned short*)source; q = dest; for (i = 0; i < count; i++) { q->red=ScaleShortToQuantum(*p++); q->green=ScaleShortToQuantum(*p++); q->blue=ScaleShortToQuantum(*p++); q->opacity=ScaleShortToQuantum(0xffff-*p++); q++; } } /* Read/write alpha channel only. */ static void get_alpha(unsigned short *dest, PixelPacket *source, unsigned long count) { unsigned long i; register PixelPacket *p; register unsigned short *q; p = source; q = dest; for (i = 0; i < count; i++) { *q++=ScaleQuantumToShort(MaxRGB-p->opacity); p++; } } static void set_alpha(PixelPacket *dest, unsigned short *source, unsigned long count) { unsigned long i; register unsigned short *p; register PixelPacket *q; p = source; q = dest; for (i = 0; i < count; i++) { q->opacity=ScaleShortToQuantum(0xffff-*p++); q++; } } /* parse info tuples */ static int parse_info(int n, expr *xv, ImageInfo *info) { int i = 0; unsigned long width, height, depth; static char geom[100]; if (i >= n) return 1; if (!isuint(xv[i++], &width)) return 0; if (i >= n) return 1; if (!isuint(xv[i++], &height)) height = 0; if (width > 0 && height > 0) { sprintf(geom, "%ux%u", width, height); info->size = geom; } if (i >= n) return 1; if (!isuint(xv[i++], &depth) || depth > QuantumDepth) return 0; if (depth > 0) info->depth = depth; return 1; } static int parse_info2(int n, expr *xv, Image *img) { int i = 3; if (i >= n) return 1; if (!istrue(xv[i]) && !isfalse(xv[i])) return 0; img->matte = istrue(xv[i++])!=0; if (i >= n) return 1; return 0; } FUNCTION(magick,magick_pixel,argc,argv) { char *s; expr *xv, x, hd, tl; int n; unsigned long r, g, b, a = 0xffff; PixelPacket pixel; bstr_t *m; char *v; if (argc != 1) return __FAIL; /* treat the case of a single color value: */ if (isstr(argv[0], &s)) { if (!QueryColorDatabase(s, &pixel, &exception)) if (check_exception(&exception)) return mkapp(mksym(sym(magick_error)), mkstr(strdup(msg))); else return __FAIL; } else if (istuple(argv[0], &n, &xv) && n >= 3 && n <= 4 && isuint(xv[0], &r) && isuint(xv[1], &g) && isuint(xv[2], &b) && (n == 3 || isuint(xv[3], &a)) && r <= 0xffff && g <= 0xffff && b <= 0xffff && a <= 0xffff) { pixel.red = ScaleShortToQuantum(r); pixel.green = ScaleShortToQuantum(g); pixel.blue = ScaleShortToQuantum(b); pixel.opacity = ScaleShortToQuantum(0xffff-a); } else goto skip; if (!(m = malloc(sizeof(bstr_t))) || !(m->v = malloc(8))) { if (m) free(m); return __ERROR; } m->size = 8; get_pixels(m->v, &pixel, 1); return mkobj(type(ByteStr), m); skip: /* if we come here, we should deal with a list of color values */ for (n = 0, x = argv[0]; iscons(x, &hd, &tl); x = tl) n++; if (!isnil(x)) return __FAIL; if (n == 0) { if (!(m = malloc(sizeof(bstr_t)))) return __ERROR; m->size = 0; m->v = NULL; return mkobj(type(ByteStr), m); } if (n < 0 || ULONG_MAX/8 < n) return __ERROR; if (!(m = malloc(sizeof(bstr_t))) || !(m->v = malloc(n*8))) { if (m) free(m); return __ERROR; } m->size = n*8; for (v = m->v, x = argv[0]; iscons(x, &hd, &tl); x = tl, v += 8) { if (isstr(hd, &s)) { if (!QueryColorDatabase(s, &pixel, &exception)) if (check_exception(&exception)) return mkapp(mksym(sym(magick_error)), mkstr(strdup(msg))); else { free(m->v); free(m); return __FAIL; } } else if (istuple(hd, &n, &xv) && n >= 3 && n <= 4 && isuint(xv[0], &r) && isuint(xv[1], &g) && isuint(xv[2], &b) && (n == 3 || isuint(xv[3], &a)) && r <= 0xffff && g <= 0xffff && b <= 0xffff && a <= 0xffff) { pixel.red = ScaleShortToQuantum(r); pixel.green = ScaleShortToQuantum(g); pixel.blue = ScaleShortToQuantum(b); pixel.opacity = ScaleShortToQuantum(0xffff-a); } else { free(m->v); free(m); return __FAIL; } get_pixels(v, &pixel, 1); } return mkobj(type(ByteStr), m); } FUNCTION(magick,magick_alpha,argc,argv) { expr *xv, x, hd, tl; int n; unsigned long a; PixelPacket pixel; bstr_t *m; unsigned short *v; if (argc != 1) return __FAIL; pixel.red = pixel.green = pixel.blue = 0; /* treat the case of a single alpha value: */ if (isuint(argv[0], &a) && a <= 0xffff) pixel.opacity = ScaleShortToQuantum(0xffff-a); else goto skip; if (!(m = malloc(sizeof(bstr_t))) || !(m->v = malloc(2))) { if (m) free(m); return __ERROR; } m->size = 2; get_alpha((unsigned short*)m->v, &pixel, 1); return mkobj(type(ByteStr), m); skip: /* if we come here, we should deal with a list of alpha values */ for (n = 0, x = argv[0]; iscons(x, &hd, &tl); x = tl) n++; if (!isnil(x)) return __FAIL; if (n == 0) { if (!(m = malloc(sizeof(bstr_t)))) return __ERROR; m->size = 0; m->v = NULL; return mkobj(type(ByteStr), m); } if (n < 0 || n > INT_MAX/2) return __ERROR; if (!(m = malloc(sizeof(bstr_t))) || !(m->v = malloc(n*2))) { if (m) free(m); return __ERROR; } m->size = n*2; for (v = (unsigned short*)m->v, x = argv[0]; iscons(x, &hd, &tl); x = tl, v++) { if (isuint(hd, &a) && a <= 0xffff) pixel.opacity = ScaleShortToQuantum(0xffff-a); else { free(m->v); free(m); return __FAIL; } get_alpha(v, &pixel, 1); } return mkobj(type(ByteStr), m); } FUNCTION(magick,create_image,argc,argv) { expr *xv; int n = 0; if (argc == 1 && (istuple(argv[0], &n, &xv) || isvoid(argv[0])) && n <= 7) { ImageInfo *info = CloneImageInfo(NULL); Image *img; if (!info) return __ERROR; if (!parse_info(n, xv, info)) { DestroyImageInfo(info); return __FAIL; } img = AllocateImage(info); DestroyImageInfo(info); if (img && !parse_info2(n, xv, img)) { DestroyImage(img); return __FAIL; } if (!img) return __ERROR; else return mkobj(type(Image), img); } else return __FAIL; } FUNCTION(magick,clone_image,argc,argv) { Image *img; if (argc == 1 && isobj(argv[0], type(Image), (void**)&img)) { img = CloneImage(img, 0, 0, 1, &exception); if (check_exception(&exception)) return mkapp(mksym(sym(magick_error)), mkstr(strdup(msg))); else if (!img) return __ERROR; else return mkobj(type(Image), img); } else return __FAIL; } FUNCTION(magick,read_image,argc,argv) { char *s; expr *xv; int n = 0; if (argc == 2 && isstr(argv[0], &s) && (istuple(argv[1], &n, &xv) || isvoid(argv[1])) && n <= 7) { ImageInfo *info = CloneImageInfo(NULL); Image *img; if (!info) return __ERROR; if (!parse_info(n, xv, info)) { DestroyImageInfo(info); return __FAIL; } strncpy(info->filename, s, MaxTextExtent-1); img = ReadImage(info, &exception); DestroyImageInfo(info); if (check_exception(&exception)) return mkapp(mksym(sym(magick_error)), mkstr(strdup(msg))); if (img && !parse_info2(n, xv, img)) { DestroyImage(img); return __FAIL; } if (!img) return __FAIL; else return mkobj(type(Image), img); } else return __FAIL; } FUNCTION(magick,write_image,argc,argv) { char *s; Image *img; if (argc == 2 && isstr(argv[0], &s) && isobj(argv[1], type(Image), (void**)&img) && img->columns > 0 && img->rows > 0) { ImageInfo *info = CloneImageInfo(NULL); int res; if (!info) return __ERROR; strncpy(img->filename, s, MaxTextExtent-1); res = WriteImage(info, img); DestroyImageInfo(info); if (check_exception(&img->exception)) return mkapp(mksym(sym(magick_error)), mkstr(strdup(msg))); else if (!res) return __FAIL; else return mkvoid; } else return __FAIL; } FUNCTION(magick,image_info,argc,argv) { Image *img; if (argc == 1 && isobj(argv[0], type(Image), (void**)&img)) return mktuplel(4, mkuint(img->columns), mkuint(img->rows), mkuint(img->depth), img->matte?mktrue:mkfalse); else return __FAIL; } FUNCTION(magick,count_image_colors,argc,argv) { Image *img; if (argc == 1 && isobj(argv[0], type(Image), (void**)&img)) { unsigned long colors = GetNumberColors(img, NULL, &exception); if (check_exception(&exception)) return mkapp(mksym(sym(magick_error)), mkstr(strdup(msg))); else return mkuint(colors); } else return __FAIL; } FUNCTION(magick,is_gray_image,argc,argv) { Image *img; if (argc == 1 && isobj(argv[0], type(Image), (void**)&img)) { unsigned res = IsGrayImage(img, &exception); if (check_exception(&exception)) return mkapp(mksym(sym(magick_error)), mkstr(strdup(msg))); else return res?mktrue:mkfalse; } else return __FAIL; } FUNCTION(magick,is_monochrome_image,argc,argv) { Image *img; if (argc == 1 && isobj(argv[0], type(Image), (void**)&img)) { unsigned res = IsMonochromeImage(img, &exception); if (check_exception(&exception)) return mkapp(mksym(sym(magick_error)), mkstr(strdup(msg))); else return res?mktrue:mkfalse; } else return __FAIL; } FUNCTION(magick,is_opaque_image,argc,argv) { Image *img; if (argc == 1 && isobj(argv[0], type(Image), (void**)&img)) { unsigned res = IsOpaqueImage(img, &exception); if (check_exception(&exception)) return mkapp(mksym(sym(magick_error)), mkstr(strdup(msg))); else return res?mktrue:mkfalse; } else return __FAIL; } FUNCTION(magick,is_palette_image,argc,argv) { Image *img; if (argc == 1 && isobj(argv[0], type(Image), (void**)&img)) { unsigned res = IsPaletteImage(img, &exception); if (check_exception(&exception)) return mkapp(mksym(sym(magick_error)), mkstr(strdup(msg))); else return res?mktrue:mkfalse; } else return __FAIL; } FUNCTION(magick,get_image_pixels,argc,argv) { Image *img; expr *xv; int n; long x, y; unsigned long w, h; PixelPacket *pixels; if (argc == 3 && isobj(argv[0], type(Image), (void**)&img) && istuple(argv[1], &n, &xv) && n == 2 && isint(xv[0], &x) && isint(xv[1], &y) && istuple(argv[2], &n, &xv) && n == 2 && isuint(xv[0], &w) && isint(xv[1], &h) && (pixels = GetImagePixels(img, x, y, w, h))) { unsigned long size = w*h*8; bstr_t *m; if (ULONG_MAX/8 < w*h) return __ERROR; if (size == 0) { m->size = 0; m->v = NULL; return mkobj(type(ByteStr), m); } if (!(m = malloc(sizeof(bstr_t))) || !(m->v = malloc(size))) { if (m) free(m); return __ERROR; } m->size = size; get_pixels(m->v, pixels, w*h); return mkobj(type(ByteStr), m); } else return __FAIL; } FUNCTION(magick,set_image_pixels,argc,argv) { Image *img; expr *xv; int n; long x, y; unsigned long w, h; bstr_t *m; PixelPacket *pixels; if (argc == 4 && isobj(argv[0], type(Image), (void**)&img) && istuple(argv[1], &n, &xv) && n == 2 && isint(xv[0], &x) && isint(xv[1], &y) && istuple(argv[2], &n, &xv) && n == 2 && isuint(xv[0], &w) && isint(xv[1], &h) && isobj(argv[3], type(ByteStr), (void**)&m)) { unsigned long size = w*h*8; if (ULONG_MAX/8 < w*h || size != m->size) return __FAIL; else if (size == 0) return mkvoid; if (!(pixels = SetImagePixels(img, x, y, w, h))) return __FAIL; set_pixels(pixels, m->v, w*h); img->storage_class = DirectClass; if (SyncImagePixels(img)) return mkvoid; else return __FAIL; } else return __FAIL; } FUNCTION(magick,get_image_alpha,argc,argv) { Image *img; expr *xv; int n; long x, y; unsigned long w, h; PixelPacket *pixels; if (argc == 3 && isobj(argv[0], type(Image), (void**)&img) && istuple(argv[1], &n, &xv) && n == 2 && isint(xv[0], &x) && isint(xv[1], &y) && istuple(argv[2], &n, &xv) && n == 2 && isuint(xv[0], &w) && isint(xv[1], &h) && (pixels = GetImagePixels(img, x, y, w, h))) { unsigned long size = w*h; bstr_t *m; if (ULONG_MAX/2 < w*h) return __ERROR; if (size == 0) { m->size = 0; m->v = NULL; return mkobj(type(ByteStr), m); } if (!(m = malloc(sizeof(bstr_t))) || !(m->v = malloc(size*2))) { if (m) free(m); return __ERROR; } m->size = size*2; get_alpha((unsigned short*)m->v, pixels, w*h); return mkobj(type(ByteStr), m); } else return __FAIL; } FUNCTION(magick,set_image_alpha,argc,argv) { Image *img; expr *xv; int n; long x, y; unsigned long w, h; bstr_t *m; PixelPacket *pixels; if (argc == 4 && isobj(argv[0], type(Image), (void**)&img) && istuple(argv[1], &n, &xv) && n == 2 && isint(xv[0], &x) && isint(xv[1], &y) && istuple(argv[2], &n, &xv) && n == 2 && isuint(xv[0], &w) && isint(xv[1], &h) && isobj(argv[3], type(ByteStr), (void**)&m) && m->size%2 == 0) { unsigned long size = w*h; if (ULONG_MAX/2 < w*h || 2*size != m->size) return __FAIL; else if (size == 0) return mkvoid; if (!(pixels = SetImagePixels(img, x, y, w, h))) return __FAIL; set_alpha(pixels, (unsigned short*)m->v, w*h); img->storage_class = DirectClass; if (SyncImagePixels(img)) return mkvoid; else return __FAIL; } else return __FAIL; } --- NEW FILE: magick.q --- /* magick.q: poor man's ImageMagick interface $Id: magick.q,v 1.1 2003/12/16 19:11:16 agraef Exp $ */ /* This file is part of the Q programming system. The Q programming system is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2, or (at your option) any later version. The Q programming system is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ /* This module implements a simple interface to the ImageMagick C API (libMagick), a comprehensive library for image manipulation, see http://www.imagemagick.org/. Please note that this is still work in progress. The basic operations to create, load and save images, and to retrieve and change image pixels are already in place. TODO: additional options for write_image (compression etc.); blob conversion; image list handling (animations); image manipulation operations. */ import clib; /* The Image type. Objects of this type are created with the create_image and read_image operations, and processed by the other operations of this module. */ public extern type Image; public is_image X; is_image IMG:Image = true; is_image _ = false otherwise; /* Error handling. In case of failure, some operations use the following magick_error symbol to return a diagnostic message. You can define this symbol to perform error handling as appropriate for the application. */ public magick_error MSG; /* ENCODING OF COLOR VALUES. Regardless of the internal representation of an image, pixel data is always encoded as a byte string of 16 bit RGBA values. A value of 0 in the RGB components denotes minimum, 0xffff maximum intensity. Similarly, an alpha value of 0 denotes a fully transparent, 0xffff a fully opaque pixel. Note that this format matches the layout of GGI pixel values, which makes it easy to transfer pixel data between images and GGI visuals. */ /* The magick_pixel function returns the normalized RGBA color value, as a byte string, for a given color specification, which may be either a color name in the ImageMagick color database or an (R,G,B,A) tuple with values in the range 0..0xffff; the alpha value is optional and is assumed to be 0xffff if it is missing. The function also packs a list of such values into a single byte string. The result of magick_pixel is suitable to be used as the DATA argument in a call to set_image_pixels (see below). */ public extern magick_pixel COLOR; /* The magick_alpha function packs a single alpha value in the range 0..0xffff or a list of such values into a byte string, suitable as the DATA argument of set_image_alpha (see below). */ public extern magick_alpha ALPHA; /* Operations to create, read and write an image. The create_image function creates a new image, given an INFO tuple of the form (WIDTH, HEIGHT, DEPTH, MATTE), where (WIDTH, HEIGHT) denotes the dimensions of the image, DEPTH is the bit depth of the color values (usually 8 or 16), and MATTE is a Bool value indicating whether the image has an alpha channel. All fields of the INFO tuple are optional; suitable defaults will be provided for fields which are omitted. The clone_image function creates an exact copy of the given image. The read_image function reads an image from the given source, which may also include a format prefix (such as "rgb:file.rgb") or indicate a special builtin image object (such as "logo:" or "xc:white"); see ImageMagick(1) for details. Additional image properties may optionally be specified in the INFO argument, which has the same form as for create_image. (Note that for raw image data you will have to specify at least the image type in the filename -- e.g., "rgb:file.rgb" for raw RGB data -- and the dimensions of the image in the INFO tuple.) The write_image function writes the given image to the given target, designated by a name in the same syntax as for read_image. */ public extern create_image INFO, clone_image IMG; public extern read_image NAME INFO, write_image NAME IMG; /* Retrieve the attributes of an image. The image_info function returns the attributes of an image encoded as an INFO tuple of the form (WIDTH, HEIGHT, DEPTH, MATTE). */ public extern image_info IMG; /* Convenience functions to retrieve the different components of an image info structure. */ public image_width IMG, image_height IMG, image_depth IMG, image_matte IMG; image_width IMG = W where (W,H,D,M) = image_info IMG; image_height IMG = H where (W,H,D,M) = image_info IMG; image_depth IMG = D where (W,H,D,M) = image_info IMG; image_matte IMG = M where (W,H,D,M) = image_info IMG; /* Retrieve various other useful information about an image. The count_image_ colors function determines the number of unique colors in an image. The remaining functions check whether the image belongs to one of the following image classes: gray (all RGB intensities equal), monochrome (all RGB intensities equal *and* each RGB value is either zero or max), opaque (all alpha values max), and palette (pseudo class image with at most 256 unique colors). */ public extern count_image_colors IMG; public extern is_gray_image IMG, is_monochrome_image IMG, is_opaque_image IMG, is_palette_image IMG; /* Get and set the pixel data of an image. The affected area of the image is specified by its origin P = (X,Y) and dimension DIM = (W,H). All pixel data is encoded as a byte string of 16 bit RGBA values, as discussed above. */ public extern get_image_pixels IMG P DIM; public extern set_image_pixels IMG P DIM DATA; /* Get and set the alpha channel of an image. The data is encoded as a byte string of 16 bit alpha values. These functions can be used to transfer the alpha plane of an image to the alpha buffer of a GGI visual and vice versa. */ public extern get_image_alpha IMG P DIM; public extern set_image_alpha IMG P DIM DATA; |
From: <ag...@us...> - 2003-12-16 19:11:20
|
Update of /cvsroot/q-lang/q/src In directory sc8-pr-cvs1:/tmp/cvs-serv655/src Modified Files: Makefile.am Log Message: Added magick module Index: Makefile.am =================================================================== RCS file: /cvsroot/q-lang/q/src/Makefile.am,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -C2 -d -r1.1.1.1 -r1.2 *** Makefile.am 15 Dec 2003 10:15:21 -0000 1.1.1.1 --- Makefile.am 16 Dec 2003 19:11:16 -0000 1.2 *************** *** 20,24 **** # preloaded modules ! MODULES = -dlpreopen force -dlopen $(top_srcdir)/modules/clib/clib.la @DXL_MODULE@ @GDBM_MODULE@ @GGI_MODULE@ @ODBC_MODULE@ -dlopen $(top_srcdir)/modules/octave/octave.la @TK_MODULE@ @MODULES@ AM_YFLAGS = -d --- 20,24 ---- # preloaded modules ! MODULES = -dlpreopen force -dlopen $(top_srcdir)/modules/clib/clib.la @DXL_MODULE@ @GDBM_MODULE@ @GGI_MODULE@ @MAGICK_MODULE@ @ODBC_MODULE@ -dlopen $(top_srcdir)/modules/octave/octave.la @TK_MODULE@ @MODULES@ AM_YFLAGS = -d |
From: <ag...@us...> - 2003-12-16 19:11:19
|
Update of /cvsroot/q-lang/q/modules/magick/examples In directory sc8-pr-cvs1:/tmp/cvs-serv655/modules/magick/examples Added Files: Makefile.am magicktest.q mozilla.png sprite.q Log Message: Added magick module --- NEW FILE: Makefile.am --- ## Process this file with automake to generate a GNU Makefile examplesdir = $(pkgdatadir)/examples/magick if GGI examples_DATA = *.q *.png endif EXTRA_DIST = *.q *.png --- NEW FILE: magicktest.q --- import ggi, magick; /* show NAME INFO: show an image (designated by a valid ImageMagick source specification NAME and an INFO structure, see magick.q for details) in a GGI visual. Returns the created visual. */ show NAME INFO = display IMG where IMG:Image = read_image NAME INFO; /* The simple case: our image is opaque. In this case we just render it on a screen visual. */ display IMG = ggi_put_box VIS (0,0) (W,H) PIXELS || ggi_flush VIS || VIS where (W,H|_) = image_info IMG, VIS = ggi_open "x:-keepcursor", () = ggi_set_mode VIS (sprintf "%dx%d" (W,H)), PIXELS = get_image_pixels IMG (0,0) (W,H) if is_opaque_image IMG; /* The complicated case: our image has transparency. In this case we draw the image over a background. To these ends, we first render the image on a memory visual and crossblit that to the target visual on the screen. */ def BACK = magick_pixel "gray"; display IMG = ggi_put_box MEM (0,0) (W,H) PIXELS || /* we need to also set the alpha values since these aren't transferred by ggi_put_box */ ggi_put_alpha_box MEM (0,0) (W,H) ALPHA || ggi_set_background VIS BACK || ggi_clear VIS || ggi_cross_blit MEM (0,0) (W,H) VIS (0,0) || ggi_flush VIS || VIS where (W,H|_) = image_info IMG, VIS = ggi_open "x:-keepcursor", () = ggi_set_mode VIS (sprintf "%dx%d.A8" (W,H)), () = ggi_set_alpha_flags VIS (ggi_get_alpha_flags VIS or GGI_BUF_PUTGET), (_,_,_,_,_,_,_,_,D,S) = sscanf (ggi_get_mode VIS) "%dx%d.V%dx%d.F%d.D%dx%d.[%c%d/%d]", MEM = ggi_open "memory", () = ggi_set_mode MEM (sprintf "%dx%d.[C%d/%d].A8" (W,H,D,S)), () = ggi_set_alpha_flags MEM (ggi_get_alpha_flags MEM or GGI_BUF_PUTGET), PIXELS = get_image_pixels IMG (0,0) (W,H), ALPHA = get_image_alpha IMG (0,0) (W,H) otherwise; --- NEW FILE: mozilla.png --- (This appears to be a binary file; contents omitted.) --- NEW FILE: sprite.q --- /* sprite.q: This is a tiny test program demonstrating how to move an image with transparency over a background image. 12-12-03 AG */ /* To use, evaluate `sprite', click left in the GGI window to show the sprite at the current pointer position, move the pointer to move it around, click right to hide the sprite again, etc. Press the middle mouse button to terminate the input loop at any time. */ import ggi, magick; /* globals */ def /* read in the background and the sprite image */ BACK_IMG = read_image "logo:" (), SPRITE_IMG = read_image "mozilla.png" (), /* determine the dimensions of the background image and render it inside a GGI display visual */ (W,H|_) = image_info BACK_IMG, VIS = ggi_open "x:-keepcursor", _ = ggi_set_mode VIS (sprintf "%dx%d.A8" (W,H)) || ggi_set_flags VIS GGI_FLAG_ASYNC || ggi_put_box VIS (0,0) (W,H) (get_image_pixels BACK_IMG (0,0) (W,H)) || ggi_flush VIS, /* get the colorspace of the display visual */ (_,_,_,_,_,_,_,_,D,S) = sscanf (ggi_get_mode VIS) "%dx%d.V%dx%d.F%d.D%dx%d.[%c%d/%d]", /* dimensions of the sprite image */ (W,H|_) = image_info SPRITE_IMG, /* create a memory visual as back storage */ BACK = ggi_open "memory", /* set the same colorspace as on the display visual, in order to avoid colorspace conversions (note that we need no alpha buffer here, since we only have to store the pixels of the background image) */ _ = ggi_set_mode BACK (sprintf "%dx%d.[C%d/%d]" (W,H,D,S)), /* render the sprite image in another memory visual with alpha buffer, which will be crossblitted to the display */ SPRITE = ggi_open "memory", _ = ggi_set_mode SPRITE (sprintf "%dx%d.[C%d/%d].A8" (W,H,D,S)) || /* make sure GGI_BUF_PUTGET is set to enable full alpha blending */ ggi_set_alpha_flags SPRITE (ggi_get_alpha_flags SPRITE or GGI_BUF_PUTGET) || ggi_put_box SPRITE (0,0) (W,H) (get_image_pixels SPRITE_IMG (0,0) (W,H)) || ggi_put_alpha_box SPRITE (0,0) (W,H) (get_image_alpha SPRITE_IMG (0,0) (W,H)); /* save background pixels in the BACK visual */ save_back (X,Y) = ggi_put_box BACK (0,0) (W,H) (ggi_get_box VIS (X,Y) (W,H)); /* restore background from the BACK visual */ restore_back (X,Y) = ggi_put_box VIS (X,Y) (W,H) (ggi_get_box BACK (0,0) (W,H)); /* draw the sprite (crossblit from SPRITE visual) */ draw_sprite (X,Y) = ggi_cross_blit SPRITE (0,0) (W,H) VIS (X,Y); /* show, hide and move the sprite on the display */ show_sprite (X,Y) = save_back (X,Y) || draw_sprite (X,Y) || ggi_flush VIS; hide_sprite (X,Y) = restore_back (X,Y) || ggi_flush VIS; move_sprite (X,Y) (X1,Y1) = restore_back (X,Y) || save_back (X1,Y1) || draw_sprite (X1,Y1) || ggi_flush VIS; /* the main function */ sprite = loop () (); /* the input loop; take appropriate actions on mouse events */ loop STATE POS = process STATE POS (ggi_read VIS GGI_EM_ALL); // exit when middle button pressed process STATE _ (ggi_event TYPE _ _ _ _ PARAM) = cleanup STATE if (TYPE = GGI_EV_PTRBUTTONPRESS) and then (PARAM = 3); // clean up at exit cleanup (X,Y) = hide_sprite (X-W2,Y-H2); cleanup _ = () otherwise; // use these offsets to center the sprite at the cursor def W2 = W div 2, H2 = H div 2; // show sprite when left button pressed process () (X,Y) (ggi_event TYPE _ _ _ _ PARAM) = show_sprite (X-W2,Y-H2) || loop (X,Y) () if (TYPE = GGI_EV_PTRBUTTONPRESS) and then (PARAM = 1); // hide sprite when right button pressed process (X,Y) _ (ggi_event TYPE _ _ _ _ PARAM) = hide_sprite (X-W2,Y-H2) || loop () (X,Y) if (TYPE = GGI_EV_PTRBUTTONPRESS) and then (PARAM = 2); // move sprite when pointer is moved process (X,Y) _ (ggi_event TYPE _ _ _ _ (X1,Y1|_)) = move_sprite (X-W2,Y-H2) (X1-W2,Y1-H2) || loop (X1,Y1) () if TYPE = GGI_EV_PTRABSOLUTE; // track the pointer position when the sprite is off process () _ (ggi_event TYPE _ _ _ _ (X,Y|_)) = loop () (X,Y) if TYPE = GGI_EV_PTRABSOLUTE; // default action: do nothing process STATE POS _ = loop STATE POS otherwise; |
From: <ag...@us...> - 2003-12-16 19:11:19
|
Update of /cvsroot/q-lang/q/modules/ggi In directory sc8-pr-cvs1:/tmp/cvs-serv655/modules/ggi Modified Files: Makefile.am Log Message: Added magick module Index: Makefile.am =================================================================== RCS file: /cvsroot/q-lang/q/modules/ggi/Makefile.am,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -C2 -d -r1.1.1.1 -r1.2 *** Makefile.am 15 Dec 2003 10:20:40 -0000 1.1.1.1 --- Makefile.am 16 Dec 2003 19:11:16 -0000 1.2 *************** *** 13,17 **** ggi_la_SOURCES = ggi.c ggi_la_LDFLAGS = -no-undefined -module -avoid-version ! ggi_la_LIBADD = -L$(top_builddir)/libq -lq @LIBGMP@ @GGI_LIBS@ @LIBDMALLOCTH@ stdlibdir = $(pkgdatadir)/lib --- 13,17 ---- ggi_la_SOURCES = ggi.c ggi_la_LDFLAGS = -no-undefined -module -avoid-version ! ggi_la_LIBADD = -L$(top_builddir)/libq -lq @LIBGMP@ @GGI_LIBS@ @GGI_LIBBUF@ @LIBDMALLOCTH@ stdlibdir = $(pkgdatadir)/lib |
From: <ag...@us...> - 2003-12-16 19:11:19
|
Update of /cvsroot/q-lang/q/modules In directory sc8-pr-cvs1:/tmp/cvs-serv655/modules Modified Files: Makefile.am Log Message: Added magick module Index: Makefile.am =================================================================== RCS file: /cvsroot/q-lang/q/modules/Makefile.am,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -C2 -d -r1.1.1.1 -r1.2 *** Makefile.am 15 Dec 2003 10:20:11 -0000 1.1.1.1 --- Makefile.am 16 Dec 2003 19:11:16 -0000 1.2 *************** *** 1,3 **** ## Process this file with automake to generate a GNU Makefile ! SUBDIRS = clib dxl gdbm ggi octave odbc tk --- 1,3 ---- ## Process this file with automake to generate a GNU Makefile ! SUBDIRS = clib dxl gdbm ggi magick octave odbc tk |
From: <ag...@us...> - 2003-12-16 19:11:19
|
Update of /cvsroot/q-lang/q/doc In directory sc8-pr-cvs1:/tmp/cvs-serv655/doc Modified Files: version.texi Log Message: Added magick module Index: version.texi =================================================================== RCS file: /cvsroot/q-lang/q/doc/version.texi,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** version.texi 15 Dec 2003 12:07:14 -0000 1.2 --- version.texi 16 Dec 2003 19:11:16 -0000 1.3 *************** *** 1,4 **** ! @set UPDATED 14 October 2003 ! @set UPDATED-MONTH October 2003 @set EDITION 4.6 @set VERSION 4.6 --- 1,4 ---- ! @set UPDATED 15 December 2003 ! @set UPDATED-MONTH December 2003 @set EDITION 4.6 @set VERSION 4.6 |
From: <ag...@us...> - 2003-12-16 19:11:19
|
Update of /cvsroot/q-lang/q In directory sc8-pr-cvs1:/tmp/cvs-serv655 Modified Files: ChangeLog configure.in Log Message: Added magick module Index: ChangeLog =================================================================== RCS file: /cvsroot/q-lang/q/ChangeLog,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** ChangeLog 16 Dec 2003 10:53:50 -0000 1.3 --- ChangeLog 16 Dec 2003 19:11:16 -0000 1.4 *************** *** 1,6 **** 2003-12-16 Albert Graef <Dr....@t-...> * README, NEWS: bump version to 4.6, add a NEWS entry for ongoing ! development for the 4.6 release 2003-12-14 Albert Graef <Dr....@t-...> --- 1,14 ---- 2003-12-16 Albert Graef <Dr....@t-...> + * README: add information on ImageMagick support + + * magick: added ImageMagick module + + * configure.in, modules/ggi/Makefile.am: fixed some ggi-related + quirks in configury + * README, NEWS: bump version to 4.6, add a NEWS entry for ongoing ! development for the 4.6 release, add pointers to the q-lang ! SourceForge project 2003-12-14 Albert Graef <Dr....@t-...> Index: configure.in =================================================================== RCS file: /cvsroot/q-lang/q/configure.in,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** configure.in 15 Dec 2003 12:07:13 -0000 1.2 --- configure.in 16 Dec 2003 19:11:16 -0000 1.3 *************** *** 264,267 **** --- 264,304 ---- AC_SUBST(GGI_INCLUDES) + # ImageMagick + + MAGICK_LIBS="yes" + AC_ARG_WITH(magick, + [ --with-magick[[=LIBS]] use the ImageMagick library (magick module)], + [case "${withval}" in + no) MAGICK_LIBS="" ;; + *) MAGICK_LIBS="${withval}" ;; + esac]) + if test "${MAGICK_LIBS}" = "yes"; then + MAGICK_LIBS="" + AC_CHECK_LIB(Magick, InitializeMagick, [ MAGICK_LIBS="-lMagick" ]) + if test "${MAGICK_LIBS}" = ""; then + AC_MSG_WARN([could not find the ImageMagick library, skipping the magick module]) + else + AC_MSG_RESULT([defining MAGICK_LIBS to be ${MAGICK_LIBS}]) + fi + fi + AM_CONDITIONAL(MAGICK, test "${MAGICK_LIBS}" != "") + AC_SUBST(MAGICK_LIBS) + if test "${MAGICK_LIBS}" != ""; then + MAGICK_MODULE='-dlopen $(top_srcdir)/modules/magick/magick.la' + else + MAGICK_MODULE="" + fi + AC_SUBST(MAGICK_MODULE) + + MAGICK_INCLUDES="" + AC_ARG_WITH(magick-includes, + [ --with-magick-includes=INC extra includes for the ImageMagick library], + [case "${withval}" in + yes) MAGICK_INCLUDES="" ;; + no) MAGICK_INCLUDES="" ;; + *) MAGICK_INCLUDES="${withval}" ;; + esac]) + AC_SUBST(MAGICK_INCLUDES) + # ODBC *************** *** 509,517 **** --- 546,557 ---- AC_CHECK_FUNCS(gethostname gethostbyname gethostbyaddr gethostent getprotobyname getprotobynumber getprotoent getservbyname getservbyport getservent inet_aton) dnl pthread stuff + OLDLIBS=$LIBS LIBS="$LIBS $LIBPTHREAD" AC_CHECK_FUNCS(pthread_atfork) + LIBS=$OLDLIBS dnl ggi buffer support LIBS="$LIBS ${GGI_LIBBUF}" AC_CHECK_FUNCS(ggiBufInit) + LIBS=$OLDLIBS dnl Configure readline support. *************** *** 576,580 **** dnl Output. ! AC_OUTPUT(Makefile doc/Makefile etc/Makefile examples/Makefile libq/Makefile modules/Makefile modules/clib/Makefile modules/clib/examples/Makefile modules/dxl/Makefile modules/dxl/examples/Makefile modules/gdbm/Makefile modules/gdbm/examples/Makefile modules/ggi/Makefile modules/ggi/examples/Makefile modules/octave/Makefile modules/odbc/Makefile modules/odbc/examples/Makefile modules/tk/Makefile modules/tk/examples/Makefile src/Makefile stdlib/Makefile) dnl Brief summary. --- 616,620 ---- dnl Output. ! AC_OUTPUT(Makefile doc/Makefile etc/Makefile examples/Makefile libq/Makefile modules/Makefile modules/clib/Makefile modules/clib/examples/Makefile modules/dxl/Makefile modules/dxl/examples/Makefile modules/gdbm/Makefile modules/gdbm/examples/Makefile modules/ggi/Makefile modules/ggi/examples/Makefile modules/magick/Makefile modules/magick/examples/Makefile modules/octave/Makefile modules/odbc/Makefile modules/odbc/examples/Makefile modules/tk/Makefile modules/tk/examples/Makefile src/Makefile stdlib/Makefile) dnl Brief summary. *************** *** 622,629 **** fi if test "${GGI_LIBS}" != ""; then ! AC_MSG_RESULT([ GGI: libraries: ${GGI_LIBS}] ${GGI_LIBBUF}) AC_MSG_RESULT([ includes : ${GGI_INCLUDES}]) else AC_MSG_RESULT([ GGI: disabled]) fi if test "${ODBC_LIBS}" != ""; then --- 662,675 ---- fi if test "${GGI_LIBS}" != ""; then ! AC_MSG_RESULT([ GGI: libraries: ${GGI_LIBS} ${GGI_LIBBUF}]) AC_MSG_RESULT([ includes : ${GGI_INCLUDES}]) else AC_MSG_RESULT([ GGI: disabled]) + fi + if test "${MAGICK_LIBS}" != ""; then + AC_MSG_RESULT([ ImageMagick: libraries: ${MAGICK_LIBS}]) + AC_MSG_RESULT([ includes : ${MAGICK_INCLUDES}]) + else + AC_MSG_RESULT([ ImageMagick: disabled]) fi if test "${ODBC_LIBS}" != ""; then |
From: <ag...@us...> - 2003-12-16 19:04:36
|
Update of /cvsroot/q-lang/q/modules/magick/examples In directory sc8-pr-cvs1:/tmp/cvs-serv32231/examples Log Message: Directory /cvsroot/q-lang/q/modules/magick/examples added to the repository |
From: <ag...@us...> - 2003-12-16 19:03:18
|
Update of /cvsroot/q-lang/q/modules/magick In directory sc8-pr-cvs1:/tmp/cvs-serv31901/magick Log Message: Directory /cvsroot/q-lang/q/modules/magick added to the repository |
From: <ag...@us...> - 2003-12-16 19:02:32
|
Update of /cvsroot/q-lang/q In directory sc8-pr-cvs1:/tmp/cvs-serv31621 Modified Files: README NEWS Log Message: More updates in README and NEWS files Index: README =================================================================== RCS file: /cvsroot/q-lang/q/README,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** README 16 Dec 2003 13:38:18 -0000 1.4 --- README 16 Dec 2003 19:02:29 -0000 1.5 *************** *** 66,73 **** POSIX threads, BSD sockets, regular expression matching, ... ! The distribution includes the Q programming tools, the standard library, ! add-on modules for interfacing to GNU Octave, GNU dbm, ODBC, Tcl/Tk and IBM's ! Data Explorer, and an Emacs mode. A Windows GUI frontend can be obtained as a ! separate package. For more information please check out the Q homepage at: http://q-lang.sourceforge.net --- 66,76 ---- POSIX threads, BSD sockets, regular expression matching, ... ! The distribution includes the Q programming tools, the standard library, a ! collection of useful add-on modules for interfacing to various third-party ! libraries and software, such as GNU Octave, GNU dbm, ODBC, GGI, ImageMagick, ! Tcl/Tk and IBM's Data Explorer, as well as Q language modes for Emacs and ! Kate. A Windows GUI frontend can be obtained as a separate package. For more ! information please check out the Q homepage at the following URL: ! http://q-lang.sourceforge.net *************** *** 197,205 **** (readline library), gdbm (GNU dbm library, needed for the gdbm module), odbc (ODBC library, needed for the odbc module), ggi (GGI libraries, needed for the ! ggi module), tk (Tcl/Tk libraries, needed for the tk module) or dxl (Data ! Explorer DXLink library, needed for the dxl module). Among these only the gmp ! library is strictly necessary for building the package. Multithreading support ! will be enabled by default if the POSIX thread library is found, but can be ! disabled with the --without-pthread option. For instance, if your gmp library is in /root/lib and the gmp.h header file in --- 200,209 ---- (readline library), gdbm (GNU dbm library, needed for the gdbm module), odbc (ODBC library, needed for the odbc module), ggi (GGI libraries, needed for the ! ggi module), magick (ImageMagick library, needed for the magick module), tk ! (Tcl/Tk libraries, needed for the tk module) or dxl (Data Explorer DXLink ! library, needed for the dxl module). Among these only the gmp library is ! strictly necessary for building the package. Multithreading support will be ! enabled by default if the POSIX thread library is found, but can be disabled ! with the --without-pthread option. For instance, if your gmp library is in /root/lib and the gmp.h header file in *************** *** 368,371 **** --- 372,383 ---- create raster graphics on a variety of display devices. See README-GGI for more information. + + IMAGEMAGICK + ----------- + + The `magick' module lets you access most common image formats using the + ImageMagick library, available from http://www.imagemagick.org. Using this + module you can, e.g., perform various image manipulation operations and render + image files in a GGI visual. See README-Magick for more information. OCTAVE Index: NEWS =================================================================== RCS file: /cvsroot/q-lang/q/NEWS,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** NEWS 16 Dec 2003 10:53:50 -0000 1.2 --- NEWS 16 Dec 2003 19:02:29 -0000 1.3 *************** *** 5,12 **** * 4.6 (unreleased) Work is underway to improve the GGI interface and add a magick module which uses libMagick to load, save and manipulate images in a variety of file ! formats. This is currently available in CVS only, see http://sourceforge.net/ ! projects/q-lang/. --- 5,22 ---- * 4.6 (unreleased) + BIG NEWS: Q goes SourceForge! As of December 2003, Q has become a + SourceForge-hosted project, which can be found at the following URL: + + http://sourceforge.net/projects/q-lang/ + + There you can now obtain released source and binary packages (check the + "Files" link on the project page), as well as the latest and greatest + development sources in CVS ("CVS" link). Two mailing lists for discussing Q + development and usage are also available ("Lists" link). + Work is underway to improve the GGI interface and add a magick module which uses libMagick to load, save and manipulate images in a variety of file ! formats. This is currently available in CVS only, but we expect to release Q ! 4.6 with all these new features "real soon now". :) |