[q-lang-cvs] q/modules/magick README-Magick,1.2,1.3 magick.c,1.4,1.5 magick.q,1.4,1.5
Brought to you by:
agraef
From: <ag...@us...> - 2003-12-26 03:10:52
|
Update of /cvsroot/q-lang/q/modules/magick In directory sc8-pr-cvs1:/tmp/cvs-serv10788 Modified Files: README-Magick magick.c magick.q Log Message: added image list support Index: README-Magick =================================================================== RCS file: /cvsroot/q-lang/q/modules/magick/README-Magick,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** README-Magick 23 Dec 2003 13:14:43 -0000 1.2 --- README-Magick 26 Dec 2003 03:10:48 -0000 1.3 *************** *** 14,26 **** 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 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 --- 14,24 ---- 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.) and 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. At present a fairly recent ! ImageMagick version (>= 5.5) is required. Please see magick.q for a description of the functions provided by this *************** *** 33,37 **** Enjoy! :) ! Dec 23 2003 Albert Graef ag...@mu..., Dr....@t-... --- 31,35 ---- Enjoy! :) ! Dec 26 2003 Albert Graef ag...@mu..., Dr....@t-... Index: magick.c =================================================================== RCS file: /cvsroot/q-lang/q/modules/magick/magick.c,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** magick.c 24 Dec 2003 03:05:36 -0000 1.4 --- magick.c 26 Dec 2003 03:10:48 -0000 1.5 *************** *** 427,431 **** if (!img) return __FAIL; ! else { if (matte >= 0) img->matte = (unsigned)matte; return mkobj(type(Image), img); --- 427,455 ---- if (!img) return __FAIL; ! else if (img->next) { ! expr x = mknil; ! Image *imgs; ! if (matte >= 0) ! for (imgs = img; imgs; imgs = imgs->next) ! imgs->matte = (unsigned)matte; ! /* convert image sequence into list of images */ ! for (imgs = img; imgs->next; imgs = imgs->next) ! ; ! /* imgs now points at the last image in the sequence */ ! while (x && imgs) { ! Image *tmp = imgs->previous; ! if (tmp) { ! tmp->next = NULL; ! imgs->previous = NULL; ! } ! x = mkcons(mkobj(type(Image), imgs), x); ! imgs = tmp; ! } ! if (!x) { ! DestroyImageList(img); ! return __ERROR; ! } ! return x; ! } else { if (matte >= 0) img->matte = (unsigned)matte; return mkobj(type(Image), img); *************** *** 438,452 **** { 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) --- 462,516 ---- { char *s; ! if (argc == 2 && isstr(argv[0], &s)) { ! Image *img = NULL, *tmp, *tmp2; ! ImageInfo *info; int res; + expr x, hd, tl; + if (isnil(argv[1])) + return __FAIL; + info = CloneImageInfo(NULL); if (!info) return __ERROR; ! for (x = argv[1]; iscons(x, &hd, &tl); x = tl) { ! if (!(isobj(hd, type(Image), (void**)&tmp) && ! tmp->columns > 0 && tmp->rows > 0)) { ! DestroyImageInfo(info); ! return __FAIL; ! } ! if (!img) img = tmp; ! } ! if (img && !isnil(x)) { ! DestroyImageInfo(info); ! return __FAIL; ! } ! if (img) { ! /* build the image list */ ! tmp2 = NULL; ! for (x = argv[1]; iscons(x, &hd, &tl); x = tl) { ! isobj(hd, type(Image), (void**)&tmp); ! if (tmp2) { ! tmp->previous = tmp2; ! tmp2->next = tmp; ! } ! tmp2 = tmp; ! res = WriteImages(info, img, s, &exception); ! } ! } else { ! /* must be a singleton image */ ! if (!(isobj(argv[1], type(Image), (void**)&img) && ! img->columns > 0 && img->rows > 0)) { ! DestroyImageInfo(info); ! return __FAIL; ! } ! strncpy(img->filename, s, MaxTextExtent-1); ! res = WriteImage(info, img); ! exception = img->exception; ! } DestroyImageInfo(info); ! /* break up image list */ ! for (tmp = img; tmp; tmp = tmp2) { ! tmp2 = tmp->next; ! tmp->previous = tmp->next = NULL; ! } ! if (check_exception(&exception)) return mkapp(mksym(sym(magick_error)), mkstr(strdup(msg))); else if (!res) Index: magick.q =================================================================== RCS file: /cvsroot/q-lang/q/modules/magick/magick.q,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** magick.q 24 Dec 2003 03:05:36 -0000 1.4 --- magick.q 26 Dec 2003 03:10:48 -0000 1.5 *************** *** 24,31 **** 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.); image list handling ! (animations); image manipulation operations. */ ! import clib; /* The Image type. Objects of this type are created with the create_image and --- 24,31 ---- 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.), image manipulation ! operations. */ ! import stdlib, clib; /* The Image type. Objects of this type are created with the create_image and *************** *** 64,75 **** public extern magick_pixel COLOR; ! /* 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, MAGICK), where (WIDTH, HEIGHT) denotes ! the dimensions of the image, DEPTH is the bit depth of the color values ! (usually 8 or 16), MATTE is 1 if the image has an alpha channel and 0 ! otherwise, and MAGICK is a string naming one of the image formats ! understood by ImageMagick (such as EPS, GIF, RGB, etc.). Only the first two fields specifying the dimensions of the image are --- 64,74 ---- public extern magick_pixel COLOR; ! /* Operations to create and copy images. The create_image function creates a ! new image, given an INFO tuple of the form (WIDTH, HEIGHT, DEPTH, MATTE, ! MAGICK), where (WIDTH, HEIGHT) denotes the dimensions of the image, DEPTH ! is the bit depth of the color values (usually 8 or 16), MATTE is 1 if the ! image has an alpha channel and 0 otherwise, and MAGICK is a string naming ! one of the image formats understood by ImageMagick (such as EPS, GIF, RGB, ! etc.). Only the first two fields specifying the dimensions of the image are *************** *** 80,98 **** dimensions of the image. ! 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") or indicate a special ! builtin image object (such as "logo:" or "xc:white"); see ImageMagick(1) ! for details. Additional image properties may be specified in the INFO ! argument, which has the same form as for create_image. For read_image, all ! fields in the INFO structure are optional, but note that for raw image data ! (e.g., RGB or RGBA) you will have to specify at least the dimensions of the ! image. 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 PIXELS, clone_image IMG; public extern read_image NAME INFO, write_image NAME IMG; --- 79,113 ---- dimensions of the image. ! The clone_image function creates an exact copy of the given image. This is ! useful if an image is to be modified but you want to retain the original ! image. */ ! public extern create_image INFO PIXELS, clone_image IMG; ! ! /* Operations to read and write images. The read_image function reads an image ! from the given source, which may also include a format prefix (such as ! "rgb:file") or indicate a special builtin image object (such as "logo:" or ! "xc:white"); see ImageMagick(1) for details. Additional image properties ! may be specified in the INFO argument, which has the same form as for ! create_image. For read_image, all fields in the INFO structure are ! optional, but note that for raw image data (e.g., RGB or RGBA) you will ! have to specify at least the dimensions of the image. ! ! Note that some image files (such as GIF animations or MPEG movies) actually ! contain an entire sequence of images (which are also called "frames") ! rather than a single image; in this case read_image returns a list with all ! the images that were read from the file. You can also specify a subrange of ! frames to be extracted in the input filename (e.g., "video.mpg[50-75]"), ! see ImageMagick(1) for details. The write_image function writes the given image to the given target, ! designated by a name in the same syntax as for read_image. If the input ! image is actually a list of images, it is written to a single multi-image ! file, if the image format supports that, or to a sequence of files with ! attached frame numbers otherwise. You can also specify a %d printf ! specification in the output filename (e.g., "image%02d.miff") which ! expands to the zero-based frame number when the individual frames are ! written, see again ImageMagick(1) for details. */ public extern read_image NAME INFO, write_image NAME IMG; |