[q-lang-cvs] q/modules/magick README-Magick,1.4,1.5 magick.c,1.29,1.30 magick.q,1.27,1.28
Brought to you by:
agraef
From: <ag...@us...> - 2003-12-31 01:47:56
|
Update of /cvsroot/q-lang/q/modules/magick In directory sc8-pr-cvs1:/tmp/cvs-serv13713 Modified Files: README-Magick magick.c magick.q Log Message: added magick_color and image_label/set_image_label functions, updated examples and docs Index: README-Magick =================================================================== RCS file: /cvsroot/q-lang/q/modules/magick/README-Magick,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** README-Magick 29 Dec 2003 03:17:53 -0000 1.4 --- README-Magick 31 Dec 2003 01:47:52 -0000 1.5 *************** *** 3,23 **** ======== = =========== ========= === === = =========== ======== ! 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, operations to retrieve and change the pixel ! data, and most image manipulation functions are already in place. Some of the ! more advanced image manipulation routines still need to be done. 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. At present a fairly recent ! ImageMagick version (>= 5.5) is required. Please see magick.q for a description of the functions provided by this --- 3,18 ---- ======== = =========== ========= === === = =========== ======== ! This module provides an 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. The module requires that you have ImageMagick installed, which should be ! readily available in most Linux distributions. The Windows Qpad package will ! include all necessary support files once this module is released. At present a ! fairly recent ImageMagick version (>= 5.5) is required. Please see magick.q for a description of the functions provided by this *************** *** 30,34 **** Enjoy! :) ! Dec 29 2003 Albert Graef ag...@mu..., Dr....@t-... --- 25,29 ---- Enjoy! :) ! Dec 31 2003 Albert Graef ag...@mu..., Dr....@t-... Index: magick.c =================================================================== RCS file: /cvsroot/q-lang/q/modules/magick/magick.c,v retrieving revision 1.29 retrieving revision 1.30 diff -C2 -d -r1.29 -r1.30 *** magick.c 31 Dec 2003 00:22:52 -0000 1.29 --- magick.c 31 Dec 2003 01:47:52 -0000 1.30 *************** *** 869,872 **** --- 869,900 ---- } + FUNCTION(magick,magick_color,argc,argv) + { + bstr_t *m; + if (argc == 1 && isobj(argv[0], type(ByteStr), (void**)&m) && + m->size%8 == 0) { + if (m->size == 0) + return mknil; + else if (m->size == 8) { + unsigned short *v = (unsigned short*)m->v; + unsigned short r, g, b, a; + r = *v++; g = *v++; b = *v++; a = *v++; + return mktuplel(4, mkuint(r), mkuint(g), mkuint(b), mkuint(a)); + } else { + expr x = mknil; + int i, n = m->size/8; + unsigned short *v = (unsigned short*)(m->v+m->size); + unsigned short r, g, b, a; + for (i = 0; x && i < n; i++) { + a = *--v; b = *--v; g = *--v; r = *--v; + x = mkcons(mktuplel(4, mkuint(r), mkuint(g), mkuint(b), mkuint(a)), + x); + } + return x; + } + } else + return __FAIL; + } + FUNCTION(magick,create_image,argc,argv) { Index: magick.q =================================================================== RCS file: /cvsroot/q-lang/q/modules/magick/magick.q,v retrieving revision 1.27 retrieving revision 1.28 diff -C2 -d -r1.27 -r1.28 *** magick.q 31 Dec 2003 00:22:52 -0000 1.27 --- magick.q 31 Dec 2003 01:47:52 -0000 1.28 *************** *** 1,4 **** ! /* magick.q: poor man's ImageMagick interface $Id$ */ --- 1,4 ---- ! /* magick.q: the Q programmer's ImageMagick interface $Id$ */ *************** *** 19,28 **** 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, save and manipulate images, ! and to retrieve and change image pixels are already in place. The ! annotation, draw and paint operations still need to be done. */ import clib; --- 19,30 ---- Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ ! /* This module provides access to the ImageMagick C API (libMagick), a ! comprehensive library for image manipulation. Requires ImageMagick, ! available from http://www.imagemagick.org/. All essential ImageMagick ! operations are supported, including creating, reading and writing images in ! a plethora of different formats, retrieving and changing the pixel data of ! an image, davanced image manipulation and effect functions, and drawing ! primitives. As the external pixel representation is the same as that of the ! GGI module, GGI visuals can be employed to actually display the images. */ import clib; *************** *** 137,143 **** 0xffff if it is missing. The function also packs a list of such values into a single byte string. The returned value can be passed as the PIXELS ! parameter of create_image and set_image_pixels. */ ! public extern magick_pixel COLOR; /***************************************************************************/ --- 139,148 ---- 0xffff if it is missing. The function also packs a list of such values into a single byte string. The returned value can be passed as the PIXELS ! parameter of create_image and set_image_pixels. ! The magick_color function converts an RGBA byte string back to an (R,G,B,A) ! tuple or a list of such tuples. */ ! ! public extern magick_pixel COLOR, magick_color PIXEL; /***************************************************************************/ *************** *** 194,199 **** image_magick IMG = M where (W,H,O,D,A,M) = image_info IMG; ! /* Some secondary image properties can be retrieved and changed with the ! following operations. The following properties are currently supported: - background_color, border_color, matte_color: The image background, border --- 199,211 ---- image_magick IMG = M where (W,H,O,D,A,M) = image_info IMG; ! /* The DRAW_INFO structure of an image summarizes various properties which ! control the rendering of graphics primitives with the draw function. It can ! be retrieved and changed with the following operations. */ ! ! // TODO: ! //public extern draw_info IMG, set_draw_info IMG INFO; ! ! /* A few other properties can be retrieved and changed with the following ! operations. These properties are currently supported: - background_color, border_color, matte_color: The image background, border *************** *** 229,246 **** public extern image_page IMG, set_image_page IMG PAGE; ! /* The following operations let you retrieve and change attributes (string ! values) associated with an image. To delete a key from the attributes list ! of an image, specify () as the VAL parameter of set_image_attr. Attributes ! used by ImageMagick include "comment", "label" and "signature". The "label" ! attribute is useful with the montage operation (see below). */ public extern image_attr IMG KEY, set_image_attr IMG KEY VAL; ! /* The DRAW_INFO structure of an image summarizes various properties which ! control the rendering of graphics primitives with the draw function. It can ! be retrieved and changed with the following operations. */ ! // TODO: ! //public extern draw_info IMG, set_draw_info IMG INFO; /***************************************************************************/ --- 241,262 ---- public extern image_page IMG, set_image_page IMG PAGE; ! /* The following operations let you retrieve and change named string ! attributes associated with an image. To delete a key from the attributes ! list of an image, specify () as the VAL parameter of set_image_attr. ! Otherwise the given value is added to the attribute (an existing value is ! *not* overridden automatically). Attributes used by ImageMagick include ! "comment", "label" and "signature". In particular, the "label" attribute is ! useful with the montage operation (see below). */ public extern image_attr IMG KEY, set_image_attr IMG KEY VAL; ! /* Convenience functions to access the "label" attribute. */ ! public image_label IMG, set_image_label IMG LABEL; ! ! image_label IMG:Image = LABEL where LABEL:String = image_attr IMG "label"; ! set_image_label IMG:Image LABEL:String ! = set_image_attr IMG "label" () || ! set_image_attr IMG "label" LABEL; /***************************************************************************/ *************** *** 496,500 **** public extern annotate IMG P TEXT; // BANG! ! public extern draw IMG CMD; // BANG! /* Painting. */ --- 512,516 ---- public extern annotate IMG P TEXT; // BANG! ! public extern draw IMG COMMAND; // BANG! /* Painting. */ |