diff --git a/src/modules/Image/image.c b/src/modules/Image/image.c index c63ec025052a1c1cdf152e52c9ebe56e965c3e79..e19922cac936c9fddd272847115e2bb3bdf1a903 100644 --- a/src/modules/Image/image.c +++ b/src/modules/Image/image.c @@ -1,4 +1,4 @@ -/* $Id: image.c,v 1.37 1997/09/01 14:16:12 per Exp $ */ +/* $Id: image.c,v 1.38 1997/09/05 16:51:56 grubba Exp $ */ /* **! module Image @@ -6,7 +6,7 @@ **! This module adds image-drawing and -manipulating **! capabilities to pike. **! note -**! $Id: image.c,v 1.37 1997/09/01 14:16:12 per Exp $<br> +**! $Id: image.c,v 1.38 1997/09/05 16:51:56 grubba Exp $<br> **! see also: Image.font, Image.image **! **! class image @@ -107,7 +107,7 @@ #include "stralloc.h" #include "global.h" -RCSID("$Id: image.c,v 1.37 1997/09/01 14:16:12 per Exp $"); +RCSID("$Id: image.c,v 1.38 1997/09/05 16:51:56 grubba Exp $"); #include "pike_macros.h" #include "object.h" #include "constants.h" @@ -1650,6 +1650,7 @@ void image_hsv_to_rgb(INT32 args) rgb_group *s,*d; struct object *o; struct image *img; + char *err = NULL; if (!THIS->img) error("no image\n"); o=clone_object(image_program,0); @@ -1694,7 +1695,8 @@ void image_hsv_to_rgb(INT32 args) case 4: r = t; g = p; b = v; break; case 5: r = v; g = p; b = q; break; default: - error("Nope. Not possible"); + err = "Nope. Not possible"; + goto exit_loop; } } #undef i @@ -1708,8 +1710,13 @@ void image_hsv_to_rgb(INT32 args) d->b = FIX(b); s++; d++; } +exit_loop: THREADS_DISALLOW(); + if (err) { + error(err); + } + pop_n_elems(args); push_object(o); } diff --git a/src/modules/Image/matrix.c b/src/modules/Image/matrix.c index 89e1ee6d71ea0cd36c618629a509ca5187cc3a2f..91e3287884aa2d3be91e61a716c54f084cedcebb 100644 --- a/src/modules/Image/matrix.c +++ b/src/modules/Image/matrix.c @@ -1,9 +1,9 @@ -/* $Id: matrix.c,v 1.8 1997/09/01 14:17:11 per Exp $ */ +/* $Id: matrix.c,v 1.9 1997/09/05 16:51:57 grubba Exp $ */ /* **! module Image **! note -**! $Id: matrix.c,v 1.8 1997/09/01 14:17:11 per Exp $<br> +**! $Id: matrix.c,v 1.9 1997/09/05 16:51:57 grubba Exp $<br> **! class image */ @@ -162,6 +162,7 @@ void img_scale(struct image *dest, rgb_group *d; INT32 y,yd; double yn,dx,dy; + char *err = NULL; CHRONO("scale begin"); @@ -200,27 +201,30 @@ CHRONO("scale begin"); } dest->img=d=malloc(newx*newy*sizeof(rgb_group) +1); - if (!d) { free(new); error("Out of memory!\n"); } + if (d) { CHRONO("transfer begin"); - s=new; - y=newx*newy; - while (y--) - { - d->r=min((int)(s->r+0.5),255); - d->g=min((int)(s->g+0.5),255); - d->b=min((int)(s->b+0.5),255); - d++; s++; - } - - dest->xsize=newx; - dest->ysize=newy; + s=new; + y=newx*newy; + while (y--) { + d->r=min((int)(s->r+0.5),255); + d->g=min((int)(s->g+0.5),255); + d->b=min((int)(s->b+0.5),255); + d++; s++; + } + dest->xsize=newx; + dest->ysize=newy; + } free(new); CHRONO("scale end"); + THREADS_DISALLOW(); + if (!d) { + error("Out of memory!\n"); + } } /* Special, faster, case for scale=1/2 */