q-lang-cvs Mailing List for Q - Equational Programming Language (Page 129)
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-30 13:53:07
|
Update of /cvsroot/q-lang/q/modules/magick In directory sc8-pr-cvs1:/tmp/cvs-serv4198 Modified Files: magick.c Log Message: added client_data infrastructure Index: magick.c =================================================================== RCS file: /cvsroot/q-lang/q/modules/magick/magick.c,v retrieving revision 1.26 retrieving revision 1.27 diff -C2 -d -r1.26 -r1.27 *** magick.c 30 Dec 2003 12:00:22 -0000 1.26 --- magick.c 30 Dec 2003 13:53:03 -0000 1.27 *************** *** 282,285 **** --- 282,303 ---- } + /* private image data; we use this to store the draw info and other + information needed by the operations of this module */ + + typedef struct { + DrawInfo *draw_info; + int tag; + } ImageData; + + static ImageData *init_data(void) + { + ImageData *data = malloc(sizeof(ImageData)); + if (data) { + data->draw_info = NULL; + data->tag = 0; + } + return data; + } + /* image type */ *************** *** 287,290 **** --- 305,309 ---- { Image *img = (Image*)ptr; + if (img->client_data) free(img->client_data); DestroyImage(img); } *************** *** 760,763 **** --- 779,783 ---- ImageInfo info; Image *img; + ImageData *data; int matte; GetImageInfo(&info); *************** *** 765,775 **** !parse_info(n, xv, &info, &matte)) return __FAIL; img = AllocateImage(&info); ! if (!img) return __ERROR; ! else { PixelPacket *pixels; if (matte >= 0) img->matte = (unsigned)matte; if (!(pixels = SetImagePixels(img, 0, 0, w, h))) { DestroyImage(img); return __FAIL; --- 785,799 ---- !parse_info(n, xv, &info, &matte)) return __FAIL; + if (!(data = init_data())) return __ERROR; img = AllocateImage(&info); ! if (!img) { ! free(data); return __ERROR; ! } else { PixelPacket *pixels; + img->client_data = data; if (matte >= 0) img->matte = (unsigned)matte; if (!(pixels = SetImagePixels(img, 0, 0, w, h))) { + free(img->client_data); DestroyImage(img); return __FAIL; *************** *** 787,790 **** --- 811,815 ---- return mkobj(type(Image), img); else { + free(img->client_data); DestroyImage(img); return __FAIL; *************** *** 816,824 **** tmp2 = tmp->next; tmp->previous = tmp->next = NULL; ! if ((int)tmp->client_data == 2) /* dispose temporary */ DestroyImage(tmp); else ! tmp->client_data = 0; } } --- 841,849 ---- tmp2 = tmp->next; tmp->previous = tmp->next = NULL; ! if (!tmp->client_data) /* dispose temporary */ DestroyImage(tmp); else ! ((ImageData*)tmp->client_data)->tag = 0; } } *************** *** 835,846 **** Image *tmp = imgs->previous; imgs->scene = 0; ! imgs->client_data = 0; ! x = mkcons(mkobj(type(Image), imgs), x); imgs = tmp; } if (x) decompose_image_list(img); ! else DestroyImageList(img); return x; } --- 860,877 ---- Image *tmp = imgs->previous; imgs->scene = 0; ! if ((imgs->client_data = init_data())) ! x = mkcons(mkobj(type(Image), imgs), x); ! else { ! dispose(x); x = NULL; ! } imgs = tmp; } if (x) decompose_image_list(img); ! else { ! for (imgs = img; imgs; imgs = imgs->next) ! if (imgs->client_data) free(imgs->client_data); DestroyImageList(img); + } return x; } *************** *** 872,875 **** --- 903,912 ---- return mk_image_list(img); } else { + ImageData *data = init_data(); + if (!data) { + DestroyImage(img); + return __ERROR; + } + img->client_data = data; if (matte >= 0) img->matte = (unsigned)matte; return mkobj(type(Image), img); *************** *** 905,908 **** --- 942,951 ---- return mk_image_list(img); } else { + ImageData *data = init_data(); + if (!data) { + DestroyImage(img); + return __ERROR; + } + img->client_data = data; if (matte >= 0) img->matte = (unsigned)matte; return mkobj(type(Image), img); *************** *** 926,931 **** for (y = x; iscons(y, &hd, &tl); y = tl) { isobj(hd, type(Image), (void**)&tmp); ! if (tmp->client_data) { ! /* we got a cycle here, clone the current image */ tmp = CloneImage(tmp, 0, 0, 1, &exception); if (check_exception(&exception)) { --- 969,974 ---- for (y = x; iscons(y, &hd, &tl); y = tl) { isobj(hd, type(Image), (void**)&tmp); ! if (tmp->client_data && ((ImageData*)tmp->client_data)->tag) { ! /* this image is already in the list, create a temporary copy */ tmp = CloneImage(tmp, 0, 0, 1, &exception); if (check_exception(&exception)) { *************** *** 933,939 **** return 0; } ! tmp->client_data = (void*)2; } else ! tmp->client_data = (void*)1; if (tmp2) { tmp->previous = tmp2; --- 976,982 ---- return 0; } ! tmp->client_data = NULL; } else ! ((ImageData*)tmp->client_data)->tag = 1; if (tmp2) { tmp->previous = tmp2; *************** *** 1061,1064 **** --- 1104,1113 ---- return mk_image_list(img); } else { + ImageData *data = init_data(); + if (!data) { + DestroyImage(img); + return __ERROR; + } + img->client_data = data; if (matte >= 0) img->matte = (unsigned)matte; return mkobj(type(Image), img); *************** *** 1615,1636 **** GetImageInfo(&image_info); GetMontageInfo(&image_info, &montage_info0); - - #if 0 - montage_info0.title = "Test"; - montage_info0.tile = "4x3"; - montage_info0.geometry = "128x128+10+10"; - montage_info0.frame = "15x15+3+3"; - montage_info0.border_width = 10; - montage_info0.shadow = 1; - //montage_info0.texture = "granite:"; - montage_info0.font = "-adobe-helvetica-*-r-*-*-18-*-*-*-*-*-*-*"; - montage_info0.pointsize = 18.0; - QueryColorDatabase("white", &montage_info0.background_color, &exception); - QueryColorDatabase("red", &montage_info0.border_color, &exception); - QueryColorDatabase("green", &montage_info0.matte_color, &exception); - //QueryColorDatabase("white", &montage_info0.stroke, &exception); - QueryColorDatabase("black", &montage_info0.fill, &exception); - #endif - montage_init = 1; } --- 1664,1667 ---- |
From: <ag...@us...> - 2003-12-30 12:00:26
|
Update of /cvsroot/q-lang/q/modules/magick In directory sc8-pr-cvs1:/tmp/cvs-serv18005 Modified Files: magick.c magick.q Log Message: added image_fuzz, set_image_fuzz functions Index: magick.c =================================================================== RCS file: /cvsroot/q-lang/q/modules/magick/magick.c,v retrieving revision 1.25 retrieving revision 1.26 diff -C2 -d -r1.25 -r1.26 *** magick.c 30 Dec 2003 05:32:20 -0000 1.25 --- magick.c 30 Dec 2003 12:00:22 -0000 1.26 *************** *** 498,501 **** --- 498,543 ---- } + FUNCTION(magick,image_compression,argc,argv) + { + Image *img; + if (argc == 1 && isobj(argv[0], type(Image), (void**)&img)) + return mkuint(img->compression); + else + return __FAIL; + } + + FUNCTION(magick,set_image_compression,argc,argv) + { + Image *img; + unsigned long compression; + if (argc == 2 && isobj(argv[0], type(Image), (void**)&img) && + isuint(argv[1], &compression)) { + img->compression = compression; + return mkvoid; + } else + return __FAIL; + } + + FUNCTION(magick,image_fuzz,argc,argv) + { + Image *img; + if (argc == 1 && isobj(argv[0], type(Image), (void**)&img)) + return mkint(img->fuzz); + else + return __FAIL; + } + + FUNCTION(magick,set_image_fuzz,argc,argv) + { + Image *img; + long fuzz; + if (argc == 2 && isobj(argv[0], type(Image), (void**)&img) && + isint(argv[1], &fuzz)) { + img->fuzz = fuzz; + return mkvoid; + } else + return __FAIL; + } + FUNCTION(magick,image_page,argc,argv) { *************** *** 534,558 **** else return __FAIL; - return mkvoid; - } else - return __FAIL; - } - - FUNCTION(magick,image_compression,argc,argv) - { - Image *img; - if (argc == 1 && isobj(argv[0], type(Image), (void**)&img)) - return mkuint(img->compression); - else - return __FAIL; - } - - FUNCTION(magick,set_image_compression,argc,argv) - { - Image *img; - unsigned long compression; - if (argc == 2 && isobj(argv[0], type(Image), (void**)&img) && - isuint(argv[1], &compression)) { - img->compression = compression; return mkvoid; } else --- 576,579 ---- Index: magick.q =================================================================== RCS file: /cvsroot/q-lang/q/modules/magick/magick.q,v retrieving revision 1.24 retrieving revision 1.25 diff -C2 -d -r1.24 -r1.25 *** magick.q 30 Dec 2003 05:43:48 -0000 1.24 --- magick.q 30 Dec 2003 12:00:22 -0000 1.25 *************** *** 195,205 **** /* Some secondary image properties can be retrieved and changed with the ! following operations. */ public extern image_background_color IMG, set_image_background_color IMG PIXEL; public extern image_border_color IMG, set_image_border_color IMG PIXEL; public extern image_matte_color IMG, set_image_matte_color IMG PIXEL; ! public extern image_page IMG, set_image_page IMG PAGE; public extern image_compression IMG, set_image_compression IMG COMPRESSION; /* The following operations let you retrieve and change attributes (string --- 195,231 ---- /* 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 ! and matte colors, specified as RGBA pixel values. ! ! - compression: The image's compression method, used as the default method ! when writing the image. This can be any of the compression type values ! defined in the manifest constants section at the beginning of this ! module. ! ! - fuzz: This integer value is used to match pixels in various operations, ! such as the flood_fill functions. The default value is zero, meaning that ! colors only match if they are identical. You can set this value to a ! positive number to increase the range of colors which match a given pixel ! value. ! ! - page: The equivalent PostScript page size of the image, specified as a ! quadrupel (X,Y,W,H), where (X,Y) denotes the page offset and (W,H) its ! dimension. This information is used when saving the image in PostScript ! format (in which case the coordinates are interpreted in PostScript ! coordinate space). The (X,Y) coordinates are also used by various image ! manipulation routines which combine images, such as flatten and mosaic ! (in this case the coordinates are in pixels). When setting this value, ! you can either specify the entire quadrupel, or only the (X,Y) values; in ! the latter case only the offset values are changed. */ public extern image_background_color IMG, set_image_background_color IMG PIXEL; public extern image_border_color IMG, set_image_border_color IMG PIXEL; public extern image_matte_color IMG, set_image_matte_color IMG PIXEL; ! public extern image_compression IMG, set_image_compression IMG COMPRESSION; + public extern image_fuzz IMG, set_image_fuzz IMG FUZZ; + public extern image_page IMG, set_image_page IMG PAGE; /* The following operations let you retrieve and change attributes (string |
From: <ag...@us...> - 2003-12-30 05:43:51
|
Update of /cvsroot/q-lang/q In directory sc8-pr-cvs1:/tmp/cvs-serv31372 Modified Files: ChangeLog Log Message: typo fix, ChangeLog updated Index: ChangeLog =================================================================== RCS file: /cvsroot/q-lang/q/ChangeLog,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** ChangeLog 26 Dec 2003 03:11:55 -0000 1.10 --- ChangeLog 30 Dec 2003 05:43:48 -0000 1.11 *************** *** 1,3 **** --- 1,15 ---- + 2003-12-30 Albert Graef <Dr....@t-...> + + * magick: finished basic image manipulation functions, code + cleanup, bug fixes + + 2003-12-28 Albert Graef <Dr....@t-...> + + * magick: new resource management functions, started work on image + manipulation operations + 2003-12-26 Albert Graef <Dr....@t-...> + + * magick: new magick_info and ping_image operations * magick: read_image and write_image now fully support multi-frame |
From: <ag...@us...> - 2003-12-30 05:43:51
|
Update of /cvsroot/q-lang/q/modules/magick In directory sc8-pr-cvs1:/tmp/cvs-serv31372/modules/magick Modified Files: magick.q Log Message: typo fix, ChangeLog updated Index: magick.q =================================================================== RCS file: /cvsroot/q-lang/q/modules/magick/magick.q,v retrieving revision 1.23 retrieving revision 1.24 diff -C2 -d -r1.23 -r1.24 *** magick.q 30 Dec 2003 05:32:20 -0000 1.23 --- magick.q 30 Dec 2003 05:43:48 -0000 1.24 *************** *** 400,404 **** - BACK, FORE, MATTE: pixel values used for the image's background, ! foreground and frames All fields are optional, but must be specified in the given order. --- 400,404 ---- - BACK, FORE, MATTE: pixel values used for the image's background, ! foreground and frames, respectively All fields are optional, but must be specified in the given order. |
From: <ag...@us...> - 2003-12-30 05:32:23
|
Update of /cvsroot/q-lang/q/modules/magick In directory sc8-pr-cvs1:/tmp/cvs-serv30303 Modified Files: magick.c magick.q Log Message: added image_attr, set_image_attr, montage Index: magick.c =================================================================== RCS file: /cvsroot/q-lang/q/modules/magick/magick.c,v retrieving revision 1.24 retrieving revision 1.25 diff -C2 -d -r1.24 -r1.25 *** magick.c 29 Dec 2003 20:31:36 -0000 1.24 --- magick.c 30 Dec 2003 05:32:20 -0000 1.25 *************** *** 560,563 **** --- 560,591 ---- } + FUNCTION(magick,image_attr,argc,argv) + { + Image *img; + char *key; + if (argc == 2 && isobj(argv[0], type(Image), (void**)&img) && + isstr(argv[1], &key)) { + const ImageAttribute *attr = GetImageAttribute(img, key); + if (attr) + return mkstr(strdup(attr->value)); + else + return __FAIL; + } else + return __FAIL; + } + + FUNCTION(magick,set_image_attr,argc,argv) + { + Image *img; + char *key, *val = NULL; + if (argc == 3 && isobj(argv[0], type(Image), (void**)&img) && + isstr(argv[1], &key) && + (isvoid(argv[2]) || isstr(argv[2], &val))) { + SetImageAttribute(img, key, val); + return mkvoid; + } else + return __FAIL; + } + FUNCTION(magick,count_image_colors,argc,argv) { *************** *** 785,788 **** --- 813,817 ---- while (x && imgs) { Image *tmp = imgs->previous; + imgs->scene = 0; imgs->client_data = 0; x = mkcons(mkobj(type(Image), imgs), x); *************** *** 1471,1474 **** --- 1500,1638 ---- } + FUNCTION(magick,mosaic,argc,argv) + { + Image *imgs; + if (argc == 1 && is_image_list(argv[0], &imgs) && imgs) { + Image *img = MosaicImages(imgs, &exception); + decompose_image_list(imgs); + if (check_exception(&exception)) + return mkapp(mksym(sym(magick_error)), mkstr(strdup(msg))); + else if (!img) + return __FAIL; + else + return mkobj(type(Image), img); + } else + return __FAIL; + } + + /* info structure used by montage */ + + static int parse_montage_info(int n, expr *xv, MontageInfo *info) + { + int i = 0, b; + unsigned long u; + double f; + char *s; + bstr_t *m; + + if (i >= n) return 1; + s = NULL; + if (!isvoid(xv[i]) && !isstr(xv[i], &s)) return 0; + if (s) info->title = s; + i++; + if (i >= n) return 1; + s = NULL; + if (!isvoid(xv[i]) && !isstr(xv[i], &s)) return 0; + if (s) info->tile = s; + i++; + if (i >= n) return 1; + s = NULL; + if (!isvoid(xv[i]) && !isstr(xv[i], &s)) return 0; + if (s) info->geometry = s; + i++; + if (i >= n) return 1; + s = NULL; + if (!isvoid(xv[i]) && !isstr(xv[i], &s)) return 0; + if (s) info->frame = s; + i++; + if (i >= n) return 1; + if (!isuint(xv[i++], &u)) return 0; + if (u > 0) info->border_width = u; + if (i >= n) return 1; + if (!isbool(xv[i++], &b)) return 0; + info->shadow = b; + if (i >= n) return 1; + s = NULL; + if (!isvoid(xv[i]) && !isstr(xv[i], &s)) return 0; + if (s) info->texture = s; + i++; + if (i >= n) return 1; + s = NULL; + if (!isvoid(xv[i]) && !isstr(xv[i], &s)) return 0; + if (s) info->font = s; + i++; + if (i >= n) return 1; + if (!isfloat(xv[i], &f) && !ismpz_float(xv[i], &f)) return 0; + if (f > 0.0) info->pointsize = f; + i++; + if (i >= n) return 1; + if (!isobj(xv[i++], type(ByteStr), (void**)&m) || m->size != 8) return 0; + set_pixels(&info->background_color, m->v, 1, 1); + if (i >= n) return 1; + if (!isobj(xv[i++], type(ByteStr), (void**)&m) || m->size != 8) return 0; + set_pixels(&info->fill, m->v, 1, 1); + if (i >= n) return 1; + if (!isobj(xv[i++], type(ByteStr), (void**)&m) || m->size != 8) return 0; + set_pixels(&info->matte_color, m->v, 1, 1); + if (i >= n) return 1; + return 0; + } + + FUNCTION(magick,montage,argc,argv) + { + static int montage_init = 0; + static MontageInfo montage_info0; + Image *imgs; + if (argc == 2 && is_image_list(argv[0], &imgs) && imgs) { + Image *img, *next; + MontageInfo montage_info; + int n; + expr *xv; + if (!montage_init) { + /* this is only initialized once */ + ImageInfo image_info; + GetImageInfo(&image_info); + GetMontageInfo(&image_info, &montage_info0); + + #if 0 + montage_info0.title = "Test"; + montage_info0.tile = "4x3"; + montage_info0.geometry = "128x128+10+10"; + montage_info0.frame = "15x15+3+3"; + montage_info0.border_width = 10; + montage_info0.shadow = 1; + //montage_info0.texture = "granite:"; + montage_info0.font = "-adobe-helvetica-*-r-*-*-18-*-*-*-*-*-*-*"; + montage_info0.pointsize = 18.0; + QueryColorDatabase("white", &montage_info0.background_color, &exception); + QueryColorDatabase("red", &montage_info0.border_color, &exception); + QueryColorDatabase("green", &montage_info0.matte_color, &exception); + //QueryColorDatabase("white", &montage_info0.stroke, &exception); + QueryColorDatabase("black", &montage_info0.fill, &exception); + #endif + + montage_init = 1; + } + montage_info = montage_info0; + if (!istuple(argv[1], &n, &xv)) { + n = 1; + xv = argv+1; + } + if (!parse_montage_info(n, xv, &montage_info)) + return __FAIL; + img = MontageImages(imgs, &montage_info, &exception); + decompose_image_list(imgs); + if (check_exception(&exception)) + return mkapp(mksym(sym(magick_error)), mkstr(strdup(msg))); + else if (!img) + return __FAIL; + else if (img->next) + return mk_image_list(img); + else + return mkobj(type(Image), img); + } else + return __FAIL; + } + FUNCTION(magick,deconstruct,argc,argv) { *************** *** 1922,1927 **** isstr(argv[1], &val) && isobj(argv[2], type(ByteStr), (void**)&m) && m->size == 8) { ! PixelPacket *pixel = (PixelPacket*)m->v; ! img = ColorizeImage(img, val, *pixel, &exception); if (check_exception(&exception)) return mkapp(mksym(sym(magick_error)), mkstr(strdup(msg))); --- 2086,2092 ---- isstr(argv[1], &val) && isobj(argv[2], type(ByteStr), (void**)&m) && m->size == 8) { ! PixelPacket pixel; ! set_pixels(&pixel, m->v, 1, 1); ! img = ColorizeImage(img, val, pixel, &exception); if (check_exception(&exception)) return mkapp(mksym(sym(magick_error)), mkstr(strdup(msg))); Index: magick.q =================================================================== RCS file: /cvsroot/q-lang/q/modules/magick/magick.q,v retrieving revision 1.22 retrieving revision 1.23 diff -C2 -d -r1.22 -r1.23 *** magick.q 29 Dec 2003 20:31:36 -0000 1.22 --- magick.q 30 Dec 2003 05:32:20 -0000 1.23 *************** *** 23,28 **** 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. Some of the ! more advanced image manipulation routines still need to be done. */ import clib; --- 23,28 ---- 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; *************** *** 194,198 **** image_magick IMG = M where (W,H,O,D,A,M) = image_info IMG; ! /* Some secondary image attributes can be retrieved and changed with the following operations. */ --- 194,198 ---- 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. */ *************** *** 203,206 **** --- 203,214 ---- public extern image_compression IMG, set_image_compression IMG COMPRESSION; + /* 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; + /* Retrieve various other useful information about an image. The count_image_ colors function determines the number of unique colors in an image. The *************** *** 360,368 **** /* Combining and deconstructing images. */ ! public extern coalesce IMGS, flatten IMGS, deconstruct IMGS; public extern composite IMG OP IMG2 P; // BANG! public extern segment IMG COLORSPACE VERBOSE CLUSTER SMOOTH; // BANG! ! // TODO: montage /* Image enhancement. */ --- 368,415 ---- /* Combining and deconstructing images. */ ! public extern coalesce IMGS, flatten IMGS, mosaic IMGS; ! public extern deconstruct IMGS; public extern composite IMG OP IMG2 P; // BANG! public extern segment IMG COLORSPACE VERBOSE CLUSTER SMOOTH; // BANG! ! /* The montage function creates a montage of thumbnail images. The following ! parameters are set via the INFO tuple (see also montage(1) for a closer ! description of the various options): ! ! - TITLE: the title of the image, as a string, () for none ! ! - TILE: the layout of the tiles, e.g.: "4x3", () for default ! ! - GEOMETRY: the geometry of the tiles, e.g.: "128x128+10+10", () for ! default ! ! - FRAME: the geometry of the 3D frame to place around the tiles, () if no ! frame is desired; e.g.: "15x15+3+3" ! ! - BORDERWIDTH: the size of a border to draw around each tile (an integer); ! this is only active if no frame is specified ! ! - SHADOW: true or false, determines whether an additional shadow is drawn ! behind each tile ! ! - TEXTURE: a background texture such as "granite:", () if none ! ! - FONT: the font to be used for the title and tile labels, () if none ! ! - POINTSIZE: the font size (integer or floating point number) ! ! - BACK, FORE, MATTE: pixel values used for the image's background, ! foreground and frames ! ! All fields are optional, but must be specified in the given order. ! ImageMagick defaults are used for omitted values. You can also specify just ! the title string, or leave all fields empty by specifying () for the INFO ! tuple. ! ! Note that this operation may also return a list of images, if the tiles do ! not fit all on one page. Also note that to get labels on the images, you ! have to set them first with the set_image_attr function. */ ! ! public extern montage IMGS INFO; /* Image enhancement. */ |
From: <ag...@us...> - 2003-12-29 20:31:40
|
Update of /cvsroot/q-lang/q/modules/magick In directory sc8-pr-cvs1:/tmp/cvs-serv4183 Modified Files: magick.c magick.q Log Message: added compression options to write_image/image_to_blob, new image attribute ops Index: magick.c =================================================================== RCS file: /cvsroot/q-lang/q/modules/magick/magick.c,v retrieving revision 1.23 retrieving revision 1.24 diff -C2 -d -r1.23 -r1.24 *** magick.c 29 Dec 2003 13:08:32 -0000 1.23 --- magick.c 29 Dec 2003 20:31:36 -0000 1.24 *************** *** 137,141 **** if (argc != 0) return __FAIL; return mktuplel ! (52, mkuint(PointFilter), mkuint(BoxFilter), --- 137,151 ---- if (argc != 0) return __FAIL; return mktuplel ! (61, ! mkuint(NoCompression), ! mkuint(BZipCompression), ! mkuint(FaxCompression), ! mkuint(Group4Compression), ! mkuint(JPEGCompression), ! mkuint(LosslessJPEGCompression), ! mkuint(LZWCompression), ! mkuint(RLECompression), ! mkuint(ZipCompression), ! mkuint(PointFilter), mkuint(BoxFilter), *************** *** 375,378 **** --- 385,408 ---- } + /* compression info used by write_image and image_to_blob */ + + static int parse_info2(int n, expr *xv, ImageInfo *info) + { + int i = 0; + unsigned long compression, quality; + char *sampling_factor; + if (i >= n) return 1; + if (!isuint(xv[i++], &compression)) return 0; + info->compression = compression; + if (i >= n) return 1; + if (!isuint(xv[i++], &quality)) return 0; + info->quality = quality; + if (i >= n) return 1; + if (!isstr(xv[i++], &sampling_factor)) return 0; + info->sampling_factor = sampling_factor; + if (i >= n) return 1; + return 0; + } + FUNCTION(magick,image_info,argc,argv) { *************** *** 468,471 **** --- 498,563 ---- } + FUNCTION(magick,image_page,argc,argv) + { + Image *img; + if (argc == 1 && isobj(argv[0], type(Image), (void**)&img)) + return mktuplel(4, mkint(img->page.x), mkint(img->page.y), + mkuint(img->page.width), mkuint(img->page.height)); + else + return __FAIL; + } + + FUNCTION(magick,set_image_page,argc,argv) + { + Image *img; + int n; + expr *xv; + long x, y; + unsigned long w, h; + if (argc == 2 && isobj(argv[0], type(Image), (void**)&img) && + istuple(argv[1], &n, &xv)) { + if (n == 2) + if (isint(xv[0], &x) && isint(xv[1], &y)) { + img->page.x = x; + img->page.y = y; + } else + return __FAIL; + else if (n == 4) + if (isint(xv[0], &x) && isint(xv[1], &y) && + isuint(xv[2], &w) && isuint(xv[3], &h)) { + img->page.x = x; + img->page.y = y; + img->page.width = w; + img->page.height = h; + } else + return __FAIL; + else + return __FAIL; + return mkvoid; + } else + return __FAIL; + } + + FUNCTION(magick,image_compression,argc,argv) + { + Image *img; + if (argc == 1 && isobj(argv[0], type(Image), (void**)&img)) + return mkuint(img->compression); + else + return __FAIL; + } + + FUNCTION(magick,set_image_compression,argc,argv) + { + Image *img; + unsigned long compression; + if (argc == 2 && isobj(argv[0], type(Image), (void**)&img) && + isuint(argv[1], &compression)) { + img->compression = compression; + return mkvoid; + } else + return __FAIL; + } + FUNCTION(magick,count_image_colors,argc,argv) { *************** *** 609,617 **** FUNCTION(magick,create_image,argc,argv) { ! expr *xv; int n = 0; bstr_t *m; unsigned long w, h; ! if (argc == 2 && istuple(argv[0], &n, &xv) && n >= 2 && n <= 5 && isuint(xv[0], &w) && isuint(xv[1], &h) && w > 0 && h > 0 && isobj(argv[1], type(ByteStr), (void**)&m)) { --- 701,709 ---- FUNCTION(magick,create_image,argc,argv) { ! expr *xv = NULL; int n = 0; bstr_t *m; unsigned long w, h; ! if (argc == 2 && istuple(argv[0], &n, &xv) && n >= 2 && isuint(xv[0], &w) && isuint(xv[1], &h) && w > 0 && h > 0 && isobj(argv[1], type(ByteStr), (void**)&m)) { *************** *** 707,715 **** { char *s; ! expr *xv; int n = 0; if (argc == 2 && isstr(argv[0], &s) && ! (istuple(argv[1], &n, &xv) || isvoid(argv[1])) && ! n <= 5) { ImageInfo info; Image *img; --- 799,806 ---- { char *s; ! expr *xv = NULL; int n = 0; if (argc == 2 && isstr(argv[0], &s) && ! (istuple(argv[1], &n, &xv) || isvoid(argv[1]))) { ImageInfo info; Image *img; *************** *** 741,749 **** { char *s; ! expr *xv; int n = 0; if (argc == 2 && isstr(argv[0], &s) && ! (istuple(argv[1], &n, &xv) || isvoid(argv[1])) && ! n <= 5) { ImageInfo info; Image *img; --- 832,839 ---- { char *s; ! expr *xv = NULL; int n = 0; if (argc == 2 && isstr(argv[0], &s) && ! (istuple(argv[1], &n, &xv) || isvoid(argv[1]))) { ImageInfo info; Image *img; *************** *** 809,813 **** { char *s; ! if (argc == 2 && isstr(argv[0], &s)) { Image *img = NULL; ImageInfo info; --- 899,905 ---- { char *s; ! expr *xv = NULL; ! int n = 0; ! if (argc == 3 && isstr(argv[0], &s)) { Image *img = NULL; ImageInfo info; *************** *** 816,819 **** --- 908,917 ---- return __FAIL; GetImageInfo(&info); + if (!isvoid(argv[2]) && !istuple(argv[2], &n, &xv)) { + xv = argv+2; + n = 1; + } + if (!parse_info2(n, xv, &info)) + return __FAIL; if (is_image_list(argv[1], &img)) { res = WriteImages(&info, img, s, &exception); *************** *** 842,846 **** char *s = NULL; Image *img; ! if (argc == 2 && (isobj(argv[1], type(Image), (void**)&img) || is_image_list(argv[1], &img)) && --- 940,946 ---- char *s = NULL; Image *img; ! expr *xv; ! int n = 0; ! if (argc == 3 && (isobj(argv[1], type(Image), (void**)&img) || is_image_list(argv[1], &img)) && *************** *** 853,856 **** --- 953,962 ---- char magick[MaxTextExtent]; GetImageInfo(&info); + if (!isvoid(argv[2]) && !istuple(argv[2], &n, &xv)) { + xv = argv+2; + n = 1; + } + if (!parse_info2(n, xv, &info)) + return __FAIL; if (s) { strncpy(magick, img->magick, MaxTextExtent-1); *************** *** 880,889 **** { bstr_t *m; ! expr *xv; int n = 0; if (argc == 2 && isobj(argv[0], type(ByteStr), (void**)&m) && m->size > 0 && ! (istuple(argv[1], &n, &xv) || isvoid(argv[1])) && ! n <= 5) { ImageInfo info; Image *img; --- 986,994 ---- { bstr_t *m; ! expr *xv = NULL; int n = 0; if (argc == 2 && isobj(argv[0], type(ByteStr), (void**)&m) && m->size > 0 && ! (istuple(argv[1], &n, &xv) || isvoid(argv[1]))) { ImageInfo info; Image *img; *************** *** 1168,1172 **** isuint(xv[0], &w) && isuint(xv[1], &h) && isuint(argv[2], &filter) && - filter != UndefinedFilter && filter <= SincFilter && (isfloat(argv[3], &blur) || ismpz_float(argv[3], &blur))) { img = ResizeImage(img, w, h, filter, blur, &exception); --- 1273,1276 ---- *************** *** 1413,1417 **** if (argc == 4 && isobj(argv[0], type(Image), (void**)&img) && isuint(argv[1], &op) && - op != UndefinedCompositeOp && op <= OverlayCompositeOp && isobj(argv[2], type(Image), (void**)&img2) && istuple(argv[3], &n, &xv) && --- 1517,1520 ---- *************** *** 1539,1543 **** unsigned long noise; if (argc == 2 && isobj(argv[0], type(Image), (void**)&img) && ! isuint(argv[1], &noise) && noise <= PoissonNoise) { img = AddNoiseImage(img, noise, &exception); if (check_exception(&exception)) --- 1642,1646 ---- unsigned long noise; if (argc == 2 && isobj(argv[0], type(Image), (void**)&img) && ! isuint(argv[1], &noise)) { img = AddNoiseImage(img, noise, &exception); if (check_exception(&exception)) Index: magick.q =================================================================== RCS file: /cvsroot/q-lang/q/modules/magick/magick.q,v retrieving revision 1.21 retrieving revision 1.22 diff -C2 -d -r1.21 -r1.22 *** magick.q 29 Dec 2003 13:08:32 -0000 1.21 --- magick.q 29 Dec 2003 20:31:36 -0000 1.22 *************** *** 36,40 **** --- 36,47 ---- def GRAY = 0, RGB = 1; + /* This is used to indicate the default value for various options. */ + public var const DEFAULT; + def DEFAULT = 0; + public var const + /* Compression types for the write_image and image_to_blob functions. */ + NONE, BZIP, FAX, GROUP4, JPEG, LOSSLESS, LZW, RLE, ZIP, + /* Filter types for the resize function. */ POINT_FILTER, BOX_FILTER, TRIANGLE_FILTER, HERMITE_FILTER, *************** *** 55,59 **** private extern magick_vars; ! def (POINT_FILTER, BOX_FILTER, TRIANGLE_FILTER, HERMITE_FILTER, HANNING_FILTER, HAMMING_FILTER, BLACKMAN_FILTER, GAUSSIAN_FILTER, QUADRATIC_FILTER, CUBIC_FILTER, CATROM_FILTER, MITCHELL_FILTER, --- 62,68 ---- private extern magick_vars; ! def (NONE, BZIP, FAX, GROUP4, JPEG, LOSSLESS, LZW, RLE, ZIP, ! ! POINT_FILTER, BOX_FILTER, TRIANGLE_FILTER, HERMITE_FILTER, HANNING_FILTER, HAMMING_FILTER, BLACKMAN_FILTER, GAUSSIAN_FILTER, QUADRATIC_FILTER, CUBIC_FILTER, CATROM_FILTER, MITCHELL_FILTER, *************** *** 153,157 **** - OFFSET: A number of initial bytes to be skipped when reading an image. Usually, this is set to zero, but there are some special image ! formats (in particular: STEGANO) which use a non-zero value for this field. --- 162,166 ---- - OFFSET: A number of initial bytes to be skipped when reading an image. Usually, this is set to zero, but there are some special image ! formats (in particular: STEGANO) which may use a non-zero value for this field. *************** *** 188,200 **** following operations. */ ! public extern image_background_color IMG, ! image_border_color IMG, image_matte_color IMG; ! ! public extern set_image_background_color IMG PIXEL, ! set_image_border_color IMG PIXEL, set_image_matte_color IMG PIXEL; ! ! // TODO: We need some additional operations here to retrieve and change ! // various other image parameters, such as compression options and page ! // geometry. /* Retrieve various other useful information about an image. The count_image_ --- 197,205 ---- following operations. */ ! public extern image_background_color IMG, set_image_background_color IMG PIXEL; ! public extern image_border_color IMG, set_image_border_color IMG PIXEL; ! public extern image_matte_color IMG, set_image_matte_color IMG PIXEL; ! public extern image_page IMG, set_image_page IMG PAGE; ! public extern image_compression IMG, set_image_compression IMG COMPRESSION; /* Retrieve various other useful information about an image. The count_image_ *************** *** 258,267 **** 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 ! written, see again ImageMagick(1) for details. */ public extern read_image NAME INFO, ping_image NAME INFO; ! public extern write_image NAME IMG; /* Convert an image or image sequence to a "blob" ("binary large object", --- 263,284 ---- 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 written, see ! again ImageMagick(1) for details. ! ! The compression type and quality of write_image can optionally be indicated ! with the INFO parameter, which can be a singleton COMPRESSION value, or a ! tuple with up to 3 fields which takes the form (COMPRESSION, QUALITY, ! SAMPLING_FACTOR). COMPRESSION can be any of the compression type values ! defined in the "manifest constants" section, QUALITY is an integer (ranging ! from 0 to 100 a.k.a. "worst/fastest" to "best/slowest", with 75 being the ! default) which corresponds to ImageMagick's -quality option, and ! SAMPLING_FACTOR is a string in the same format as ImageMagick's ! -sampling-factor option, see ImageMagick(1) for details. All fields are ! optional. If no compression type is specified (COMPRESSION = 0 or INFO = ! ()) then the default compression type for the image format is used. */ public extern read_image NAME INFO, ping_image NAME INFO; ! public extern write_image NAME IMG INFO; /* Convert an image or image sequence to a "blob" ("binary large object", *************** *** 270,278 **** data. The MAGICK parameter of image_to_blob can be used to indicate the desired target format; if it is () then the format of the image is used as ! the target format. The blob_to_image function takes an INFO structure to ! specify image properties which cannot be deduced from the blob itself; this ! is necessary, e.g., if the blob is just raw RGB data. */ ! public extern image_to_blob MAGICK IMG, blob_to_image BLOB INFO; /***************************************************************************/ --- 287,297 ---- data. The MAGICK parameter of image_to_blob can be used to indicate the desired target format; if it is () then the format of the image is used as ! the target format. The INFO parameter of image_to_blob can be used to ! denote the desired compression method, and has the same format and meaning ! as with the write_image function. The blob_to_image function takes an image ! INFO structure to specify image properties which cannot be deduced from the ! blob itself; this is necessary, e.g., if the blob is just raw RGB data. */ ! public extern image_to_blob MAGICK IMG INFO, blob_to_image BLOB INFO; /***************************************************************************/ |
From: <ag...@us...> - 2003-12-29 13:08:35
|
Update of /cvsroot/q-lang/q/modules/magick In directory sc8-pr-cvs1:/tmp/cvs-serv15493 Modified Files: magick.c magick.q Log Message: fixed frame operation (missing P parameter) Index: magick.c =================================================================== RCS file: /cvsroot/q-lang/q/modules/magick/magick.c,v retrieving revision 1.22 retrieving revision 1.23 diff -C2 -d -r1.22 -r1.23 *** magick.c 29 Dec 2003 12:31:42 -0000 1.22 --- magick.c 29 Dec 2003 13:08:32 -0000 1.23 *************** *** 2020,2032 **** int n; expr *xv; unsigned long w, h; long inner, outer; ! if (argc == 3 && isobj(argv[0], type(Image), (void**)&img) && istuple(argv[1], &n, &xv) && n == 2 && ! isuint(xv[0], &w) && isuint(xv[1], &h) && istuple(argv[2], &n, &xv) && n == 2 && isint(xv[0], &inner) && isint(xv[1], &outer)) { FrameInfo frame; ! frame.x = frame.y = 0; frame.width = w; frame.height = h; frame.inner_bevel = inner; frame.outer_bevel = outer; img = FrameImage(img, &frame, &exception); --- 2020,2035 ---- int n; expr *xv; + long x, y; unsigned long w, h; long inner, outer; ! 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) && isuint(xv[1], &h) && + istuple(argv[3], &n, &xv) && n == 2 && isint(xv[0], &inner) && isint(xv[1], &outer)) { FrameInfo frame; ! frame.x = x; frame.y = y; frame.width = w; frame.height = h; frame.inner_bevel = inner; frame.outer_bevel = outer; img = FrameImage(img, &frame, &exception); Index: magick.q =================================================================== RCS file: /cvsroot/q-lang/q/modules/magick/magick.q,v retrieving revision 1.20 retrieving revision 1.21 diff -C2 -d -r1.20 -r1.21 *** magick.q 29 Dec 2003 12:31:42 -0000 1.20 --- magick.q 29 Dec 2003 13:08:32 -0000 1.21 *************** *** 389,393 **** public extern border IMG DIM; ! public extern frame IMG DIM BEVEL; public extern button IMG DIM RAISE; // BANG! --- 389,393 ---- public extern border IMG DIM; ! public extern frame IMG P DIM BEVEL; public extern button IMG DIM RAISE; // BANG! |
From: <ag...@us...> - 2003-12-29 12:31:45
|
Update of /cvsroot/q-lang/q/modules/magick In directory sc8-pr-cvs1:/tmp/cvs-serv10115 Modified Files: magick.c magick.q Log Message: added operations to get and set the background, border and matte colors of an image Index: magick.c =================================================================== RCS file: /cvsroot/q-lang/q/modules/magick/magick.c,v retrieving revision 1.21 retrieving revision 1.22 diff -C2 -d -r1.21 -r1.22 *** magick.c 29 Dec 2003 12:02:21 -0000 1.21 --- magick.c 29 Dec 2003 12:31:42 -0000 1.22 *************** *** 387,390 **** --- 387,471 ---- } + FUNCTION(magick,image_background_color,argc,argv) + { + Image *img; + if (argc == 1 && isobj(argv[0], type(Image), (void**)&img)) { + bstr_t *m; + if (!(m = malloc(sizeof(bstr_t))) || !(m->v = malloc(8))) { + if (m) free(m); return __ERROR; + } + m->size = 8; + get_pixels(m->v, &img->background_color, 1, img->matte); + return mkobj(type(ByteStr), m); + } else + return __FAIL; + } + + FUNCTION(magick,set_image_background_color,argc,argv) + { + Image *img; + bstr_t *m; + if (argc == 2 && isobj(argv[0], type(Image), (void**)&img) && + isobj(argv[1], type(ByteStr), (void**)&m) && m->size == 8) { + set_pixels(&img->background_color, m->v, 1, img->matte); + return mkvoid; + } else + return __FAIL; + } + + FUNCTION(magick,image_border_color,argc,argv) + { + Image *img; + if (argc == 1 && isobj(argv[0], type(Image), (void**)&img)) { + bstr_t *m; + if (!(m = malloc(sizeof(bstr_t))) || !(m->v = malloc(8))) { + if (m) free(m); return __ERROR; + } + m->size = 8; + get_pixels(m->v, &img->border_color, 1, img->matte); + return mkobj(type(ByteStr), m); + } else + return __FAIL; + } + + FUNCTION(magick,set_image_border_color,argc,argv) + { + Image *img; + bstr_t *m; + if (argc == 2 && isobj(argv[0], type(Image), (void**)&img) && + isobj(argv[1], type(ByteStr), (void**)&m) && m->size == 8) { + set_pixels(&img->border_color, m->v, 1, img->matte); + return mkvoid; + } else + return __FAIL; + } + + FUNCTION(magick,image_matte_color,argc,argv) + { + Image *img; + if (argc == 1 && isobj(argv[0], type(Image), (void**)&img)) { + bstr_t *m; + if (!(m = malloc(sizeof(bstr_t))) || !(m->v = malloc(8))) { + if (m) free(m); return __ERROR; + } + m->size = 8; + get_pixels(m->v, &img->matte_color, 1, img->matte); + return mkobj(type(ByteStr), m); + } else + return __FAIL; + } + + FUNCTION(magick,set_image_matte_color,argc,argv) + { + Image *img; + bstr_t *m; + if (argc == 2 && isobj(argv[0], type(Image), (void**)&img) && + isobj(argv[1], type(ByteStr), (void**)&m) && m->size == 8) { + set_pixels(&img->matte_color, m->v, 1, img->matte); + return mkvoid; + } else + return __FAIL; + } + FUNCTION(magick,count_image_colors,argc,argv) { Index: magick.q =================================================================== RCS file: /cvsroot/q-lang/q/modules/magick/magick.q,v retrieving revision 1.19 retrieving revision 1.20 diff -C2 -d -r1.19 -r1.20 *** magick.q 29 Dec 2003 12:02:21 -0000 1.19 --- magick.q 29 Dec 2003 12:31:42 -0000 1.20 *************** *** 185,191 **** image_magick IMG = M where (W,H,O,D,A,M) = image_info IMG; // TODO: We need some additional operations here to retrieve and change ! // various other image parameters, such as compression options, ! // background/border/matte color and page geometry. /* Retrieve various other useful information about an image. The count_image_ --- 185,200 ---- image_magick IMG = M where (W,H,O,D,A,M) = image_info IMG; + /* Some secondary image attributes can be retrieved and changed with the + following operations. */ + + public extern image_background_color IMG, + image_border_color IMG, image_matte_color IMG; + + public extern set_image_background_color IMG PIXEL, + set_image_border_color IMG PIXEL, set_image_matte_color IMG PIXEL; + // TODO: We need some additional operations here to retrieve and change ! // various other image parameters, such as compression options and page ! // geometry. /* Retrieve various other useful information about an image. The count_image_ |
From: <ag...@us...> - 2003-12-29 12:02:26
|
Update of /cvsroot/q-lang/q/modules/magick In directory sc8-pr-cvs1:/tmp/cvs-serv5974 Modified Files: magick.c magick.q Log Message: added offset field to info structure, code cleanup Index: magick.c =================================================================== RCS file: /cvsroot/q-lang/q/modules/magick/magick.c,v retrieving revision 1.20 retrieving revision 1.21 diff -C2 -d -r1.20 -r1.21 *** magick.c 29 Dec 2003 04:20:47 -0000 1.20 --- magick.c 29 Dec 2003 12:02:21 -0000 1.21 *************** *** 343,347 **** { int i = 0; ! unsigned long width, height, depth, matte; char *magick; static char geom[100]; --- 343,347 ---- { int i = 0; ! unsigned long width, height, depth, offset, matte; char *magick; static char geom[100]; *************** *** 356,359 **** --- 356,365 ---- } if (i >= n) return 1; + if (!isuint(xv[i++], &offset)) return 0; + if (offset > 0) { + sprintf(geom, "%ux%u+%u", width, height, offset); + info->size = geom; + } + if (i >= n) return 1; if (!isuint(xv[i++], &depth) || depth > QuantumDepth) return 0; if (depth > 0) *************** *** 369,372 **** --- 375,455 ---- } + FUNCTION(magick,image_info,argc,argv) + { + Image *img; + if (argc == 1 && isobj(argv[0], type(Image), (void**)&img)) + return mktuplel(6, mkuint(img->columns), mkuint(img->rows), + mkuint(img->offset), mkuint(img->depth), + mkuint((unsigned long)img->matte), + mkstr(strdup(img->magick))); + 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,magick_pixel,argc,argv) { *************** *** 745,825 **** return mkobj(type(Image), img); } - } else - return __FAIL; - } - - FUNCTION(magick,image_info,argc,argv) - { - Image *img; - if (argc == 1 && isobj(argv[0], type(Image), (void**)&img)) - return mktuplel(5, mkuint(img->columns), mkuint(img->rows), - mkuint(img->depth), - mkuint((unsigned long)img->matte), - mkstr(strdup(img->magick))); - 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; --- 828,831 ---- Index: magick.q =================================================================== RCS file: /cvsroot/q-lang/q/modules/magick/magick.q,v retrieving revision 1.18 retrieving revision 1.19 diff -C2 -d -r1.18 -r1.19 *** magick.q 29 Dec 2003 04:20:47 -0000 1.18 --- magick.q 29 Dec 2003 12:02:21 -0000 1.19 *************** *** 72,87 **** /***************************************************************************/ ! /* 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 --- 72,76 ---- /***************************************************************************/ ! /* General ImageMagick properties and functions. */ /* Error handling. In case of failure, some operations use the following *************** *** 145,162 **** /***************************************************************************/ ! /* 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 ! mandatory, the remaining fields will be filled with suitable defaults if ! they are omitted. The image will be created with the pixels initialized ! from the given PIXELS argument, a byte string of RGBA values representing ! either a single pixel or a pixel sequence whose length matches the ! dimensions of the image. The clone_image function creates an exact copy of the given image. This is --- 134,213 ---- /***************************************************************************/ ! /* The Image type. Objects of this type are created with the create_image, ! read_image, ping_image and blob_to_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; ! ! /* The most important attributes of an image are summarized in its INFO ! structure, a tuple of the from (WIDTH, HEIGHT, OFFSET, DEPTH, MATTE, ! MAGICK) with the following components: ! ! - WIDTH, HEIGHT: The dimensions of the image, in pixel units. ! ! - OFFSET: A number of initial bytes to be skipped when reading an ! image. Usually, this is set to zero, but there are some special image ! formats (in particular: STEGANO) which use a non-zero value for this ! field. ! ! - DEPTH: The bit depth of the image (usually 8 or 16), denotes the number ! of bits used to represent each color component or "plane" (red, green, ! blue, opacity or "alpha"). ! ! - MATTE: An integer value which is 1 if the image has an alpha channel and ! 0 otherwise. ! ! - MAGICK: A string naming one of the image formats understood by ! ImageMagick (such as EPS, GIF, RGB, etc.). ! ! INFO tuples are used to specify the properties of an image when it is ! created, and the INFO tuple of an existing image can be retrieved with the ! image_info function. */ ! ! public extern image_info IMG; ! ! /* Convenience functions to retrieve the different components of an INFO ! structure. */ ! ! public image_width IMG, image_height IMG, image_offset IMG, image_depth IMG, ! image_matte IMG, image_magick IMG; ! ! image_width IMG = W where (W,H,O,D,A,M) = image_info IMG; ! image_height IMG = H where (W,H,O,D,A,M) = image_info IMG; ! image_offset IMG = O where (W,H,O,D,A,M) = image_info IMG; ! image_depth IMG = D where (W,H,O,D,A,M) = image_info IMG; ! image_matte IMG = A where (W,H,O,D,A,M) = image_info IMG; ! image_magick IMG = M where (W,H,O,D,A,M) = image_info IMG; ! ! // TODO: We need some additional operations here to retrieve and change ! // various other image parameters, such as compression options, ! // background/border/matte color and page geometry. ! ! /* 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; ! ! /***************************************************************************/ ! ! /* Operations to create and copy images. The create_image function creates a ! new image, given its INFO tuple. Only the first two fields specifying the ! dimensions of the image are mandatory, the remaining fields will be filled ! with suitable defaults if they are omitted or zero. The image will be ! created with the pixels initialized from the given PIXELS argument, a byte ! string of RGBA values representing either a single pixel or a pixel ! sequence whose length matches the dimensions of the image. The clone_image function creates an exact copy of the given image. This is *************** *** 170,177 **** "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 videos) actually --- 221,230 ---- "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 given INFO tuple. 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. For ! STEGANO images ("watermark" images hidden in the main image, specified as ! "stegano:file") you also have to specify the offset of the stegano image in ! the file using the OFFSET field of the INFO structure. Note that some image files (such as GIF animations or MPEG videos) actually *************** *** 200,205 **** written, see again ImageMagick(1) for details. */ - // TODO: offset option for read_image; compression options for write_image - public extern read_image NAME INFO, ping_image NAME INFO; public extern write_image NAME IMG; --- 253,256 ---- *************** *** 210,217 **** data. The MAGICK parameter of image_to_blob can be used to indicate the desired target format; if it is () then the format of the image is used as ! the target format. The blob_to_image function takes an INFO structure like ! the one passed to create_image and read_image, to specify image properties ! which cannot be deduced from the blob itself; this is necessary, e.g., if ! the blob is just raw RGB data. */ public extern image_to_blob MAGICK IMG, blob_to_image BLOB INFO; --- 261,267 ---- data. The MAGICK parameter of image_to_blob can be used to indicate the desired target format; if it is () then the format of the image is used as ! the target format. The blob_to_image function takes an INFO structure to ! specify image properties which cannot be deduced from the blob itself; this ! is necessary, e.g., if the blob is just raw RGB data. */ public extern image_to_blob MAGICK IMG, blob_to_image BLOB INFO; *************** *** 219,257 **** /***************************************************************************/ - /* 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, MAGICK). */ - - 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_magick IMG; - - image_width IMG = W where (W,H,D,A,M) = image_info IMG; - image_height IMG = H where (W,H,D,A,M) = image_info IMG; - image_depth IMG = D where (W,H,D,A,M) = image_info IMG; - image_matte IMG = A where (W,H,D,A,M) = image_info IMG; - image_magick IMG = M where (W,H,D,A,M) = image_info IMG; - - // TODO: We need some operations here to retrieve and change various other - // image parameters, such as background/border/matte color and page geometry. - - /* 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 --- 269,272 ---- *************** *** 272,275 **** --- 287,294 ---- unchanged. + Most operations have the same name as in the C API (without the Image + suffix), with the following exceptions: `FlipImage' and `FlopImage' are + named `flipy' and `flipx', and `RaiseImage' is named `button'. + A note on parameters: IMG always denotes a singleton input image, IMGS an image list. Some operations also take a secondary image IMG2 as an *************** *** 284,297 **** manual. */ ! /* Quantization. The COLORSPACE parameter designates the target colorspace, ! and can be either (1) one of the constant values GRAY and RGB, or (2) a ! pair (COLORSPACE, COLORS) denoting both the colorspace and the desired ! maximum number of colors, or (3) a reference image specifying the colormap ! to be applied to the target image. In case (1) the number of colors ! defaults to 256. The DITHER flag determines whether to apply Floyd/ ! Steinberg dithering to the image. The target image IMG can also be a list ! of images which are to be mapped to the same colormap. Please note that ! this is a BANG! type operation, thus if you you want to retain the original ! images you will have to clone them first. */ public extern quantize IMG COLORSPACE DITHER; // BANG! --- 303,318 ---- manual. */ ! /* Quantization. */ ! ! /* NOTE: The COLORSPACE parameter designates the target colorspace, and can be ! either (1) one of the constant values GRAY and RGB, or (2) a pair ! (COLORSPACE, COLORS) denoting both the colorspace and the desired maximum ! number of colors, or (3) a reference image specifying the colormap to be ! applied to the target image. In case (1) the number of colors defaults to ! 256. The DITHER flag determines whether to apply Floyd/Steinberg dithering ! to the image. The target image IMG can also be a list of images which are ! to be mapped to the same colormap. Please note that this is a BANG! type ! operation, thus if you you want to retain the original images you will have ! to clone them first. */ public extern quantize IMG COLORSPACE DITHER; // BANG! *************** *** 317,325 **** // TODO: montage ! /* Image enhancement. (These are all of the BANG! type.) */ ! public extern contrast IMG SHARPEN, equalize IMG; ! public extern gamma IMG VAL, level IMG VAL, modulate IMG VAL; ! public extern negate IMG, normalize IMG; /* Effects. */ --- 338,346 ---- // TODO: montage ! /* Image enhancement. */ ! public extern contrast IMG SHARPEN, equalize IMG; // BANG! ! public extern gamma IMG VAL, level IMG VAL, modulate IMG VAL; // BANG! ! public extern negate IMG, normalize IMG; // BANG! /* Effects. */ *************** *** 351,355 **** public extern oil_paint IMG RADIUS; public extern solarize IMG THRESHOLD; // BANG! ! public extern stegano IMG IMG2 OFFS; public extern stereo IMG IMG2; public extern swirl IMG ANGLE; --- 372,376 ---- public extern oil_paint IMG RADIUS; public extern solarize IMG THRESHOLD; // BANG! ! public extern stegano IMG IMG2 OFFSET; public extern stereo IMG IMG2; public extern swirl IMG ANGLE; |
From: <ag...@us...> - 2003-12-29 04:20:51
|
Update of /cvsroot/q-lang/q/modules/magick In directory sc8-pr-cvs1:/tmp/cvs-serv5358 Modified Files: magick.c magick.q Log Message: added decoration ops Index: magick.c =================================================================== RCS file: /cvsroot/q-lang/q/modules/magick/magick.c,v retrieving revision 1.19 retrieving revision 1.20 diff -C2 -d -r1.19 -r1.20 *** magick.c 29 Dec 2003 03:35:53 -0000 1.19 --- magick.c 29 Dec 2003 04:20:47 -0000 1.20 *************** *** 1905,1906 **** --- 1905,1975 ---- return __FAIL; } + + FUNCTION(magick,border,argc,argv) + { + Image *img; + int n; + expr *xv; + unsigned long w, h; + if (argc == 2 && isobj(argv[0], type(Image), (void**)&img) && + istuple(argv[1], &n, &xv) && n == 2 && + isuint(xv[0], &w) && isuint(xv[1], &h)) { + RectangleInfo rect; + rect.x = rect.y = 0; rect.width = w; rect.height = h; + img = BorderImage(img, &rect, &exception); + if (check_exception(&exception)) + return mkapp(mksym(sym(magick_error)), mkstr(strdup(msg))); + else if (!img) + return __FAIL; + else + return mkobj(type(Image), img); + } else + return __FAIL; + } + + FUNCTION(magick,frame,argc,argv) + { + Image *img; + int n; + expr *xv; + unsigned long w, h; + long inner, outer; + if (argc == 3 && isobj(argv[0], type(Image), (void**)&img) && + istuple(argv[1], &n, &xv) && n == 2 && + isuint(xv[0], &w) && isuint(xv[1], &h) && + istuple(argv[2], &n, &xv) && n == 2 && + isint(xv[0], &inner) && isint(xv[1], &outer)) { + FrameInfo frame; + frame.x = frame.y = 0; frame.width = w; frame.height = h; + frame.inner_bevel = inner; frame.outer_bevel = outer; + img = FrameImage(img, &frame, &exception); + if (check_exception(&exception)) + return mkapp(mksym(sym(magick_error)), mkstr(strdup(msg))); + else if (!img) + return __FAIL; + else + return mkobj(type(Image), img); + } else + return __FAIL; + } + + FUNCTION(magick,button,argc,argv) + { + Image *img; + int n; + expr *xv; + unsigned long w, h; + int raise; + if (argc == 3 && isobj(argv[0], type(Image), (void**)&img) && + istuple(argv[1], &n, &xv) && n == 2 && + isuint(xv[0], &w) && isuint(xv[1], &h) && + isbool(argv[2], &raise)) { + RectangleInfo rect; + rect.x = rect.y = 0; rect.width = w; rect.height = h; + if (RaiseImage(img, &rect, raise)) + return mkvoid; + else + return __FAIL; + } else + return __FAIL; + } Index: magick.q =================================================================== RCS file: /cvsroot/q-lang/q/modules/magick/magick.q,v retrieving revision 1.17 retrieving revision 1.18 diff -C2 -d -r1.17 -r1.18 *** magick.q 29 Dec 2003 03:35:53 -0000 1.17 --- magick.q 29 Dec 2003 04:20:47 -0000 1.18 *************** *** 238,242 **** // TODO: We need some operations here to retrieve and change various other ! // image parameters, such as default background color and page geometry. /* Retrieve various other useful information about an image. The count_image_ --- 238,242 ---- // TODO: We need some operations here to retrieve and change various other ! // image parameters, such as background/border/matte color and page geometry. /* Retrieve various other useful information about an image. The count_image_ *************** *** 358,365 **** /* Decorations. */ ! // TODO ! // public extern border IMG DIM PIXEL; ! // public extern frame IMG DIM INNER OUTER PIXEL; ! // public extern button IMG DIM; // BANG! /* Annotations. */ --- 358,364 ---- /* Decorations. */ ! public extern border IMG DIM; ! public extern frame IMG DIM BEVEL; ! public extern button IMG DIM RAISE; // BANG! /* Annotations. */ |
From: <ag...@us...> - 2003-12-29 03:35:57
|
Update of /cvsroot/q-lang/q/modules/magick In directory sc8-pr-cvs1:/tmp/cvs-serv32009 Modified Files: magick.c magick.q Log Message: added filter argument to resize Index: magick.c =================================================================== RCS file: /cvsroot/q-lang/q/modules/magick/magick.c,v retrieving revision 1.18 retrieving revision 1.19 diff -C2 -d -r1.18 -r1.19 *** magick.c 29 Dec 2003 03:13:54 -0000 1.18 --- magick.c 29 Dec 2003 03:35:53 -0000 1.19 *************** *** 137,141 **** if (argc != 0) return __FAIL; return mktuplel ! (37, mkuint(OverCompositeOp), mkuint(InCompositeOp), --- 137,157 ---- if (argc != 0) return __FAIL; return mktuplel ! (52, ! mkuint(PointFilter), ! mkuint(BoxFilter), ! mkuint(TriangleFilter), ! mkuint(HermiteFilter), ! mkuint(HanningFilter), ! mkuint(HammingFilter), ! mkuint(BlackmanFilter), ! mkuint(GaussianFilter), ! mkuint(QuadraticFilter), ! mkuint(CubicFilter), ! mkuint(CatromFilter), ! mkuint(MitchellFilter), ! mkuint(LanczosFilter), ! mkuint(BesselFilter), ! mkuint(SincFilter), ! mkuint(OverCompositeOp), mkuint(InCompositeOp), *************** *** 1059,1069 **** int n; expr *xv; ! unsigned long w, h; double blur; ! if (argc == 3 && isobj(argv[0], type(Image), (void**)&img) && istuple(argv[1], &n, &xv) && n == 2 && isuint(xv[0], &w) && isuint(xv[1], &h) && ! (isfloat(argv[2], &blur) || ismpz_float(argv[2], &blur))) { ! img = ResizeImage(img, w, h, LanczosFilter, blur, &exception); if (check_exception(&exception)) return mkapp(mksym(sym(magick_error)), mkstr(strdup(msg))); --- 1075,1087 ---- int n; expr *xv; ! unsigned long w, h, filter; double blur; ! if (argc == 4 && isobj(argv[0], type(Image), (void**)&img) && istuple(argv[1], &n, &xv) && n == 2 && isuint(xv[0], &w) && isuint(xv[1], &h) && ! isuint(argv[2], &filter) && ! filter != UndefinedFilter && filter <= SincFilter && ! (isfloat(argv[3], &blur) || ismpz_float(argv[3], &blur))) { ! img = ResizeImage(img, w, h, filter, blur, &exception); if (check_exception(&exception)) return mkapp(mksym(sym(magick_error)), mkstr(strdup(msg))); Index: magick.q =================================================================== RCS file: /cvsroot/q-lang/q/modules/magick/magick.q,v retrieving revision 1.16 retrieving revision 1.17 diff -C2 -d -r1.16 -r1.17 *** magick.q 29 Dec 2003 03:13:54 -0000 1.16 --- magick.q 29 Dec 2003 03:35:53 -0000 1.17 *************** *** 37,40 **** --- 37,46 ---- public var const + /* Filter types for the resize function. */ + POINT_FILTER, BOX_FILTER, TRIANGLE_FILTER, HERMITE_FILTER, + HANNING_FILTER, HAMMING_FILTER, BLACKMAN_FILTER, GAUSSIAN_FILTER, + QUADRATIC_FILTER, CUBIC_FILTER, CATROM_FILTER, MITCHELL_FILTER, + LANCZOS_FILTER, BESSEL_FILTER, SINC_FILTER, + /* Compose operators for the composite function. */ OVER_OP, IN_OP, OUT_OP, ATOP_OP, XOR_OP, PLUS_OP, MINUS_OP, ADD_OP, *************** *** 49,57 **** private extern magick_vars; ! def (OVER_OP, IN_OP, OUT_OP, ATOP_OP, XOR_OP, PLUS_OP, MINUS_OP, ADD_OP, SUBTRACT_OP, DIFFERENCE_OP, MULTIPLY_OP, BUMPMAP_OP, COPY_OP, COPYRED_OP, COPYGREEN_OP, COPYBLUE_OP, COPYOPACITY_OP, CLEAR_OP, DISSOLVE_OP, DISPLACE_OP, MODULATE_OP, THRESHOLD_OP, NO_OP, DARKEN_OP, LIGHTEN_OP, HUE_OP, SATURATE_OP, COLORIZE_OP, LUMINIZE_OP, SCREEN_OP, OVERLAY_OP, UNIFORM_NOISE, GAUSSIAN_NOISE, MULTIPLICATIVE_GAUSSIAN_NOISE, IMPULSE_NOISE, LAPLACIAN_NOISE, POISSON_NOISE) --- 55,69 ---- private extern magick_vars; ! def (POINT_FILTER, BOX_FILTER, TRIANGLE_FILTER, HERMITE_FILTER, ! HANNING_FILTER, HAMMING_FILTER, BLACKMAN_FILTER, GAUSSIAN_FILTER, ! QUADRATIC_FILTER, CUBIC_FILTER, CATROM_FILTER, MITCHELL_FILTER, ! LANCZOS_FILTER, BESSEL_FILTER, SINC_FILTER, ! ! OVER_OP, IN_OP, OUT_OP, ATOP_OP, XOR_OP, PLUS_OP, MINUS_OP, ADD_OP, SUBTRACT_OP, DIFFERENCE_OP, MULTIPLY_OP, BUMPMAP_OP, COPY_OP, COPYRED_OP, COPYGREEN_OP, COPYBLUE_OP, COPYOPACITY_OP, CLEAR_OP, DISSOLVE_OP, DISPLACE_OP, MODULATE_OP, THRESHOLD_OP, NO_OP, DARKEN_OP, LIGHTEN_OP, HUE_OP, SATURATE_OP, COLORIZE_OP, LUMINIZE_OP, SCREEN_OP, OVERLAY_OP, + UNIFORM_NOISE, GAUSSIAN_NOISE, MULTIPLICATIVE_GAUSSIAN_NOISE, IMPULSE_NOISE, LAPLACIAN_NOISE, POISSON_NOISE) *************** *** 287,299 **** /* Resizing, scaling and transformations. */ ! public extern chop IMG P DIM, crop IMG P DIM, roll IMG P, shave IMG DIM; ! ! // TODO: add filter type argument to resize operation public extern magnify IMG, minify IMG; ! public extern resize IMG DIM BLUR, sample IMG DIM, scale IMG DIM; public extern thumbnail IMG DIM; ! public extern flipx IMG, flipy IMG; public extern rotate IMG ANGLE, shear IMG SHEAR_ANGLES; public extern affine_transform IMG MATRIX P; --- 299,309 ---- /* Resizing, scaling and transformations. */ ! public extern chop IMG P DIM, crop IMG P DIM, shave IMG DIM; public extern magnify IMG, minify IMG; ! public extern resize IMG DIM FILTER BLUR, sample IMG DIM, scale IMG DIM; public extern thumbnail IMG DIM; ! public extern flipx IMG, flipy IMG, roll IMG P; public extern rotate IMG ANGLE, shear IMG SHEAR_ANGLES; public extern affine_transform IMG MATRIX P; |
From: <ag...@us...> - 2003-12-29 03:17:56
|
Update of /cvsroot/q-lang/q/modules/magick In directory sc8-pr-cvs1:/tmp/cvs-serv29862 Modified Files: README-Magick Log Message: updated README Index: README-Magick =================================================================== RCS file: /cvsroot/q-lang/q/modules/magick/README-Magick,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** README-Magick 26 Dec 2003 03:10:48 -0000 1.3 --- README-Magick 29 Dec 2003 03:17:53 -0000 1.4 *************** *** 12,19 **** 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.) and support for the advanced image ! manipulation operations provided by libMagick. The module requires that you have ImageMagick installed, which should be --- 12,18 ---- 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 *************** *** 31,35 **** Enjoy! :) ! Dec 26 2003 Albert Graef ag...@mu..., Dr....@t-... --- 30,34 ---- Enjoy! :) ! Dec 29 2003 Albert Graef ag...@mu..., Dr....@t-... |
From: <ag...@us...> - 2003-12-29 03:13:57
|
Update of /cvsroot/q-lang/q/modules/magick In directory sc8-pr-cvs1:/tmp/cvs-serv29392 Modified Files: magick.c magick.q Log Message: added special effect ops, code cleanup, bug fixes Index: magick.c =================================================================== RCS file: /cvsroot/q-lang/q/modules/magick/magick.c,v retrieving revision 1.17 retrieving revision 1.18 diff -C2 -d -r1.17 -r1.18 *** magick.c 28 Dec 2003 23:36:09 -0000 1.17 --- magick.c 29 Dec 2003 03:13:54 -0000 1.18 *************** *** 495,498 **** --- 495,503 ---- tmp2 = tmp->next; tmp->previous = tmp->next = NULL; + if ((int)tmp->client_data == 2) + /* dispose temporary */ + DestroyImage(tmp); + else + tmp->client_data = 0; } } *************** *** 508,511 **** --- 513,517 ---- while (x && imgs) { Image *tmp = imgs->previous; + imgs->client_data = 0; x = mkcons(mkobj(type(Image), imgs), x); imgs = tmp; *************** *** 600,603 **** --- 606,619 ---- for (y = x; iscons(y, &hd, &tl); y = tl) { isobj(hd, type(Image), (void**)&tmp); + if (tmp->client_data) { + /* we got a cycle here, clone the current image */ + tmp = CloneImage(tmp, 0, 0, 1, &exception); + if (check_exception(&exception)) { + decompose_image_list(*img); + return 0; + } + tmp->client_data = (void*)2; + } else + tmp->client_data = (void*)1; if (tmp2) { tmp->previous = tmp2; *************** *** 1640,1644 **** { Image *img; ! char *val = NULL; if (argc == 2 && isobj(argv[0], type(Image), (void**)&img) && isstr(argv[1], &val)) { --- 1656,1660 ---- { Image *img; ! char *val; if (argc == 2 && isobj(argv[0], type(Image), (void**)&img) && isstr(argv[1], &val)) { *************** *** 1662,1665 **** --- 1678,1881 ---- (isfloat(argv[3], &threshold) || ismpz_float(argv[3], &threshold))) { img = UnsharpMaskImage(img, radius, sigma, amount, threshold, &exception); + if (check_exception(&exception)) + return mkapp(mksym(sym(magick_error)), mkstr(strdup(msg))); + else if (!img) + return __FAIL; + else + return mkobj(type(Image), img); + } else + return __FAIL; + } + + FUNCTION(magick,charcoal,argc,argv) + { + Image *img; + double radius, sigma; + if (argc == 3 && isobj(argv[0], type(Image), (void**)&img) && + (isfloat(argv[1], &radius) || ismpz_float(argv[1], &radius)) && + (isfloat(argv[2], &sigma) || ismpz_float(argv[2], &sigma))) { + img = CharcoalImage(img, radius, sigma, &exception); + if (check_exception(&exception)) + return mkapp(mksym(sym(magick_error)), mkstr(strdup(msg))); + else if (!img) + return __FAIL; + else + return mkobj(type(Image), img); + } else + return __FAIL; + } + + FUNCTION(magick,colorize,argc,argv) + { + Image *img; + char *val; + bstr_t *m; + if (argc == 3 && isobj(argv[0], type(Image), (void**)&img) && + isstr(argv[1], &val) && + isobj(argv[2], type(ByteStr), (void**)&m) && m->size == 8) { + PixelPacket *pixel = (PixelPacket*)m->v; + img = ColorizeImage(img, val, *pixel, &exception); + if (check_exception(&exception)) + return mkapp(mksym(sym(magick_error)), mkstr(strdup(msg))); + else if (!img) + return __FAIL; + else + return mkobj(type(Image), img); + } else + return __FAIL; + } + + FUNCTION(magick,convolve,argc,argv) + { + Image *img; + int n; + expr *xv; + if (argc == 2 && isobj(argv[0], type(Image), (void**)&img) && + istuple(argv[1], &n, &xv) && n > 0) { + int order = (int)sqrt(n), i; + double *kernel; + if (order*order != n) return __FAIL; + if (!(kernel = malloc(n*sizeof(double)))) return __ERROR; + for (i = 0; i < n; i++) + if (!isfloat(xv[i], kernel+i) && !ismpz_float(xv[i], kernel+i)) { + free(kernel); + return __FAIL; + } + img = ConvolveImage(img, order, kernel, &exception); + free(kernel); + if (check_exception(&exception)) + return mkapp(mksym(sym(magick_error)), mkstr(strdup(msg))); + else if (!img) + return __FAIL; + else + return mkobj(type(Image), img); + } else + return __FAIL; + } + + FUNCTION(magick,implode,argc,argv) + { + Image *img; + double amount; + if (argc == 2 && isobj(argv[0], type(Image), (void**)&img) && + (isfloat(argv[1], &amount) || ismpz_float(argv[1], &amount))) { + img = ImplodeImage(img, amount, &exception); + if (check_exception(&exception)) + return mkapp(mksym(sym(magick_error)), mkstr(strdup(msg))); + else if (!img) + return __FAIL; + else + return mkobj(type(Image), img); + } else + return __FAIL; + } + + FUNCTION(magick,morph,argc,argv) + { + Image *imgs, *imgs2; + unsigned long frames; + if (argc == 2 && is_image_list(argv[0], &imgs) && imgs && + isuint(argv[1], &frames)) { + imgs2 = MorphImages(imgs, frames, &exception); + decompose_image_list(imgs); + if (check_exception(&exception)) + return mkapp(mksym(sym(magick_error)), mkstr(strdup(msg))); + else if (!imgs2) + return __FAIL; + else + return mk_image_list(imgs2); + } else + return __FAIL; + } + + FUNCTION(magick,oil_paint,argc,argv) + { + Image *img; + double radius; + if (argc == 2 && isobj(argv[0], type(Image), (void**)&img) && + (isfloat(argv[1], &radius) || ismpz_float(argv[1], &radius))) { + img = OilPaintImage(img, radius, &exception); + if (check_exception(&exception)) + return mkapp(mksym(sym(magick_error)), mkstr(strdup(msg))); + else if (!img) + return __FAIL; + else + return mkobj(type(Image), img); + } else + return __FAIL; + } + + FUNCTION(magick,solarize,argc,argv) + { + Image *img; + double threshold; + if (argc == 2 && isobj(argv[0], type(Image), (void**)&img) && + ismpz_float(argv[1], &threshold)) { + SolarizeImage(img, threshold); + return mkvoid; + } else + return __FAIL; + } + + FUNCTION(magick,stegano,argc,argv) + { + Image *img, *img2; + long offset; + if (argc == 3 && isobj(argv[0], type(Image), (void**)&img) && + isobj(argv[1], type(Image), (void**)&img2) && + isint(argv[2], &offset)) { + img->offset = offset; + img = SteganoImage(img, img2, &exception); + if (check_exception(&exception)) + return mkapp(mksym(sym(magick_error)), mkstr(strdup(msg))); + else if (!img) + return __FAIL; + else + return mkobj(type(Image), img); + } else + return __FAIL; + } + + FUNCTION(magick,stereo,argc,argv) + { + Image *img, *img2; + if (argc == 2 && isobj(argv[0], type(Image), (void**)&img) && + isobj(argv[1], type(Image), (void**)&img2)) { + img = StereoImage(img, img2, &exception); + if (check_exception(&exception)) + return mkapp(mksym(sym(magick_error)), mkstr(strdup(msg))); + else if (!img) + return __FAIL; + else + return mkobj(type(Image), img); + } else + return __FAIL; + } + + FUNCTION(magick,swirl,argc,argv) + { + Image *img; + double angle; + if (argc == 2 && isobj(argv[0], type(Image), (void**)&img) && + (isfloat(argv[1], &angle) || ismpz_float(argv[1], &angle))) { + img = SwirlImage(img, angle, &exception); + if (check_exception(&exception)) + return mkapp(mksym(sym(magick_error)), mkstr(strdup(msg))); + else if (!img) + return __FAIL; + else + return mkobj(type(Image), img); + } else + return __FAIL; + } + + FUNCTION(magick,wave,argc,argv) + { + Image *img; + double amp, wavelen; + if (argc == 3 && isobj(argv[0], type(Image), (void**)&img) && + (isfloat(argv[1], &) || ismpz_float(argv[1], &)) && + (isfloat(argv[2], &wavelen) || ismpz_float(argv[2], &wavelen))) { + img = WaveImage(img, amp, wavelen, &exception); if (check_exception(&exception)) return mkapp(mksym(sym(magick_error)), mkstr(strdup(msg))); Index: magick.q =================================================================== RCS file: /cvsroot/q-lang/q/modules/magick/magick.q,v retrieving revision 1.15 retrieving revision 1.16 diff -C2 -d -r1.15 -r1.16 *** magick.q 28 Dec 2003 23:36:09 -0000 1.15 --- magick.q 29 Dec 2003 03:13:54 -0000 1.16 *************** *** 22,39 **** (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.), image manipulation ! operations. */ import clib; /* Manifest constants. */ ! public var const GRAY, RGB; // colorspaces def GRAY = 0, RGB = 1; public var const ! // composite operators for the composite function OVER_OP, IN_OP, OUT_OP, ATOP_OP, XOR_OP, PLUS_OP, MINUS_OP, ADD_OP, SUBTRACT_OP, DIFFERENCE_OP, MULTIPLY_OP, BUMPMAP_OP, COPY_OP, COPYRED_OP, --- 22,41 ---- (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. Some of the ! more advanced image manipulation routines still need to be done. */ import clib; + /***************************************************************************/ + /* Manifest constants. */ ! /* Colorspace values, used by the quantize and segment operations. */ ! public var const GRAY, RGB; def GRAY = 0, RGB = 1; public var const ! /* Compose operators for the composite function. */ OVER_OP, IN_OP, OUT_OP, ATOP_OP, XOR_OP, PLUS_OP, MINUS_OP, ADD_OP, SUBTRACT_OP, DIFFERENCE_OP, MULTIPLY_OP, BUMPMAP_OP, COPY_OP, COPYRED_OP, *************** *** 42,46 **** HUE_OP, SATURATE_OP, COLORIZE_OP, LUMINIZE_OP, SCREEN_OP, OVERLAY_OP, ! // noise types for add_noise function UNIFORM_NOISE, GAUSSIAN_NOISE, MULTIPLICATIVE_GAUSSIAN_NOISE, IMPULSE_NOISE, LAPLACIAN_NOISE, POISSON_NOISE; --- 44,48 ---- HUE_OP, SATURATE_OP, COLORIZE_OP, LUMINIZE_OP, SCREEN_OP, OVERLAY_OP, ! /* Noise types for the add_noise function. */ UNIFORM_NOISE, GAUSSIAN_NOISE, MULTIPLICATIVE_GAUSSIAN_NOISE, IMPULSE_NOISE, LAPLACIAN_NOISE, POISSON_NOISE; *************** *** 56,59 **** --- 58,63 ---- = magick_vars; + /***************************************************************************/ + /* 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 *************** *** 109,113 **** 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 values. A value of 0 in the RGB components denotes minimum, 0xffff maximum --- 113,117 ---- 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 values. A value of 0 in the RGB components denotes minimum, 0xffff maximum *************** *** 184,187 **** --- 188,193 ---- written, see again ImageMagick(1) for details. */ + // TODO: offset option for read_image; compression options for write_image + public extern read_image NAME INFO, ping_image NAME INFO; public extern write_image NAME IMG; *************** *** 219,224 **** image_magick IMG = M where (W,H,D,A,M) = image_info IMG; ! // TODO: We also need some operations here to retrieve and change various ! // other image parameters, such as default background color and page geometry. /* Retrieve various other useful information about an image. The count_image_ --- 225,230 ---- image_magick IMG = M where (W,H,D,A,M) = image_info IMG; ! // TODO: We need some operations here to retrieve and change various other ! // image parameters, such as default background color and page geometry. /* Retrieve various other useful information about an image. The count_image_ *************** *** 245,258 **** /***************************************************************************/ - /* UNDER CONSTRUCTION!!! */ - /* Image manipulation operations. Please refer to the ImageMagick manual for ! further information about these. "BANG! type" operations, i.e., functions ! which modify the given target image(s) in-place, are marked with `BANG!'. ! Generally, these will be the operations which always leave the image size ! unchanged and only operate on the pixels of an image. These functions ! return () as the result, and if you want to retain the original image you ! will have to clone it beforehand. All other operations return a new image, ! and the original image is left unchanged. A note on parameters: IMG always denotes a singleton input image, IMGS an --- 251,262 ---- /***************************************************************************/ /* Image manipulation operations. Please refer to the ImageMagick manual for ! further information about these. Note that, for efficiency reasons, some ! operations are of the "BANG! type", i.e., they modify the given target ! image(s) in-place. In the following, these are marked with `BANG!'. BANG! ! type functions return () rather than a new image as the result, and if you ! want to retain the original image you will have to clone it beforehand. All ! other operations return a new image, and the original image is left ! unchanged. A note on parameters: IMG always denotes a singleton input image, IMGS an *************** *** 261,267 **** offset or displacement vector, DIM = (W,H) the dimensions of a rectangle, RADIUS a radius, SIGMA a standard deviation value, and ANGLE an angle in ! degrees. PIXEL is an RGBA color value in byte string format. Other ! parameters are mostly different numeric values used by the various ! algorithms. These are explained in more detail in the ImageMagick manual. */ /* Quantization. The COLORSPACE parameter designates the target colorspace, --- 265,274 ---- offset or displacement vector, DIM = (W,H) the dimensions of a rectangle, RADIUS a radius, SIGMA a standard deviation value, and ANGLE an angle in ! degrees. PIXEL is an RGBA color value in byte string format. Some ! operations have a generic string parameter called VAL, which must be in the ! same format as the parameter for the corresponding ImageMagick command line ! option. Other parameters are mostly different numeric values used by the ! various algorithms. These are explained in more detail in the ImageMagick ! manual. */ /* Quantization. The COLORSPACE parameter designates the target colorspace, *************** *** 283,301 **** // TODO: add filter type argument to resize operation public extern magnify IMG, minify IMG; public extern resize IMG DIM BLUR, sample IMG DIM, scale IMG DIM; public extern thumbnail IMG DIM; - /* SHEAR is a pair (XSHEAR,YSHEAR) of shearing angles, MATRIX = (SX,RX,RY,SY) - a linear transform matrix. Please note that rotated images are usually - larger than the originals and have 'empty' triangular corners filled with - the background color set on the image. */ - public extern flipx IMG, flipy IMG; ! public extern rotate IMG ANGLE, shear IMG SHEAR; public extern affine_transform IMG MATRIX P; ! /* Combining and deconstructing images. The OP argument of composite can be ! any of the *_OP values defined in the manifest constants section. */ public extern coalesce IMGS, flatten IMGS, deconstruct IMGS; --- 290,303 ---- // TODO: add filter type argument to resize operation + public extern magnify IMG, minify IMG; public extern resize IMG DIM BLUR, sample IMG DIM, scale IMG DIM; public extern thumbnail IMG DIM; public extern flipx IMG, flipy IMG; ! public extern rotate IMG ANGLE, shear IMG SHEAR_ANGLES; public extern affine_transform IMG MATRIX P; ! /* Combining and deconstructing images. */ public extern coalesce IMGS, flatten IMGS, deconstruct IMGS; *************** *** 305,316 **** // TODO: montage ! /* Image enhancement. SHARPEN = true or false, specifies whether to increase ! or decrease the contrast. The VAL parameter of the gamma, level and ! modulate functions is a string specifying the gamma correction, contrast ! level and brightness/saturation/hue values in the same format as the ! parameters of the -gamma, -level and -modulate options of ImageMagick, see ! ImageMagick(1) for details. */ ! ! /* These are all of the BANG! type. */ public extern contrast IMG SHARPEN, equalize IMG; --- 307,311 ---- // TODO: montage ! /* Image enhancement. (These are all of the BANG! type.) */ public extern contrast IMG SHARPEN, equalize IMG; *************** *** 318,324 **** public extern negate IMG, normalize IMG; ! /* Effects. Note: The VAL argument of the threshold operation is a string in ! the same format as the parameter of ImageMagick's -threshold option, see ! ImageMagick(1). */ public extern adaptive_threshold IMG DIM OFFS; --- 313,317 ---- public extern negate IMG, normalize IMG; ! /* Effects. */ public extern adaptive_threshold IMG DIM OFFS; *************** *** 341,356 **** /* Special effects. */ ! // TODO ! // public extern charcoal IMG RADIUS SIGMA; ! // public extern colorize IMG OPACITY PIXEL; ! // public extern convolve IMG KERNEL; ! // public extern implode IMG AMOUNT; ! // public extern morph IMG1 IMG2 FRAMES; ! // public extern oil_paint IMG RADIUS; ! // public extern solarize IMG THRESHOLD; // BANG! ! // public extern stegano IMG WATERMARK OFFSET; ! // public extern stereo IMG1 IMG2; ! // public extern swirl IMG ANGLE; ! // public extern wave IMG AMP WAVELEN; /* Decorations. */ --- 334,348 ---- /* Special effects. */ ! public extern charcoal IMG RADIUS SIGMA; ! public extern colorize IMG VAL PIXEL; ! public extern convolve IMG KERNEL; ! public extern implode IMG AMOUNT; ! public extern morph IMGS FRAMES; ! public extern oil_paint IMG RADIUS; ! public extern solarize IMG THRESHOLD; // BANG! ! public extern stegano IMG IMG2 OFFS; ! public extern stereo IMG IMG2; ! public extern swirl IMG ANGLE; ! public extern wave IMG AMP WAVELEN; /* Decorations. */ |
From: <ag...@us...> - 2003-12-28 23:36:13
|
Update of /cvsroot/q-lang/q/modules/magick In directory sc8-pr-cvs1:/tmp/cvs-serv31537 Modified Files: magick.c magick.q Log Message: fixed VAL arg of threshold operation Index: magick.c =================================================================== RCS file: /cvsroot/q-lang/q/modules/magick/magick.c,v retrieving revision 1.16 retrieving revision 1.17 diff -C2 -d -r1.16 -r1.17 *** magick.c 28 Dec 2003 23:28:30 -0000 1.16 --- magick.c 28 Dec 2003 23:36:09 -0000 1.17 *************** *** 1640,1652 **** { Image *img; - double threshold; char *val = NULL; if (argc == 2 && isobj(argv[0], type(Image), (void**)&img) && ! (isstr(argv[1], &val) || ismpz_float(argv[1], &threshold))) { ! int res; ! if (val) ! res = ThresholdImageChannel(img, val); ! else ! res = ThresholdImage(img, threshold); if (!res) return __FAIL; --- 1640,1647 ---- { Image *img; char *val = NULL; if (argc == 2 && isobj(argv[0], type(Image), (void**)&img) && ! isstr(argv[1], &val)) { ! int res = ThresholdImageChannel(img, val); if (!res) return __FAIL; Index: magick.q =================================================================== RCS file: /cvsroot/q-lang/q/modules/magick/magick.q,v retrieving revision 1.14 retrieving revision 1.15 diff -C2 -d -r1.14 -r1.15 *** magick.q 28 Dec 2003 23:28:30 -0000 1.14 --- magick.q 28 Dec 2003 23:36:09 -0000 1.15 *************** *** 318,325 **** public extern negate IMG, normalize IMG; ! /* Effects. Note: The VAL argument of the threshold operation can be either a ! single integer value denoting an absolute threshold in the range 0..0xffff, ! or a string in the same format as the parameter of ImageMagick's -threshold ! option, see ImageMagick(1). */ public extern adaptive_threshold IMG DIM OFFS; --- 318,324 ---- public extern negate IMG, normalize IMG; ! /* Effects. Note: The VAL argument of the threshold operation is a string in ! the same format as the parameter of ImageMagick's -threshold option, see ! ImageMagick(1). */ public extern adaptive_threshold IMG DIM OFFS; |
From: <ag...@us...> - 2003-12-28 23:28:33
|
Update of /cvsroot/q-lang/q/modules/magick In directory sc8-pr-cvs1:/tmp/cvs-serv30537 Modified Files: magick.c magick.q Log Message: added threshold operations Index: magick.c =================================================================== RCS file: /cvsroot/q-lang/q/modules/magick/magick.c,v retrieving revision 1.15 retrieving revision 1.16 diff -C2 -d -r1.15 -r1.16 *** magick.c 28 Dec 2003 20:20:34 -0000 1.15 --- magick.c 28 Dec 2003 23:28:30 -0000 1.16 *************** *** 1,7 **** /* $Id$ */ - /* TODO: make this work with older libMagick versions which don't provide - the ScaleQuantumToXYZ routines. */ - /* This file is part of the Q programming system. --- 1,4 ---- *************** *** 1394,1397 **** --- 1391,1416 ---- } + FUNCTION(magick,adaptive_threshold,argc,argv) + { + Image *img; + unsigned long w, h; + long offs; + int n; + expr *xv; + if (argc == 3 && isobj(argv[0], type(Image), (void**)&img) && + istuple(argv[1], &n, &xv) && n == 2 && + isuint(xv[0], &w) && isuint(xv[1], &h) && + isint(argv[2], &offs)) { + img = AdaptiveThresholdImage(img, w, h, offs, &exception); + if (check_exception(&exception)) + return mkapp(mksym(sym(magick_error)), mkstr(strdup(msg))); + else if (!img) + return __FAIL; + else + return mkobj(type(Image), img); + } else + return __FAIL; + } + FUNCTION(magick,add_noise,argc,argv) { *************** *** 1614,1617 **** --- 1633,1656 ---- else return mkobj(type(Image), img); + } else + return __FAIL; + } + + FUNCTION(magick,threshold,argc,argv) + { + Image *img; + double threshold; + char *val = NULL; + if (argc == 2 && isobj(argv[0], type(Image), (void**)&img) && + (isstr(argv[1], &val) || ismpz_float(argv[1], &threshold))) { + int res; + if (val) + res = ThresholdImageChannel(img, val); + else + res = ThresholdImage(img, threshold); + if (!res) + return __FAIL; + else + return mkvoid; } else return __FAIL; Index: magick.q =================================================================== RCS file: /cvsroot/q-lang/q/modules/magick/magick.q,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -d -r1.13 -r1.14 *** magick.q 28 Dec 2003 20:20:34 -0000 1.13 --- magick.q 28 Dec 2003 23:28:30 -0000 1.14 *************** *** 276,280 **** images you will have to clone them first. */ ! public extern quantize IMG COLORSPACE DITHER; // BANG! /* Resizing, scaling and transformations. */ --- 276,280 ---- images you will have to clone them first. */ ! public extern quantize IMG COLORSPACE DITHER; // BANG! /* Resizing, scaling and transformations. */ *************** *** 318,325 **** public extern negate IMG, normalize IMG; ! /* Effects. */ ! // TODO ! // public extern adaptive_threshold IMG DIM OFFS; public extern add_noise IMG NOISE; public extern blur IMG RADIUS SIGMA; --- 318,327 ---- public extern negate IMG, normalize IMG; ! /* Effects. Note: The VAL argument of the threshold operation can be either a ! single integer value denoting an absolute threshold in the range 0..0xffff, ! or a string in the same format as the parameter of ImageMagick's -threshold ! option, see ImageMagick(1). */ ! public extern adaptive_threshold IMG DIM OFFS; public extern add_noise IMG NOISE; public extern blur IMG RADIUS SIGMA; *************** *** 335,339 **** public extern sharpen IMG RADIUS SIGMA; public extern spread IMG RADIUS; ! // public extern threshold IMG THRESHOLD; public extern unsharp_mask IMG RADIUS SIGMA AMOUNT THRESHOLD; --- 337,341 ---- public extern sharpen IMG RADIUS SIGMA; public extern spread IMG RADIUS; ! public extern threshold IMG VAL; // BANG! public extern unsharp_mask IMG RADIUS SIGMA AMOUNT THRESHOLD; *************** *** 347,351 **** // public extern morph IMG1 IMG2 FRAMES; // public extern oil_paint IMG RADIUS; ! // public extern solarize IMG THRESHOLD; // BANG! // public extern stegano IMG WATERMARK OFFSET; // public extern stereo IMG1 IMG2; --- 349,353 ---- // public extern morph IMG1 IMG2 FRAMES; // public extern oil_paint IMG RADIUS; ! // public extern solarize IMG THRESHOLD; // BANG! // public extern stegano IMG WATERMARK OFFSET; // public extern stereo IMG1 IMG2; *************** *** 358,362 **** // public extern border IMG DIM PIXEL; // public extern frame IMG DIM INNER OUTER PIXEL; ! // public extern button IMG DIM; // BANG! /* Annotations. */ --- 360,364 ---- // public extern border IMG DIM PIXEL; // public extern frame IMG DIM INNER OUTER PIXEL; ! // public extern button IMG DIM; // BANG! /* Annotations. */ |
From: <ag...@us...> - 2003-12-28 20:20:37
|
Update of /cvsroot/q-lang/q/modules/magick In directory sc8-pr-cvs1:/tmp/cvs-serv31863 Modified Files: magick.c magick.q Log Message: added effect operations; todo: threshold ops Index: magick.c =================================================================== RCS file: /cvsroot/q-lang/q/modules/magick/magick.c,v retrieving revision 1.14 retrieving revision 1.15 diff -C2 -d -r1.14 -r1.15 *** magick.c 28 Dec 2003 18:47:19 -0000 1.14 --- magick.c 28 Dec 2003 20:20:34 -0000 1.15 *************** *** 140,144 **** if (argc != 0) return __FAIL; return mktuplel ! (31, mkuint(OverCompositeOp), mkuint(InCompositeOp), --- 140,144 ---- if (argc != 0) return __FAIL; return mktuplel ! (37, mkuint(OverCompositeOp), mkuint(InCompositeOp), *************** *** 171,175 **** mkuint(LuminizeCompositeOp), mkuint(ScreenCompositeOp), ! mkuint(OverlayCompositeOp)); } --- 171,184 ---- mkuint(LuminizeCompositeOp), mkuint(ScreenCompositeOp), ! mkuint(OverlayCompositeOp), ! ! mkuint(UniformNoise), ! mkuint(GaussianNoise), ! mkuint(MultiplicativeGaussianNoise), ! mkuint(ImpulseNoise), ! mkuint(LaplacianNoise), ! mkuint(PoissonNoise) ! ! ); } *************** *** 1285,1289 **** expr *xv; if (argc == 4 && isobj(argv[0], type(Image), (void**)&img) && ! isuint(argv[1], &op) && op > 0 && op <= OverlayCompositeOp && isobj(argv[2], type(Image), (void**)&img2) && istuple(argv[3], &n, &xv) && --- 1294,1299 ---- expr *xv; if (argc == 4 && isobj(argv[0], type(Image), (void**)&img) && ! isuint(argv[1], &op) && ! op != UndefinedCompositeOp && op <= OverlayCompositeOp && isobj(argv[2], type(Image), (void**)&img2) && istuple(argv[3], &n, &xv) && *************** *** 1380,1383 **** --- 1390,1637 ---- else return mkvoid; + } else + return __FAIL; + } + + FUNCTION(magick,add_noise,argc,argv) + { + Image *img; + unsigned long noise; + if (argc == 2 && isobj(argv[0], type(Image), (void**)&img) && + isuint(argv[1], &noise) && noise <= PoissonNoise) { + img = AddNoiseImage(img, noise, &exception); + if (check_exception(&exception)) + return mkapp(mksym(sym(magick_error)), mkstr(strdup(msg))); + else if (!img) + return __FAIL; + else + return mkobj(type(Image), img); + } else + return __FAIL; + } + + FUNCTION(magick,blur,argc,argv) + { + Image *img; + double radius, sigma; + if (argc == 3 && isobj(argv[0], type(Image), (void**)&img) && + (isfloat(argv[1], &radius) || ismpz_float(argv[1], &radius)) && + (isfloat(argv[2], &sigma) || ismpz_float(argv[2], &sigma))) { + img = BlurImage(img, radius, sigma, &exception); + if (check_exception(&exception)) + return mkapp(mksym(sym(magick_error)), mkstr(strdup(msg))); + else if (!img) + return __FAIL; + else + return mkobj(type(Image), img); + } else + return __FAIL; + } + + FUNCTION(magick,despeckle,argc,argv) + { + Image *img; + if (argc == 1 && isobj(argv[0], type(Image), (void**)&img)) { + img = DespeckleImage(img, &exception); + if (check_exception(&exception)) + return mkapp(mksym(sym(magick_error)), mkstr(strdup(msg))); + else if (!img) + return __FAIL; + else + return mkobj(type(Image), img); + } else + return __FAIL; + } + + FUNCTION(magick,edge,argc,argv) + { + Image *img; + double radius; + if (argc == 2 && isobj(argv[0], type(Image), (void**)&img) && + (isfloat(argv[1], &radius) || ismpz_float(argv[1], &radius))) { + img = EdgeImage(img, radius, &exception); + if (check_exception(&exception)) + return mkapp(mksym(sym(magick_error)), mkstr(strdup(msg))); + else if (!img) + return __FAIL; + else + return mkobj(type(Image), img); + } else + return __FAIL; + } + + FUNCTION(magick,emboss,argc,argv) + { + Image *img; + double radius, sigma; + if (argc == 3 && isobj(argv[0], type(Image), (void**)&img) && + (isfloat(argv[1], &radius) || ismpz_float(argv[1], &radius)) && + (isfloat(argv[2], &sigma) || ismpz_float(argv[2], &sigma))) { + img = EmbossImage(img, radius, sigma, &exception); + if (check_exception(&exception)) + return mkapp(mksym(sym(magick_error)), mkstr(strdup(msg))); + else if (!img) + return __FAIL; + else + return mkobj(type(Image), img); + } else + return __FAIL; + } + + FUNCTION(magick,enhance,argc,argv) + { + Image *img; + if (argc == 1 && isobj(argv[0], type(Image), (void**)&img)) { + img = EnhanceImage(img, &exception); + if (check_exception(&exception)) + return mkapp(mksym(sym(magick_error)), mkstr(strdup(msg))); + else if (!img) + return __FAIL; + else + return mkobj(type(Image), img); + } else + return __FAIL; + } + + FUNCTION(magick,gaussian_blur,argc,argv) + { + Image *img; + double radius, sigma; + if (argc == 3 && isobj(argv[0], type(Image), (void**)&img) && + (isfloat(argv[1], &radius) || ismpz_float(argv[1], &radius)) && + (isfloat(argv[2], &sigma) || ismpz_float(argv[2], &sigma))) { + img = GaussianBlurImage(img, radius, sigma, &exception); + if (check_exception(&exception)) + return mkapp(mksym(sym(magick_error)), mkstr(strdup(msg))); + else if (!img) + return __FAIL; + else + return mkobj(type(Image), img); + } else + return __FAIL; + } + + FUNCTION(magick,median_filter,argc,argv) + { + Image *img; + double radius; + if (argc == 2 && isobj(argv[0], type(Image), (void**)&img) && + (isfloat(argv[1], &radius) || ismpz_float(argv[1], &radius))) { + img = MedianFilterImage(img, radius, &exception); + if (check_exception(&exception)) + return mkapp(mksym(sym(magick_error)), mkstr(strdup(msg))); + else if (!img) + return __FAIL; + else + return mkobj(type(Image), img); + } else + return __FAIL; + } + + FUNCTION(magick,motion_blur,argc,argv) + { + Image *img; + double radius, sigma, angle; + if (argc == 4 && isobj(argv[0], type(Image), (void**)&img) && + (isfloat(argv[1], &radius) || ismpz_float(argv[1], &radius)) && + (isfloat(argv[2], &sigma) || ismpz_float(argv[2], &sigma)) && + (isfloat(argv[3], &angle) || ismpz_float(argv[3], &angle))) { + img = MotionBlurImage(img, radius, sigma, angle, &exception); + if (check_exception(&exception)) + return mkapp(mksym(sym(magick_error)), mkstr(strdup(msg))); + else if (!img) + return __FAIL; + else + return mkobj(type(Image), img); + } else + return __FAIL; + } + + FUNCTION(magick,reduce_noise,argc,argv) + { + Image *img; + double radius; + if (argc == 2 && isobj(argv[0], type(Image), (void**)&img) && + (isfloat(argv[1], &radius) || ismpz_float(argv[1], &radius))) { + img = ReduceNoiseImage(img, radius, &exception); + if (check_exception(&exception)) + return mkapp(mksym(sym(magick_error)), mkstr(strdup(msg))); + else if (!img) + return __FAIL; + else + return mkobj(type(Image), img); + } else + return __FAIL; + } + + FUNCTION(magick,shade,argc,argv) + { + Image *img; + double azimuth, elevation; + if (argc == 3 && isobj(argv[0], type(Image), (void**)&img) && + (isfloat(argv[1], &azimuth) || ismpz_float(argv[1], &azimuth)) && + (isfloat(argv[2], &elevation) || ismpz_float(argv[2], &elevation))) { + img = ShadeImage(img, 0, azimuth, elevation, &exception); + if (check_exception(&exception)) + return mkapp(mksym(sym(magick_error)), mkstr(strdup(msg))); + else if (!img) + return __FAIL; + else + return mkobj(type(Image), img); + } else + return __FAIL; + } + + FUNCTION(magick,sharpen,argc,argv) + { + Image *img; + double radius, sigma; + if (argc == 3 && isobj(argv[0], type(Image), (void**)&img) && + (isfloat(argv[1], &radius) || ismpz_float(argv[1], &radius)) && + (isfloat(argv[2], &sigma) || ismpz_float(argv[2], &sigma))) { + img = SharpenImage(img, radius, sigma, &exception); + if (check_exception(&exception)) + return mkapp(mksym(sym(magick_error)), mkstr(strdup(msg))); + else if (!img) + return __FAIL; + else + return mkobj(type(Image), img); + } else + return __FAIL; + } + + FUNCTION(magick,spread,argc,argv) + { + Image *img; + double radius; + if (argc == 2 && isobj(argv[0], type(Image), (void**)&img) && + (isfloat(argv[1], &radius) || ismpz_float(argv[1], &radius))) { + img = SpreadImage(img, radius, &exception); + if (check_exception(&exception)) + return mkapp(mksym(sym(magick_error)), mkstr(strdup(msg))); + else if (!img) + return __FAIL; + else + return mkobj(type(Image), img); + } else + return __FAIL; + } + + FUNCTION(magick,unsharp_mask,argc,argv) + { + Image *img; + double radius, sigma, amount, threshold; + if (argc == 5 && isobj(argv[0], type(Image), (void**)&img) && + (isfloat(argv[1], &radius) || ismpz_float(argv[1], &radius)) && + (isfloat(argv[2], &sigma) || ismpz_float(argv[2], &sigma)) && + (isfloat(argv[3], &amount) || ismpz_float(argv[3], &amount)) && + (isfloat(argv[3], &threshold) || ismpz_float(argv[3], &threshold))) { + img = UnsharpMaskImage(img, radius, sigma, amount, threshold, &exception); + if (check_exception(&exception)) + return mkapp(mksym(sym(magick_error)), mkstr(strdup(msg))); + else if (!img) + return __FAIL; + else + return mkobj(type(Image), img); } else return __FAIL; Index: magick.q =================================================================== RCS file: /cvsroot/q-lang/q/modules/magick/magick.q,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -d -r1.12 -r1.13 *** magick.q 28 Dec 2003 18:47:19 -0000 1.12 --- magick.q 28 Dec 2003 20:20:34 -0000 1.13 *************** *** 40,51 **** COPYGREEN_OP, COPYBLUE_OP, COPYOPACITY_OP, CLEAR_OP, DISSOLVE_OP, DISPLACE_OP, MODULATE_OP, THRESHOLD_OP, NO_OP, DARKEN_OP, LIGHTEN_OP, ! HUE_OP, SATURATE_OP, COLORIZE_OP, LUMINIZE_OP, SCREEN_OP, OVERLAY_OP; private extern magick_vars; def (OVER_OP, IN_OP, OUT_OP, ATOP_OP, XOR_OP, PLUS_OP, MINUS_OP, ADD_OP, ! SUBTRACT_OP, DIFFERENCE_OP, MULTIPLY_OP, BUMPMAP_OP, COPY_OP, COPYRED_OP, ! COPYGREEN_OP, COPYBLUE_OP, COPYOPACITY_OP, CLEAR_OP, DISSOLVE_OP, ! DISPLACE_OP, MODULATE_OP, THRESHOLD_OP, NO_OP, DARKEN_OP, LIGHTEN_OP, ! HUE_OP, SATURATE_OP, COLORIZE_OP, LUMINIZE_OP, SCREEN_OP, OVERLAY_OP) = magick_vars; --- 40,57 ---- COPYGREEN_OP, COPYBLUE_OP, COPYOPACITY_OP, CLEAR_OP, DISSOLVE_OP, DISPLACE_OP, MODULATE_OP, THRESHOLD_OP, NO_OP, DARKEN_OP, LIGHTEN_OP, ! HUE_OP, SATURATE_OP, COLORIZE_OP, LUMINIZE_OP, SCREEN_OP, OVERLAY_OP, ! ! // noise types for add_noise function ! UNIFORM_NOISE, GAUSSIAN_NOISE, MULTIPLICATIVE_GAUSSIAN_NOISE, ! IMPULSE_NOISE, LAPLACIAN_NOISE, POISSON_NOISE; private extern magick_vars; def (OVER_OP, IN_OP, OUT_OP, ATOP_OP, XOR_OP, PLUS_OP, MINUS_OP, ADD_OP, ! SUBTRACT_OP, DIFFERENCE_OP, MULTIPLY_OP, BUMPMAP_OP, COPY_OP, COPYRED_OP, ! COPYGREEN_OP, COPYBLUE_OP, COPYOPACITY_OP, CLEAR_OP, DISSOLVE_OP, ! DISPLACE_OP, MODULATE_OP, THRESHOLD_OP, NO_OP, DARKEN_OP, LIGHTEN_OP, ! HUE_OP, SATURATE_OP, COLORIZE_OP, LUMINIZE_OP, SCREEN_OP, OVERLAY_OP, ! UNIFORM_NOISE, GAUSSIAN_NOISE, MULTIPLICATIVE_GAUSSIAN_NOISE, ! IMPULSE_NOISE, LAPLACIAN_NOISE, POISSON_NOISE) = magick_vars; *************** *** 276,279 **** --- 282,286 ---- public extern chop IMG P DIM, crop IMG P DIM, roll IMG P, shave IMG DIM; + // TODO: add filter type argument to resize operation public extern magnify IMG, minify IMG; public extern resize IMG DIM BLUR, sample IMG DIM, scale IMG DIM; *************** *** 314,339 **** // TODO - // public extern gaussian_noise IMG; - // public extern impulse_noise IMG; - // public extern laplacian_noise IMG; - // public extern multiplicative_noise IMG; - // public extern poisson_noise IMG; - // public extern uniform_noise IMG; - // public extern adaptive_threshold IMG DIM OFFS; ! // public extern blur IMG RADIUS SIGMA; ! // public extern despeckle IMG; ! // public extern edge IMG RADIUS; ! // public extern emboss IMG RADIUS SIGMA; ! // public extern enhance IMG; ! // public extern gaussian_blur IMG RADIUS SIGMA; ! // public extern median_filter IMG RADIUS; ! // public extern motion_blur IMG RADIUS SIGMA ANGLE; ! // public extern reduce_noise IMG RADIUS; ! // public extern shade IMG GRAY AZIMUTH ELEVATION; ! // public extern sharpen IMG RADIUS SIGMA; ! // public extern spread IMG RADIUS; // public extern threshold IMG THRESHOLD; ! // public extern unsharp_mask IMG RADIUS SIGMA AMOUNT THRESHOLD; /* Special effects. */ --- 321,340 ---- // TODO // public extern adaptive_threshold IMG DIM OFFS; ! public extern add_noise IMG NOISE; ! public extern blur IMG RADIUS SIGMA; ! public extern despeckle IMG; ! public extern edge IMG RADIUS; ! public extern emboss IMG RADIUS SIGMA; ! public extern enhance IMG; ! public extern gaussian_blur IMG RADIUS SIGMA; ! public extern median_filter IMG RADIUS; ! public extern motion_blur IMG RADIUS SIGMA ANGLE; ! public extern reduce_noise IMG RADIUS; ! public extern shade IMG AZIMUTH ELEVATION; ! public extern sharpen IMG RADIUS SIGMA; ! public extern spread IMG RADIUS; // public extern threshold IMG THRESHOLD; ! public extern unsharp_mask IMG RADIUS SIGMA AMOUNT THRESHOLD; /* Special effects. */ |
From: <ag...@us...> - 2003-12-28 18:47:24
|
Update of /cvsroot/q-lang/q/modules/magick In directory sc8-pr-cvs1:/tmp/cvs-serv12172 Modified Files: magick.c magick.q Log Message: added composition and image enhancement operations Index: magick.c =================================================================== RCS file: /cvsroot/q-lang/q/modules/magick/magick.c,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -d -r1.13 -r1.14 *** magick.c 28 Dec 2003 11:14:41 -0000 1.13 --- magick.c 28 Dec 2003 18:47:19 -0000 1.14 *************** *** 134,139 **** } bstr_t; - #if 0 - /* manifest constants */ --- 134,137 ---- *************** *** 142,154 **** if (argc != 0) return __FAIL; return mktuplel ! (4, ! mkuint(FileResource), ! mkuint(MemoryResource), ! mkuint(MapResource), ! mkuint(DiskResource)); } - #endif - FUNCTION(magick,magick_info,argc,argv) { --- 140,177 ---- if (argc != 0) return __FAIL; return mktuplel ! (31, ! mkuint(OverCompositeOp), ! mkuint(InCompositeOp), ! mkuint(OutCompositeOp), ! mkuint(AtopCompositeOp), ! mkuint(XorCompositeOp), ! mkuint(PlusCompositeOp), ! mkuint(MinusCompositeOp), ! mkuint(AddCompositeOp), ! mkuint(SubtractCompositeOp), ! mkuint(DifferenceCompositeOp), ! mkuint(MultiplyCompositeOp), ! mkuint(BumpmapCompositeOp), ! mkuint(CopyCompositeOp), ! mkuint(CopyRedCompositeOp), ! mkuint(CopyGreenCompositeOp), ! mkuint(CopyBlueCompositeOp), ! mkuint(CopyOpacityCompositeOp), ! mkuint(ClearCompositeOp), ! mkuint(DissolveCompositeOp), ! mkuint(DisplaceCompositeOp), ! mkuint(ModulateCompositeOp), ! mkuint(ThresholdCompositeOp), ! mkuint(NoCompositeOp), ! mkuint(DarkenCompositeOp), ! mkuint(LightenCompositeOp), ! mkuint(HueCompositeOp), ! mkuint(SaturateCompositeOp), ! mkuint(ColorizeCompositeOp), ! mkuint(LuminizeCompositeOp), ! mkuint(ScreenCompositeOp), ! mkuint(OverlayCompositeOp)); } FUNCTION(magick,magick_info,argc,argv) { *************** *** 1246,1249 **** --- 1269,1379 ---- int res = SegmentImage(img, (space==0)?GRAYColorspace:RGBColorspace, verbose, cluster, smooth); + if (!res) + return __FAIL; + else + return mkvoid; + } else + return __FAIL; + } + + FUNCTION(magick,composite,argc,argv) + { + Image *img, *img2; + unsigned long op; + long x, y; + int n; + expr *xv; + if (argc == 4 && isobj(argv[0], type(Image), (void**)&img) && + isuint(argv[1], &op) && op > 0 && op <= OverlayCompositeOp && + isobj(argv[2], type(Image), (void**)&img2) && + istuple(argv[3], &n, &xv) && + isint(xv[0], &x) && isint(xv[1], &y)) { + int res = CompositeImage(img, op, img2, x, y); + if (!res) + return __FAIL; + else + return mkvoid; + } else + return __FAIL; + } + + FUNCTION(magick,contrast,argc,argv) + { + Image *img; + int sharpen; + if (argc == 2 && isobj(argv[0], type(Image), (void**)&img) && + isbool(argv[1], &sharpen)) { + /* With IM 5.5 this always returns false, bug? Therfore we just ignore the + return value. */ + ContrastImage(img, sharpen); + return mkvoid; + } else + return __FAIL; + } + + FUNCTION(magick,equalize,argc,argv) + { + Image *img; + if (argc == 1 && isobj(argv[0], type(Image), (void**)&img)) { + int res = EqualizeImage(img); + if (!res) + return __FAIL; + else + return mkvoid; + } else + return __FAIL; + } + + FUNCTION(magick,gamma,argc,argv) + { + Image *img; + char *val; + if (argc == 2 && isobj(argv[0], type(Image), (void**)&img) && + isstr(argv[1], &val) && GammaImage(img, val)) + return mkvoid; + else + return __FAIL; + } + + FUNCTION(magick,level,argc,argv) + { + Image *img; + char *val; + if (argc == 2 && isobj(argv[0], type(Image), (void**)&img) && + isstr(argv[1], &val) && LevelImage(img, val)) + return mkvoid; + else + return __FAIL; + } + + FUNCTION(magick,modulate,argc,argv) + { + Image *img; + char *val; + if (argc == 2 && isobj(argv[0], type(Image), (void**)&img) && + isstr(argv[1], &val) && ModulateImage(img, val)) + return mkvoid; + else + return __FAIL; + } + + FUNCTION(magick,negate,argc,argv) + { + Image *img; + if (argc == 1 && isobj(argv[0], type(Image), (void**)&img)) { + int res = NegateImage(img, 0); + if (!res) + return __FAIL; + else + return mkvoid; + } else + return __FAIL; + } + + FUNCTION(magick,normalize,argc,argv) + { + Image *img; + if (argc == 1 && isobj(argv[0], type(Image), (void**)&img)) { + int res = NormalizeImage(img); if (!res) return __FAIL; Index: magick.q =================================================================== RCS file: /cvsroot/q-lang/q/modules/magick/magick.q,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** magick.q 28 Dec 2003 11:14:41 -0000 1.11 --- magick.q 28 Dec 2003 18:47:19 -0000 1.12 *************** *** 29,32 **** --- 29,53 ---- import clib; + /* Manifest constants. */ + + public var const GRAY, RGB; // colorspaces + def GRAY = 0, RGB = 1; + + public var const + // composite operators for the composite function + OVER_OP, IN_OP, OUT_OP, ATOP_OP, XOR_OP, PLUS_OP, MINUS_OP, ADD_OP, + SUBTRACT_OP, DIFFERENCE_OP, MULTIPLY_OP, BUMPMAP_OP, COPY_OP, COPYRED_OP, + COPYGREEN_OP, COPYBLUE_OP, COPYOPACITY_OP, CLEAR_OP, DISSOLVE_OP, + DISPLACE_OP, MODULATE_OP, THRESHOLD_OP, NO_OP, DARKEN_OP, LIGHTEN_OP, + HUE_OP, SATURATE_OP, COLORIZE_OP, LUMINIZE_OP, SCREEN_OP, OVERLAY_OP; + + private extern magick_vars; + def (OVER_OP, IN_OP, OUT_OP, ATOP_OP, XOR_OP, PLUS_OP, MINUS_OP, ADD_OP, + SUBTRACT_OP, DIFFERENCE_OP, MULTIPLY_OP, BUMPMAP_OP, COPY_OP, COPYRED_OP, + COPYGREEN_OP, COPYBLUE_OP, COPYOPACITY_OP, CLEAR_OP, DISSOLVE_OP, + DISPLACE_OP, MODULATE_OP, THRESHOLD_OP, NO_OP, DARKEN_OP, LIGHTEN_OP, + HUE_OP, SATURATE_OP, COLORIZE_OP, LUMINIZE_OP, SCREEN_OP, OVERLAY_OP) + = magick_vars; + /* 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 *************** *** 249,255 **** images you will have to clone them first. */ - public var const GRAY, RGB; - def GRAY = 0, RGB = 1; - public extern quantize IMG COLORSPACE DITHER; // BANG! --- 270,273 ---- *************** *** 271,323 **** public extern affine_transform IMG MATRIX P; ! /* Combining and deconstructing images. */ public extern coalesce IMGS, flatten IMGS, deconstruct IMGS; public extern segment IMG COLORSPACE VERBOSE CLUSTER SMOOTH; // BANG! // TODO: montage - /* Composition operations. These are all of the BANG! type. */ - - // TODO - // public extern composite_over IMG IMG2 P; - // public extern composite_in IMG IMG2 P; - // public extern composite_out IMG IMG2 P; - // public extern composite_atop IMG IMG2 P; - // public extern composite_xor IMG IMG2 P; - // public extern composite_plus IMG IMG2 P; - // public extern composite_minus IMG IMG2 P; - // public extern composite_add IMG IMG2 P; - // public extern composite_subtract IMG IMG2 P; - // public extern composite_difference IMG IMG2 P; - // public extern composite_multiply IMG IMG2 P; - // public extern composite_bumpmap IMG IMG2 P; - // public extern composite_copy IMG IMG2 P; - // public extern composite_copy_red IMG IMG2 P; - // public extern composite_copy_green IMG IMG2 P; - // public extern composite_copy_blue IMG IMG2 P; - // public extern composite_copy_matte IMG IMG2 P; - // public extern composite_dissolve IMG IMG2 P; - // public extern composite_clear IMG IMG2 P; - // public extern composite_displace IMG IMG2 P; - // public extern composite_modulate IMG IMG2 P; - // public extern composite_threshold IMG IMG2 P; - /* Image enhancement. SHARPEN = true or false, specifies whether to increase ! or decrease the contrast; GAMMA = either a singleton value or a triplet ! (R,G,B) of gamma correction values to be applied to the red, green and blue ! channels of an image; LEVEL = a singleton BLACK value, or a tuple of up to ! three values (BLACK,WHITE,GAMMA) used to adjust the contrast of an image; ! GRAY = true or false, specifies whether to negate only the intensities or ! the colors themselves. */ /* These are all of the BANG! type. */ ! // TODO ! // public extern contrast IMG SHARPEN, equalize IMG; ! // public extern gamma IMG GAMMA, level IMG LEVEL; ! // public extern modulate IMG BRIGHTNESS SATURATION HUE; ! // public extern negate IMG GRAY; ! // public extern normalize IMG; /* Effects. */ --- 289,313 ---- public extern affine_transform IMG MATRIX P; ! /* Combining and deconstructing images. The OP argument of composite can be ! any of the *_OP values defined in the manifest constants section. */ public extern coalesce IMGS, flatten IMGS, deconstruct IMGS; + public extern composite IMG OP IMG2 P; // BANG! public extern segment IMG COLORSPACE VERBOSE CLUSTER SMOOTH; // BANG! // TODO: montage /* Image enhancement. SHARPEN = true or false, specifies whether to increase ! or decrease the contrast. The VAL parameter of the gamma, level and ! modulate functions is a string specifying the gamma correction, contrast ! level and brightness/saturation/hue values in the same format as the ! parameters of the -gamma, -level and -modulate options of ImageMagick, see ! ImageMagick(1) for details. */ /* These are all of the BANG! type. */ ! public extern contrast IMG SHARPEN, equalize IMG; ! public extern gamma IMG VAL, level IMG VAL, modulate IMG VAL; ! public extern negate IMG, normalize IMG; /* Effects. */ |
From: <ag...@us...> - 2003-12-28 11:36:35
|
Update of /cvsroot/q-lang/q/modules/magick/examples In directory sc8-pr-cvs1:/tmp/cvs-serv1672/examples Modified Files: magicktest.q Log Message: minor fixes in animation function Index: magicktest.q =================================================================== RCS file: /cvsroot/q-lang/q/modules/magick/examples/magicktest.q,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** magicktest.q 27 Dec 2003 19:25:00 -0000 1.6 --- magicktest.q 28 Dec 2003 11:36:32 -0000 1.7 *************** *** 107,112 **** ==> animate (read_image "jurannessic_176x104.mpg" ()) ! You can also loop the animation by using the `repeat' function instead of ! `animate'. Sit back and watch. Enjoy. :) */ def FPS = 25; --- 107,111 ---- ==> animate (read_image "jurannessic_176x104.mpg" ()) ! Sit back and watch. Enjoy. :) */ def FPS = 25; *************** *** 114,127 **** animate IMGS ! = do (show VIS) IMGS || VIS ! ! where (W,H|_) = image_info (hd IMGS), ! VIS = ggi_open (sprintf "%s:-keepcursor" target), ! () = ggi_set_flags VIS GGI_FLAG_ASYNC || ! ggi_set_mode VIS (sprintf "%dx%d" (W,H)); ! ! repeat IMGS ! ! = loop VIS IMGS where (W,H|_) = image_info (hd IMGS), --- 113,117 ---- animate IMGS ! = catch id (loop VIS IMGS) where (W,H|_) = image_info (hd IMGS), *************** *** 134,139 **** show VIS IMG ! = ggi_getc VIS || halt if ggi_kbhit VIS; ! // *FIXME* we should really take a more decent way out here = ggi_put_box VIS (0,0) (W,H) PIXELS || ggi_flush VIS || sleep (T+1/FPS-time) --- 124,128 ---- show VIS IMG ! = ggi_getc VIS || throw VIS if ggi_kbhit VIS; = ggi_put_box VIS (0,0) (W,H) PIXELS || ggi_flush VIS || sleep (T+1/FPS-time) |
From: <ag...@us...> - 2003-12-28 11:14:46
|
Update of /cvsroot/q-lang/q/modules/magick In directory sc8-pr-cvs1:/tmp/cvs-serv31440 Modified Files: magick.c magick.q Log Message: more image manipulation functions Index: magick.c =================================================================== RCS file: /cvsroot/q-lang/q/modules/magick/magick.c,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -d -r1.12 -r1.13 *** magick.c 28 Dec 2003 01:56:36 -0000 1.12 --- magick.c 28 Dec 2003 11:14:41 -0000 1.13 *************** *** 853,859 **** is_image_list(argv[0], &imgs)) && (isobj(argv[1], type(Image), (void**)&img2) || ! isuint(argv[1], &space) && space <= 2 || istuple(argv[1], &n, &xv) && n == 2 && ! isuint(xv[0], &space) && space <= 2 && isuint(xv[1], &ncolors) && ncolors <= MaxRGB) && isbool(argv[2], &dither)) { --- 853,859 ---- is_image_list(argv[0], &imgs)) && (isobj(argv[1], type(Image), (void**)&img2) || ! isuint(argv[1], &space) && space <= 1 || istuple(argv[1], &n, &xv) && n == 2 && ! isuint(xv[0], &space) && space <= 1 && isuint(xv[1], &ncolors) && ncolors <= MaxRGB) && isbool(argv[2], &dither)) { *************** *** 936,939 **** --- 936,959 ---- } + FUNCTION(magick,roll,argc,argv) + { + Image *img; + int n; + expr *xv; + long x, y; + if (argc == 2 && isobj(argv[0], type(Image), (void**)&img) && + istuple(argv[1], &n, &xv) && n == 2 && + isint(xv[0], &x) && isint(xv[1], &y)) { + img = RollImage(img, x, y, &exception); + if (check_exception(&exception)) + return mkapp(mksym(sym(magick_error)), mkstr(strdup(msg))); + else if (!img) + return __FAIL; + else + return mkobj(type(Image), img); + } else + return __FAIL; + } + FUNCTION(magick,shave,argc,argv) { *************** *** 1097,1100 **** --- 1117,1253 ---- else return mkobj(type(Image), img); + } else + return __FAIL; + } + + FUNCTION(magick,rotate,argc,argv) + { + Image *img; + double angle; + if (argc == 2 && isobj(argv[0], type(Image), (void**)&img) && + (isfloat(argv[1], &angle) || ismpz_float(argv[1], &angle))) { + img = RotateImage(img, angle, &exception); + if (check_exception(&exception)) + return mkapp(mksym(sym(magick_error)), mkstr(strdup(msg))); + else if (!img) + return __FAIL; + else + return mkobj(type(Image), img); + } else + return __FAIL; + } + + FUNCTION(magick,shear,argc,argv) + { + Image *img; + int n; + expr *xv; + double xshear, yshear; + if (argc == 2 && isobj(argv[0], type(Image), (void**)&img) && + istuple(argv[1], &n, &xv) && n == 2 && + (isfloat(xv[0], &xshear) || ismpz_float(xv[0], &xshear)) && + (isfloat(xv[1], &yshear) || ismpz_float(xv[1], &yshear))) { + img = ShearImage(img, xshear, yshear, &exception); + if (check_exception(&exception)) + return mkapp(mksym(sym(magick_error)), mkstr(strdup(msg))); + else if (!img) + return __FAIL; + else + return mkobj(type(Image), img); + } else + return __FAIL; + } + + FUNCTION(magick,affine_transform,argc,argv) + { + Image *img; + int n; + expr *xv; + AffineMatrix matrix; + if (argc == 3 && isobj(argv[0], type(Image), (void**)&img) && + istuple(argv[1], &n, &xv) && n == 4 && + (isfloat(xv[0], &matrix.sx) || ismpz_float(xv[0], &matrix.sx)) && + (isfloat(xv[1], &matrix.rx) || ismpz_float(xv[1], &matrix.rx)) && + (isfloat(xv[2], &matrix.ry) || ismpz_float(xv[2], &matrix.ry)) && + (isfloat(xv[3], &matrix.sy) || ismpz_float(xv[3], &matrix.sy)) && + istuple(argv[2], &n, &xv) && n == 2 && + (isfloat(xv[0], &matrix.tx) || ismpz_float(xv[0], &matrix.tx)) && + (isfloat(xv[1], &matrix.ty) || ismpz_float(xv[1], &matrix.ty))) { + img = AffineTransformImage(img, &matrix, &exception); + if (check_exception(&exception)) + return mkapp(mksym(sym(magick_error)), mkstr(strdup(msg))); + else if (!img) + return __FAIL; + else + return mkobj(type(Image), img); + } else + return __FAIL; + } + + FUNCTION(magick,coalesce,argc,argv) + { + Image *imgs; + if (argc == 1 && is_image_list(argv[0], &imgs) && imgs) { + Image *img = CoalesceImages(imgs, &exception); + decompose_image_list(imgs); + if (check_exception(&exception)) + return mkapp(mksym(sym(magick_error)), mkstr(strdup(msg))); + else if (!img) + return __FAIL; + else + return mk_image_list(img); + } else + return __FAIL; + } + + FUNCTION(magick,flatten,argc,argv) + { + Image *imgs; + if (argc == 1 && is_image_list(argv[0], &imgs) && imgs) { + Image *img = FlattenImages(imgs, &exception); + decompose_image_list(imgs); + if (check_exception(&exception)) + return mkapp(mksym(sym(magick_error)), mkstr(strdup(msg))); + else if (!img) + return __FAIL; + else + return mkobj(type(Image), img); + } else + return __FAIL; + } + + FUNCTION(magick,deconstruct,argc,argv) + { + Image *imgs; + if (argc == 1 && is_image_list(argv[0], &imgs) && imgs) { + Image *img = DeconstructImages(imgs, &exception); + decompose_image_list(imgs); + if (check_exception(&exception)) + return mkapp(mksym(sym(magick_error)), mkstr(strdup(msg))); + else if (!img) + return __FAIL; + else + return mk_image_list(img); + } else + return __FAIL; + } + + FUNCTION(magick,segment,argc,argv) + { + Image *img; + unsigned long space; + int verbose; + double cluster, smooth; + if (argc == 5 && isobj(argv[0], type(Image), (void**)&img) && + isuint(argv[1], &space) && space <= 1 && + isbool(argv[2], &verbose) && + (isfloat(argv[3], &cluster) || ismpz_float(argv[3], &cluster)) && + (isfloat(argv[4], &smooth) || ismpz_float(argv[4], &smooth))) { + int res = SegmentImage(img, (space==0)?GRAYColorspace:RGBColorspace, + verbose, cluster, smooth); + if (!res) + return __FAIL; + else + return mkvoid; } else return __FAIL; Index: magick.q =================================================================== RCS file: /cvsroot/q-lang/q/modules/magick/magick.q,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** magick.q 28 Dec 2003 01:56:36 -0000 1.10 --- magick.q 28 Dec 2003 11:14:41 -0000 1.11 *************** *** 192,195 **** --- 192,198 ---- image_magick IMG = M where (W,H,D,A,M) = image_info IMG; + // TODO: We also need some operations here to retrieve and change various + // other image parameters, such as default background color and page geometry. + /* Retrieve various other useful information about an image. The count_image_ colors function determines the number of unique colors in an image. The *************** *** 235,281 **** algorithms. These are explained in more detail in the ImageMagick manual. */ ! /* Quantization. The SPACE parameter designates the target colorspace, and can ! be either (1) one of the constant values GRAY and RGB, or (2) a pair ! (SPACE, COLORS) denoting both the colorspace SPACE and the desired maximum ! number of colors COLORS, or (3) a reference image IMG2 specifying the ! colormap to be applied to the target image. In case (1) the number of ! colors defaults to 256. The second parameter DITHER is a flag which ! specifies whether to apply Floyd/Steinberg dithering to the image. The ! target image IMG can also be a list of images which are to be mapped to the ! same colormap. Please note that this is a BANG! type operation, thus if you ! you want to retain the original image(s) you will have to clone them ! first. */ public var const GRAY, RGB; def GRAY = 0, RGB = 1; ! public extern quantize IMG SPACE DITHER; // BANG! ! /* Resizing and scaling. */ - public extern chop IMG P DIM, crop IMG P DIM, shave IMG DIM; public extern magnify IMG, minify IMG; public extern resize IMG DIM BLUR, sample IMG DIM, scale IMG DIM; public extern thumbnail IMG DIM; ! /* Transformations. MATRIX = (SX,RX,RY,SY,TX,TY) denotes an affine ! transformation matrix. */ public extern flipx IMG, flipy IMG; ! ! // TODO ! // public extern rotate IMG ANGLE; ! // public extern roll IMG P, shear IMG P; ! // public extern transform IMG MATRIX; /* Combining and deconstructing images. */ ! // TODO ! // public extern coalesce IMGS, flatten IMGS, deconstruct IMGS; ! // public extern segment IMG CLUSTER SMOOTH; // BANG! ! // TODO: montage??? ! /* Composite operations. These are all of the BANG! type. */ // TODO --- 238,282 ---- algorithms. These are explained in more detail in the ImageMagick manual. */ ! /* Quantization. The COLORSPACE parameter designates the target colorspace, ! and can be either (1) one of the constant values GRAY and RGB, or (2) a ! pair (COLORSPACE, COLORS) denoting both the colorspace and the desired ! maximum number of colors, or (3) a reference image specifying the colormap ! to be applied to the target image. In case (1) the number of colors ! defaults to 256. The DITHER flag determines whether to apply Floyd/ ! Steinberg dithering to the image. The target image IMG can also be a list ! of images which are to be mapped to the same colormap. Please note that ! this is a BANG! type operation, thus if you you want to retain the original ! images you will have to clone them first. */ public var const GRAY, RGB; def GRAY = 0, RGB = 1; ! public extern quantize IMG COLORSPACE DITHER; // BANG! ! /* Resizing, scaling and transformations. */ ! ! public extern chop IMG P DIM, crop IMG P DIM, roll IMG P, shave IMG DIM; public extern magnify IMG, minify IMG; public extern resize IMG DIM BLUR, sample IMG DIM, scale IMG DIM; public extern thumbnail IMG DIM; ! /* SHEAR is a pair (XSHEAR,YSHEAR) of shearing angles, MATRIX = (SX,RX,RY,SY) ! a linear transform matrix. Please note that rotated images are usually ! larger than the originals and have 'empty' triangular corners filled with ! the background color set on the image. */ public extern flipx IMG, flipy IMG; ! public extern rotate IMG ANGLE, shear IMG SHEAR; ! public extern affine_transform IMG MATRIX P; /* Combining and deconstructing images. */ ! public extern coalesce IMGS, flatten IMGS, deconstruct IMGS; ! public extern segment IMG COLORSPACE VERBOSE CLUSTER SMOOTH; // BANG! ! // TODO: montage ! /* Composition operations. These are all of the BANG! type. */ // TODO |
From: <ag...@us...> - 2003-12-28 05:34:48
|
Update of /cvsroot/q-lang/q/modules/magick/examples In directory sc8-pr-cvs1:/tmp/cvs-serv8669 Modified Files: magicktest.q Log Message: improve timing in animation function Index: magicktest.q =================================================================== RCS file: /cvsroot/q-lang/q/modules/magick/examples/magicktest.q,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** magicktest.q 26 Dec 2003 03:10:49 -0000 1.5 --- magicktest.q 27 Dec 2003 19:25:00 -0000 1.6 *************** *** 107,112 **** ==> animate (read_image "jurannessic_176x104.mpg" ()) ! You can also loop the animation loop by using the `repeat' function instead ! of `animate'. Sit back and watch. Enjoy. :) */ def FPS = 25; --- 107,112 ---- ==> animate (read_image "jurannessic_176x104.mpg" ()) ! You can also loop the animation by using the `repeat' function instead of ! `animate'. Sit back and watch. Enjoy. :) */ def FPS = 25; *************** *** 137,143 **** // *FIXME* we should really take a more decent way out here ! = ggi_put_box VIS (0,0) (W,H) PIXELS || ggi_flush VIS || sleep (1/FPS) ! where (W,H|_) = image_info IMG, PIXELS = get_image_pixels IMG (0,0) (W,H); --- 137,143 ---- // *FIXME* we should really take a more decent way out here ! = ggi_put_box VIS (0,0) (W,H) PIXELS || ggi_flush VIS || sleep (T+1/FPS-time) ! where T = time, (W,H|_) = image_info IMG, PIXELS = get_image_pixels IMG (0,0) (W,H); |
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. */ |
From: <ag...@us...> - 2003-12-27 20:05:11
|
Update of /cvsroot/q-lang/q/modules/magick In directory sc8-pr-cvs1:/tmp/cvs-serv11072 Modified Files: magick.c Log Message: work on image manipulation ops started Index: magick.c =================================================================== RCS file: /cvsroot/q-lang/q/modules/magick/magick.c,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** magick.c 27 Dec 2003 04:31:36 -0000 1.10 --- magick.c 27 Dec 2003 19:41:48 -0000 1.11 *************** *** 748,752 **** 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; --- 748,752 ---- isint(xv[0], &x) && isint(xv[1], &y) && istuple(argv[2], &n, &xv) && n == 2 && ! isuint(xv[0], &w) && isuint(xv[1], &h) && (pixels = GetImagePixels(img, x, y, w, h))) { unsigned long size = w*h*8; *************** *** 782,786 **** 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; --- 782,786 ---- isint(xv[0], &x) && isint(xv[1], &y) && istuple(argv[2], &n, &xv) && n == 2 && ! isuint(xv[0], &w) && isuint(xv[1], &h) && isobj(argv[3], type(ByteStr), (void**)&m)) { unsigned long size = w*h*8; *************** *** 797,800 **** --- 797,1071 ---- else return __FAIL; + } else + return __FAIL; + } + + static inline int isbool(expr x, int *val) + { + if (istrue(x)) { + *val = 1; + return 1; + } else if (isfalse(x)) { + *val = 0; + return 1; + } else + return 0; + } + + FUNCTION(magick,quantize,argc,argv) + { + Image *img = NULL, *imgs = NULL, *img2 = NULL; + unsigned long space = 1, ncolors = 255; + int dither = 0, res; + int n; + expr *xv; + if (argc == 3 && + (isobj(argv[0], type(Image), (void**)&img) || + is_image_list(argv[0], &imgs)) && + (isobj(argv[1], type(Image), (void**)&img2) || + isuint(argv[1], &space) && space <= 2 || + istuple(argv[1], &n, &xv) && n == 2 && + isuint(xv[0], &space) && space <= 2 && + isuint(xv[1], &ncolors) && ncolors <= MaxRGB) && + isbool(argv[2], &dither)) { + if (img2) { + if (imgs) { + res = MapImages(imgs, img2, dither); + decompose_image_list(imgs); + } else + res = MapImage(img, img2, dither); + } else { + QuantizeInfo info; + GetQuantizeInfo(&info); + info.dither = dither; + info.number_colors = ncolors; + info.colorspace = (space==0)?GRAYColorspace:RGBColorspace; + if (imgs) { + res = QuantizeImages(&info, imgs); + decompose_image_list(imgs); + } else + res = QuantizeImage(&info, img); + } + if (res) + return mkvoid; + else + return __FAIL; + } else + return __FAIL; + } + + FUNCTION(magick,chop,argc,argv) + { + Image *img; + int n; + expr *xv; + long x, y; + unsigned long w, h; + if (argc == 3 && isobj(argv[0], type(Image), (void**)&img) && + istuple(argv[1], &n, &xv) && + isint(xv[0], &x) && isint(xv[1], &y) && + istuple(argv[2], &n, &xv) && n == 2 && + isuint(xv[0], &w) && isuint(xv[1], &h)) { + RectangleInfo info; + info.x = x; info.y = y; + info.width = w; info.height = h; + img = ChopImage(img, &info, &exception); + if (check_exception(&exception)) + return mkapp(mksym(sym(magick_error)), mkstr(strdup(msg))); + else if (!img) + return __FAIL; + else + return mkobj(type(Image), img); + } else + return __FAIL; + } + + FUNCTION(magick,crop,argc,argv) + { + Image *img; + int n; + expr *xv; + long x, y; + unsigned long w, h; + if (argc == 3 && isobj(argv[0], type(Image), (void**)&img) && + istuple(argv[1], &n, &xv) && + isint(xv[0], &x) && isint(xv[1], &y) && + istuple(argv[2], &n, &xv) && n == 2 && + isuint(xv[0], &w) && isuint(xv[1], &h)) { + RectangleInfo info; + info.x = x; info.y = y; + info.width = w; info.height = h; + img = CropImage(img, &info, &exception); + if (check_exception(&exception)) + return mkapp(mksym(sym(magick_error)), mkstr(strdup(msg))); + else if (!img) + return __FAIL; + else + return mkobj(type(Image), img); + } else + return __FAIL; + } + + FUNCTION(magick,shave,argc,argv) + { + Image *img; + int n; + expr *xv; + unsigned long w, h; + if (argc == 2 && isobj(argv[0], type(Image), (void**)&img) && + istuple(argv[1], &n, &xv) && n == 2 && + isuint(xv[0], &w) && isuint(xv[1], &h)) { + RectangleInfo info; + info.x = 0; info.y = 0; + info.width = w; info.height = h; + img = ShaveImage(img, &info, &exception); + if (check_exception(&exception)) + return mkapp(mksym(sym(magick_error)), mkstr(strdup(msg))); + else if (!img) + return __FAIL; + else + return mkobj(type(Image), img); + } else + return __FAIL; + } + + FUNCTION(magick,magnify,argc,argv) + { + Image *img; + if (argc == 1 && isobj(argv[0], type(Image), (void**)&img)) { + img = MagnifyImage(img, &exception); + if (check_exception(&exception)) + return mkapp(mksym(sym(magick_error)), mkstr(strdup(msg))); + else if (!img) + return __FAIL; + else + return mkobj(type(Image), img); + } else + return __FAIL; + } + + FUNCTION(magick,minify,argc,argv) + { + Image *img; + if (argc == 1 && isobj(argv[0], type(Image), (void**)&img)) { + img = MinifyImage(img, &exception); + if (check_exception(&exception)) + return mkapp(mksym(sym(magick_error)), mkstr(strdup(msg))); + else if (!img) + return __FAIL; + else + return mkobj(type(Image), img); + } else + return __FAIL; + } + + FUNCTION(magick,resize,argc,argv) + { + Image *img; + int n; + expr *xv; + unsigned long w, h; + double blur; + if (argc == 3 && isobj(argv[0], type(Image), (void**)&img) && + istuple(argv[1], &n, &xv) && n == 2 && + isuint(xv[0], &w) && isuint(xv[1], &h) && + (isfloat(argv[2], &blur) || ismpz_float(argv[2], &blur))) { + img = ResizeImage(img, w, h, LanczosFilter, blur, &exception); + if (check_exception(&exception)) + return mkapp(mksym(sym(magick_error)), mkstr(strdup(msg))); + else if (!img) + return __FAIL; + else + return mkobj(type(Image), img); + } else + return __FAIL; + } + + FUNCTION(magick,sample,argc,argv) + { + Image *img; + int n; + expr *xv; + unsigned long w, h; + if (argc == 2 && isobj(argv[0], type(Image), (void**)&img) && + istuple(argv[1], &n, &xv) && n == 2 && + isuint(xv[0], &w) && isuint(xv[1], &h)) { + img = SampleImage(img, w, h, &exception); + if (check_exception(&exception)) + return mkapp(mksym(sym(magick_error)), mkstr(strdup(msg))); + else if (!img) + return __FAIL; + else + return mkobj(type(Image), img); + } else + return __FAIL; + } + + FUNCTION(magick,scale,argc,argv) + { + Image *img; + int n; + expr *xv; + unsigned long w, h; + if (argc == 2 && isobj(argv[0], type(Image), (void**)&img) && + istuple(argv[1], &n, &xv) && n == 2 && + isuint(xv[0], &w) && isuint(xv[1], &h)) { + img = ScaleImage(img, w, h, &exception); + if (check_exception(&exception)) + return mkapp(mksym(sym(magick_error)), mkstr(strdup(msg))); + else if (!img) + return __FAIL; + else + return mkobj(type(Image), img); + } else + return __FAIL; + } + + FUNCTION(magick,thumbnail,argc,argv) + { + Image *img; + int n; + expr *xv; + unsigned long w, h; + if (argc == 2 && isobj(argv[0], type(Image), (void**)&img) && + istuple(argv[1], &n, &xv) && n == 2 && + isuint(xv[0], &w) && isuint(xv[1], &h)) { + img = ThumbnailImage(img, w, h, &exception); + if (check_exception(&exception)) + return mkapp(mksym(sym(magick_error)), mkstr(strdup(msg))); + else if (!img) + return __FAIL; + else + return mkobj(type(Image), img); + } else + return __FAIL; + } + + FUNCTION(magick,flipx,argc,argv) + { + Image *img; + if (argc == 1 && isobj(argv[0], type(Image), (void**)&img)) { + img = FlopImage(img, &exception); + if (check_exception(&exception)) + return mkapp(mksym(sym(magick_error)), mkstr(strdup(msg))); + else if (!img) + return __FAIL; + else + return mkobj(type(Image), img); + } else + return __FAIL; + } + + FUNCTION(magick,flipy,argc,argv) + { + Image *img; + if (argc == 1 && isobj(argv[0], type(Image), (void**)&img)) { + img = FlipImage(img, &exception); + if (check_exception(&exception)) + return mkapp(mksym(sym(magick_error)), mkstr(strdup(msg))); + else if (!img) + return __FAIL; + else + return mkobj(type(Image), img); } else return __FAIL; |
From: <ag...@us...> - 2003-12-27 20:00:08
|
Update of /cvsroot/q-lang/q/modules/magick In directory sc8-pr-cvs1:/tmp/cvs-serv11016 Modified Files: magick.q Log Message: work on image manipulation ops started Index: magick.q =================================================================== RCS file: /cvsroot/q-lang/q/modules/magick/magick.q,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** magick.q 26 Dec 2003 14:26:51 -0000 1.8 --- magick.q 27 Dec 2003 19:41:16 -0000 1.9 *************** *** 40,43 **** --- 40,45 ---- 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 *************** *** 89,92 **** --- 91,96 ---- 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, *************** *** 143,158 **** public extern write_image NAME IMG; ! /* Convert an image to a "blob" ("binary large object", represented as a byte ! string), and vice versa. This is useful, e.g., if an image is to be stored ! in a database, or if it is to be manipulated as raw data. The MAGICK ! parameter of image_to_blob can be used to indicate the desired target ! format; if it is () then the format of the image is used as the target ! format. The blob_to_image function takes an INFO structure like the one ! passed to create_image and read_image, to specify image properties which ! cannot be deduced from the blob itself; this is necessary, e.g., if the ! blob is just raw RGB data. */ public extern image_to_blob MAGICK IMG, blob_to_image BLOB INFO; /* 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, --- 147,164 ---- public extern write_image NAME IMG; ! /* Convert an image or image sequence to a "blob" ("binary large object", ! represented as a byte string), and vice versa. This is useful, e.g., if an ! image is to be stored in a database, or if it is to be manipulated as raw ! data. The MAGICK parameter of image_to_blob can be used to indicate the ! desired target format; if it is () then the format of the image is used as ! the target format. The blob_to_image function takes an INFO structure like ! the one passed to create_image and read_image, to specify image properties ! which cannot be deduced from the blob itself; this is necessary, e.g., if ! the blob is just raw RGB data. */ public extern image_to_blob MAGICK IMG, blob_to_image BLOB INFO; + /***************************************************************************/ + /* 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, *************** *** 185,188 **** --- 191,196 ---- 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 *************** *** 191,192 **** --- 199,363 ---- public extern get_image_pixels IMG P DIM; public extern set_image_pixels IMG P DIM PIXELS; + + /***************************************************************************/ + + /* UNDER CONSTRUCTION!!! */ + + /* Image manipulation operations. Please refer to the ImageMagick manual for + further information about these. "BANG! type" operations, i.e., functions + which modify the given target image(s) in-place, are marked with `BANG!'. + Generally, these will be the operations which always leave the image size + unchanged and only operate on the pixels of an image. These functions + return () as the result, and if you want to retain the original image you + will have to clone it beforehand. All other operations return a new image, + and the original image is left unchanged. + + A note on parameters: IMG always denotes a singleton input image, IMGS an + image list. Some operations also take a secondary image IMG2 as an + additional (r/o) parameter. P = (X,Y) is used to indicate a position, + offset or displacement vector, DIM = (W,H) the dimensions of a rectangle, + RADIUS a radius, SIGMA a standard deviation value, and ANGLE an angle in + degrees. PIXEL is an RGBA color value in byte string format. Other + parameters are mostly different numeric values used by the various + algorithms. These are explained in more detail in the ImageMagick manual. */ + + /* Quantization. The SPACE parameter designates the target colorspace, and can + be either (1) one of the constant values GRAY and RGB, or (2) a pair + (SPACE, COLORS) denoting both the colorspace SPACE and the desired maximum + number of colors COLORS, or (3) a reference image IMG2 specifying the + colormap to be applied to the target image. In case (1) the number of + colors defaults to 256. The second parameter DITHER is a flag which + specifies whether to apply Floyd/Steinberg dithering to the image. The + target image IMG can also be a list of images which are to be mapped to the + same colormap. Please note that this is a BANG! type operation, thus if you + you want to retain the original image(s) you will have to clone them + first. */ + + public var const GRAY, RGB; + def GRAY = 0, RGB = 1; + + public extern quantize IMG SPACE DITHER; // BANG! + + /* Resizing and scaling. */ + + public extern chop IMG P DIM, crop IMG P DIM, shave IMG DIM; + public extern magnify IMG, minify IMG; + public extern resize IMG DIM BLUR, sample IMG DIM, scale IMG DIM; + public extern thumbnail IMG DIM; + + /* Transformations. MATRIX = (SX,RX,RY,SY,TX,TY) denotes an affine + transformation matrix. */ + + public extern flipx IMG, flipy IMG; + + // TODO + // public extern rotate IMG ANGLE; + // public extern roll IMG P, shear IMG P; + // public extern transform IMG MATRIX; + + /* Combining and deconstructing images. */ + + // TODO + // public extern coalesce IMGS, flatten IMGS, deconstruct IMGS; + // public extern segment IMG CLUSTER SMOOTH; // BANG! + + // TODO: montage??? + + /* Composite operations. These are all of the BANG! type. */ + + // TODO + // public extern composite_over IMG IMG2 P; + // public extern composite_in IMG IMG2 P; + // public extern composite_out IMG IMG2 P; + // public extern composite_atop IMG IMG2 P; + // public extern composite_xor IMG IMG2 P; + // public extern composite_plus IMG IMG2 P; + // public extern composite_minus IMG IMG2 P; + // public extern composite_add IMG IMG2 P; + // public extern composite_subtract IMG IMG2 P; + // public extern composite_difference IMG IMG2 P; + // public extern composite_multiply IMG IMG2 P; + // public extern composite_bumpmap IMG IMG2 P; + // public extern composite_copy IMG IMG2 P; + // public extern composite_copy_red IMG IMG2 P; + // public extern composite_copy_green IMG IMG2 P; + // public extern composite_copy_blue IMG IMG2 P; + // public extern composite_copy_matte IMG IMG2 P; + // public extern composite_dissolve IMG IMG2 P; + // public extern composite_clear IMG IMG2 P; + // public extern composite_displace IMG IMG2 P; + // public extern composite_modulate IMG IMG2 P; + // public extern composite_threshold IMG IMG2 P; + + /* Image enhancement. SHARPEN = true or false, specifies whether to increase + or decrease the contrast; GAMMA = either a singleton value or a triplet + (R,G,B) of gamma correction values to be applied to the red, green and blue + channels of an image; LEVEL = a singleton BLACK value, or a tuple of up to + three values (BLACK,WHITE,GAMMA) used to adjust the contrast of an image; + GRAY = true or false, specifies whether to negate only the intensities or + the colors themselves. */ + + /* These are all of the BANG! type. */ + + // TODO + // public extern contrast IMG SHARPEN, equalize IMG; + // public extern gamma IMG GAMMA, level IMG LEVEL; + // public extern modulate IMG BRIGHTNESS SATURATION HUE; + // public extern negate IMG GRAY; + // public extern normalize IMG; + + /* Effects. */ + + // TODO + // public extern gaussian_noise IMG; + // public extern impulse_noise IMG; + // public extern laplacian_noise IMG; + // public extern multiplicative_noise IMG; + // public extern poisson_noise IMG; + // public extern uniform_noise IMG; + + // public extern adaptive_threshold IMG DIM OFFS; + // public extern blur IMG RADIUS SIGMA; + // public extern despeckle IMG; + // public extern edge IMG RADIUS; + // public extern emboss IMG RADIUS SIGMA; + // public extern enhance IMG; + // public extern gaussian_blur IMG RADIUS SIGMA; + // public extern median_filter IMG RADIUS; + // public extern motion_blur IMG RADIUS SIGMA ANGLE; + // public extern reduce_noise IMG RADIUS; + // public extern shade IMG GRAY AZIMUTH ELEVATION; + // public extern sharpen IMG RADIUS SIGMA; + // public extern spread IMG RADIUS; + // public extern threshold IMG THRESHOLD; + // public extern unsharp_mask IMG RADIUS SIGMA AMOUNT THRESHOLD; + + /* Special effects. */ + + // TODO + // public extern charcoal IMG RADIUS SIGMA; + // public extern colorize IMG OPACITY PIXEL; + // public extern convolve IMG KERNEL; + // public extern implode IMG AMOUNT; + // public extern morph IMG1 IMG2 FRAMES; + // public extern oil_paint IMG RADIUS; + // public extern solarize IMG THRESHOLD; // BANG! + // public extern stegano IMG WATERMARK OFFSET; + // public extern stereo IMG1 IMG2; + // public extern swirl IMG ANGLE; + // public extern wave IMG AMP WAVELEN; + + /* Decorations. */ + + // TODO + // public extern border IMG DIM PIXEL; + // public extern frame IMG DIM INNER OUTER PIXEL; + // public extern button IMG DIM; // BANG! + + /* Annotations. */ + + // TODO + + /* Drawing and painting. */ + + // TODO |
From: <ag...@us...> - 2003-12-27 04:53:35
|
Update of /cvsroot/q-lang/q/modules/magick In directory sc8-pr-cvs1:/tmp/cvs-serv13551 Modified Files: magick.c Log Message: factor out common image list building and parsing code, bug fixes in write_image Index: magick.c =================================================================== RCS file: /cvsroot/q-lang/q/modules/magick/magick.c,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** magick.c 27 Dec 2003 03:26:50 -0000 1.8 --- magick.c 27 Dec 2003 04:20:32 -0000 1.9 *************** *** 431,434 **** --- 431,463 ---- } + static void decompose_image_list(Image *img) + { + Image *tmp, *tmp2; + for (tmp = img; tmp; tmp = tmp2) { + tmp2 = tmp->next; + tmp->previous = tmp->next = NULL; + } + } + + static expr mk_image_list(Image *img) + { + expr x = mknil; + Image *imgs; + /* 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; + x = mkcons(mkobj(type(Image), imgs), x); + imgs = tmp; + } + if (x) + decompose_image_list(img); + else + DestroyImageList(img); + return x; + } + FUNCTION(magick,read_image,argc,argv) { *************** *** 452,478 **** 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; --- 481,489 ---- return __FAIL; else if (img->next) { Image *imgs; if (matte >= 0) for (imgs = img; imgs; imgs = imgs->next) imgs->matte = (unsigned)matte; ! return mk_image_list(img); } else { if (matte >= 0) img->matte = (unsigned)matte; *************** *** 504,530 **** 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; --- 515,523 ---- return __FAIL; else if (img->next) { Image *imgs; if (matte >= 0) for (imgs = img; imgs; imgs = imgs->next) imgs->matte = (unsigned)matte; ! return mk_image_list(img); } else { if (matte >= 0) img->matte = (unsigned)matte; *************** *** 535,569 **** } FUNCTION(magick,write_image,argc,argv) { 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; GetImageInfo(&info); ! for (x = argv[1]; iscons(x, &hd, &tl); x = tl) { ! if (!(isobj(hd, type(Image), (void**)&tmp) && ! tmp->columns > 0 && tmp->rows > 0)) ! return __FAIL; ! if (!img) img = tmp; ! } ! if (img && !isnil(x)) ! 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 */ --- 528,568 ---- } + static int is_image_list(expr x, Image **img) + { + expr y, hd, tl; + Image *tmp, *tmp2; + for (y = x; iscons(y, &hd, &tl); y = tl) + if (!(isobj(hd, type(Image), (void**)&tmp) && + tmp->columns > 0 && tmp->rows > 0)) + return 0; + if (!isnil(y)) return 0; + *img = NULL; + if (isnil(x)) return 1; + tmp2 = NULL; + for (y = x; iscons(y, &hd, &tl); y = tl) { + isobj(hd, type(Image), (void**)&tmp); + if (tmp2) { + tmp->previous = tmp2; + tmp2->next = tmp; + } else + *img = tmp; + tmp2 = tmp; + } + return 1; + } + FUNCTION(magick,write_image,argc,argv) { char *s; if (argc == 2 && isstr(argv[0], &s)) { ! Image *img = NULL; ImageInfo info; int res; if (isnil(argv[1])) return __FAIL; GetImageInfo(&info); ! if (is_image_list(argv[1], &img)) { ! res = WriteImages(&info, img, s, &exception); ! decompose_image_list(img); } else { /* must be a singleton image */ *************** *** 574,582 **** res = WriteImage(&info, img); exception = img->exception; - } - /* break up image list */ - for (tmp = img; tmp; tmp = tmp2) { - tmp2 = tmp->next; - tmp->previous = tmp->next = NULL; } if (check_exception(&exception)) --- 573,576 ---- |
From: <ag...@us...> - 2003-12-27 04:33:29
|
Update of /cvsroot/q-lang/q/modules/magick In directory sc8-pr-cvs1:/tmp/cvs-serv14845 Modified Files: magick.c Log Message: support for multi-image formats in image_to_blob and blob_to_image Index: magick.c =================================================================== RCS file: /cvsroot/q-lang/q/modules/magick/magick.c,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** magick.c 27 Dec 2003 04:20:32 -0000 1.9 --- magick.c 27 Dec 2003 04:31:36 -0000 1.10 *************** *** 589,593 **** Image *img; if (argc == 2 && ! isobj(argv[1], type(Image), (void**)&img) && img->columns > 0 && img->rows > 0 && (isvoid(argv[0]) && *img->magick || isstr(argv[0], &s) && *s)) { --- 589,594 ---- Image *img; if (argc == 2 && ! (isobj(argv[1], type(Image), (void**)&img) || ! is_image_list(argv[1], &img)) && img->columns > 0 && img->rows > 0 && (isvoid(argv[0]) && *img->magick || isstr(argv[0], &s) && *s)) { *************** *** 603,606 **** --- 604,608 ---- } blob = ImageToBlob(&info, img, &len, &exception); + decompose_image_list(img); if (s) strncpy(img->magick, magick, MaxTextExtent-1); *************** *** 643,647 **** if (!img) return __FAIL; ! else { if (matte >= 0) img->matte = (unsigned)matte; return mkobj(type(Image), img); --- 645,655 ---- if (!img) return __FAIL; ! else if (img->next) { ! Image *imgs; ! if (matte >= 0) ! for (imgs = img; imgs; imgs = imgs->next) ! imgs->matte = (unsigned)matte; ! return mk_image_list(img); ! } else { if (matte >= 0) img->matte = (unsigned)matte; return mkobj(type(Image), img); |