[q-lang-cvs] q/modules/magick magick.c,1.7,1.8
Brought to you by:
agraef
From: <ag...@us...> - 2003-12-27 03:26:53
|
Update of /cvsroot/q-lang/q/modules/magick In directory sc8-pr-cvs1:/tmp/cvs-serv7401 Modified Files: magick.c Log Message: turned image infos into automatic variables Index: magick.c =================================================================== RCS file: /cvsroot/q-lang/q/modules/magick/magick.c,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** magick.c 26 Dec 2003 14:26:51 -0000 1.7 --- magick.c 27 Dec 2003 03:26:50 -0000 1.8 *************** *** 379,393 **** isobj(argv[1], type(ByteStr), (void**)&m)) { unsigned long size = w*h*8; ! ImageInfo *info = CloneImageInfo(NULL); Image *img; int matte; ! if (!info) return __ERROR; if (ULONG_MAX/8 < w*h || m->size != 8 && m->size != size || ! !parse_info(n, xv, info, &matte)) { ! DestroyImageInfo(info); return __FAIL; ! } ! img = AllocateImage(info); ! DestroyImageInfo(info); if (!img) return __ERROR; --- 379,390 ---- isobj(argv[1], type(ByteStr), (void**)&m)) { unsigned long size = w*h*8; ! ImageInfo info; Image *img; int matte; ! GetImageInfo(&info); if (ULONG_MAX/8 < w*h || m->size != 8 && m->size != size || ! !parse_info(n, xv, &info, &matte)) return __FAIL; ! img = AllocateImage(&info); if (!img) return __ERROR; *************** *** 442,456 **** (istuple(argv[1], &n, &xv) || isvoid(argv[1])) && n <= 5) { ! ImageInfo *info = CloneImageInfo(NULL); Image *img; int matte; ! if (!info) return __ERROR; ! if (!parse_info(n, xv, info, &matte)) { ! DestroyImageInfo(info); return __FAIL; ! } ! strncpy(info->filename, s, MaxTextExtent-1); ! img = ReadImage(info, &exception); ! DestroyImageInfo(info); if (check_exception(&exception)) return mkapp(mksym(sym(magick_error)), mkstr(strdup(msg))); --- 439,450 ---- (istuple(argv[1], &n, &xv) || isvoid(argv[1])) && n <= 5) { ! ImageInfo info; Image *img; int matte; ! GetImageInfo(&info); ! if (!parse_info(n, xv, &info, &matte)) return __FAIL; ! strncpy(info.filename, s, MaxTextExtent-1); ! img = ReadImage(&info, &exception); if (check_exception(&exception)) return mkapp(mksym(sym(magick_error)), mkstr(strdup(msg))); *************** *** 497,511 **** (istuple(argv[1], &n, &xv) || isvoid(argv[1])) && n <= 5) { ! ImageInfo *info = CloneImageInfo(NULL); Image *img; int matte; ! if (!info) return __ERROR; ! if (!parse_info(n, xv, info, &matte)) { ! DestroyImageInfo(info); return __FAIL; ! } ! strncpy(info->filename, s, MaxTextExtent-1); ! img = PingImage(info, &exception); ! DestroyImageInfo(info); if (check_exception(&exception)) return mkapp(mksym(sym(magick_error)), mkstr(strdup(msg))); --- 491,502 ---- (istuple(argv[1], &n, &xv) || isvoid(argv[1])) && n <= 5) { ! ImageInfo info; Image *img; int matte; ! GetImageInfo(&info); ! if (!parse_info(n, xv, &info, &matte)) return __FAIL; ! strncpy(info.filename, s, MaxTextExtent-1); ! img = PingImage(&info, &exception); if (check_exception(&exception)) return mkapp(mksym(sym(magick_error)), mkstr(strdup(msg))); *************** *** 549,571 **** if (argc == 2 && isstr(argv[0], &s)) { Image *img = NULL, *tmp, *tmp2; ! ImageInfo *info; int res; expr x, hd, tl; if (isnil(argv[1])) return __FAIL; ! info = CloneImageInfo(NULL); ! if (!info) return __ERROR; for (x = argv[1]; iscons(x, &hd, &tl); x = tl) { if (!(isobj(hd, type(Image), (void**)&tmp) && ! tmp->columns > 0 && tmp->rows > 0)) { ! DestroyImageInfo(info); return __FAIL; - } if (!img) img = tmp; } ! if (img && !isnil(x)) { ! DestroyImageInfo(info); return __FAIL; - } if (img) { /* build the image list */ --- 540,557 ---- 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 */ *************** *** 578,595 **** } tmp2 = tmp; ! res = WriteImages(info, img, s, &exception); } } else { /* must be a singleton image */ if (!(isobj(argv[1], type(Image), (void**)&img) && ! img->columns > 0 && img->rows > 0)) { ! DestroyImageInfo(info); return __FAIL; - } strncpy(img->filename, s, MaxTextExtent-1); ! res = WriteImage(info, img); exception = img->exception; } - DestroyImageInfo(info); /* break up image list */ for (tmp = img; tmp; tmp = tmp2) { --- 564,578 ---- } tmp2 = tmp; ! res = WriteImages(&info, img, s, &exception); } } else { /* must be a singleton image */ if (!(isobj(argv[1], type(Image), (void**)&img) && ! img->columns > 0 && img->rows > 0)) return __FAIL; strncpy(img->filename, s, MaxTextExtent-1); ! res = WriteImage(&info, img); exception = img->exception; } /* break up image list */ for (tmp = img; tmp; tmp = tmp2) { *************** *** 615,632 **** img->columns > 0 && img->rows > 0 && (isvoid(argv[0]) && *img->magick || isstr(argv[0], &s) && *s)) { ! ImageInfo *info = CloneImageInfo(NULL); size_t len; void *blob; bstr_t *m; char magick[MaxTextExtent]; ! if (!info) return __ERROR; if (s) { strncpy(magick, img->magick, MaxTextExtent-1); strncpy(img->magick, s, MaxTextExtent-1); } ! blob = ImageToBlob(info, img, &len, &exception); if (s) strncpy(img->magick, magick, MaxTextExtent-1); - DestroyImageInfo(info); if (check_exception(&exception)) return mkapp(mksym(sym(magick_error)), mkstr(strdup(msg))); --- 598,614 ---- img->columns > 0 && img->rows > 0 && (isvoid(argv[0]) && *img->magick || isstr(argv[0], &s) && *s)) { ! ImageInfo info; size_t len; void *blob; bstr_t *m; char magick[MaxTextExtent]; ! GetImageInfo(&info); if (s) { strncpy(magick, img->magick, MaxTextExtent-1); strncpy(img->magick, s, MaxTextExtent-1); } ! blob = ImageToBlob(&info, img, &len, &exception); if (s) strncpy(img->magick, magick, MaxTextExtent-1); if (check_exception(&exception)) return mkapp(mksym(sym(magick_error)), mkstr(strdup(msg))); *************** *** 654,669 **** (istuple(argv[1], &n, &xv) || isvoid(argv[1])) && n <= 5) { ! ImageInfo *info = CloneImageInfo(NULL); Image *img; int matte; size_t len = (size_t)m->size; void *blob = m->v; ! if (!info) return __ERROR; ! if (!parse_info(n, xv, info, &matte)) { ! DestroyImageInfo(info); return __FAIL; ! } ! img = BlobToImage(info, blob, len, &exception); ! DestroyImageInfo(info); if (check_exception(&exception)) return mkapp(mksym(sym(magick_error)), mkstr(strdup(msg))); --- 636,648 ---- (istuple(argv[1], &n, &xv) || isvoid(argv[1])) && n <= 5) { ! ImageInfo info; Image *img; int matte; size_t len = (size_t)m->size; void *blob = m->v; ! GetImageInfo(&info); ! if (!parse_info(n, xv, &info, &matte)) return __FAIL; ! img = BlobToImage(&info, blob, len, &exception); if (check_exception(&exception)) return mkapp(mksym(sym(magick_error)), mkstr(strdup(msg))); |