[q-lang-cvs] q/modules/magick magick.c,1.21,1.22 magick.q,1.19,1.20
Brought to you by:
agraef
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_ |