Hi.  I'm looking at the ImageMagick 6.3.7 source code,
wand/magick-image.c, and see

| MagickExport MagickBooleanType MagickSegmentImage(MagickWand *wand,
|    const ColorspaceType colorspace,const MagickBooleanType verbose,
|    const double cluster_threshold,const double smooth_threshold)
|  {
|    MagickBooleanType
|      status;
|
|   assert(wand != (MagickWand *) NULL);
|   assert(wand->signature == WandSignature);
|   if (wand->debug != MagickFalse)
|     (void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",wand->name);
|   if (wand->images == (Image *) NULL)
|     ThrowWandException(WandError,"ContainsNoImages",wand->name);
|   status=SegmentImage(wand->images,colorspace,verbose,cluster_threshold,
|     smooth_threshold);
|   if (status == MagickFalse)
|     InheritException(wand->exception,&wand->images->exception);
|   return(MagickFalse);
| }

Shouldn't that last line be 

    return(status);

?  As written, the call always fails, even if it doesn't.

(Insert obligatory apologies if this has come up before - I'm new and
did just a cursory seearch.)


While we're on the subject of boolean algebra, in magick/resize.c,
ResizeImage(), there are calls to two sequential filtering functions:

|       status=HorizontalFilter(resize_filter,image,filter_image,x_factor,span, 
|         &quantum,exception);
|       status|=VerticalFilter(resize_filter,filter_image,resize_image,y_factor,
|         span,&quantum,exception);                                             

I read that as "first we squish the image in one direction, then in the other."
That status is later used to figure out whether an allocation failed:

|  if (status == MagickFalse)
|    {
|      resize_image=DestroyImage(resize_image);
|      ThrowImageException(ResourceLimitError,"MemoryAllocationFailed");
|    }

Since MagickFalse is 0 (as of magick-type.h), status will only be false
if *both*  HorizontalFilter() *and* VerticalFilter() suffered allocation
failures.  Is that really what was intended?  Or did the author mean &= ?
Or am I misinterpreting the way I'm supposed to detect and handle errors?

Thanks!

Jutta <[EMAIL PROTECTED]>
_______________________________________________
Magick-bugs mailing list
[email protected]
http://studio.imagemagick.org/mailman/listinfo/magick-bugs

Reply via email to