[q-lang-cvs] q/modules/magick magick.c,1.11,1.12 magick.q,1.9,1.10
Brought to you by:
agraef
From: <ag...@us...> - 2003-12-28 05:25:57
|
Update of /cvsroot/q-lang/q/modules/magick In directory sc8-pr-cvs1:/tmp/cvs-serv29782 Modified Files: magick.c magick.q Log Message: added resource management routines Index: magick.c =================================================================== RCS file: /cvsroot/q-lang/q/modules/magick/magick.c,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** magick.c 27 Dec 2003 19:41:48 -0000 1.11 --- magick.c 28 Dec 2003 01:56:36 -0000 1.12 *************** *** 138,167 **** /* 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)); } --- 138,150 ---- /* manifest constants */ FUNCTION(magick,magick_vars,argc,argv) { if (argc != 0) return __FAIL; return mktuplel ! (4, ! mkuint(FileResource), ! mkuint(MemoryResource), ! mkuint(MapResource), ! mkuint(DiskResource)); } *************** *** 196,199 **** --- 179,228 ---- } return x; + } + + FUNCTION(magick,magick_limit,argc,argv) + { + char *res; + unsigned long limit; + if (argc == 2 && isstr(argv[0], &res) && isuint(argv[1], &limit)) { + #if 0 /* not supported */ + if (!strcmp(res, "file")) + SetMagickResourceLimit(FileResource, limit); + else + #endif + if (!strcmp(res, "memory")) + SetMagickResourceLimit(MemoryResource, limit); + else if (!strcmp(res, "map")) + SetMagickResourceLimit(MapResource, limit); + else if (!strcmp(res, "disk")) + SetMagickResourceLimit(DiskResource, limit); + else + return __FAIL; + return mkvoid; + } else + return __FAIL; + } + + FUNCTION(magick,magick_limits,argc,argv) + { + if (argc == 0) { + ListMagickResourceInfo(stdout, &exception); + if (check_exception(&exception)) + return mkapp(mksym(sym(magick_error)), mkstr(strdup(msg))); + else + return mkvoid; + } else + return __FAIL; + } + + FUNCTION(magick,magick_resources,argc,argv) + { + if (argc == 0) + return mktuplel(4, mkuint(GetMagickResource(FileResource)), + mkuint(GetMagickResource(MemoryResource)), + mkuint(GetMagickResource(MapResource)), + mkuint(GetMagickResource(DiskResource))); + else + return __FAIL; } Index: magick.q =================================================================== RCS file: /cvsroot/q-lang/q/modules/magick/magick.q,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** magick.q 27 Dec 2003 19:41:16 -0000 1.9 --- magick.q 28 Dec 2003 01:56:36 -0000 1.10 *************** *** 73,76 **** --- 73,85 ---- public extern magick_info; + /* ImageMagick resource management. You can set a limit on the resource RES + (which can be any of the resource types for ImageMagick's -limit option, + see ImageMagick(1) for details; currently "memory", "map" and "disk" are + supported) with the magick_limit function, use the magick_limits function + to print the current limits on standard output, and retrieve the current + resource usage figures with magick_resources. */ + + public extern magick_limit RES VAL, magick_limits, magick_resources; + /* 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 *************** *** 123,132 **** 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 ping_image function is like read_image, but does *not* read the actual --- 132,145 ---- have to specify at least the dimensions of the image. ! Note that some image files (such as GIF animations or MPEG videos) 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. Be warned that reading an entire video file ! will eat *huge* amounts of memory. You can work around some of this by ! carefully tuning ImageMagick's resource limits with magick_limit, but, at ! least at the time of this writing, ImageMagick is not really up to handling ! huge amounts of video data yet. The ping_image function is like read_image, but does *not* read the actual *************** *** 139,143 **** 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 --- 152,156 ---- 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 use 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 *************** *** 237,241 **** def GRAY = 0, RGB = 1; ! public extern quantize IMG SPACE DITHER; // BANG! /* Resizing and scaling. */ --- 250,254 ---- def GRAY = 0, RGB = 1; ! public extern quantize IMG SPACE DITHER; // BANG! /* Resizing and scaling. */ |