]> granicus.if.org Git - imagemagick/commitdiff
(no commit message)
authorcristy <urban-warrior@git.imagemagick.org>
Sat, 30 Mar 2013 21:53:44 +0000 (21:53 +0000)
committercristy <urban-warrior@git.imagemagick.org>
Sat, 30 Mar 2013 21:53:44 +0000 (21:53 +0000)
coders/clip.c

index 36ae9aa6cb9c5e2310e819e8453653252b4ffa26..91887829741f8c11be4b6ee639166c2a45af50b0 100644 (file)
@@ -46,6 +46,7 @@
 #include "MagickCore/constitute.h"
 #include "MagickCore/exception.h"
 #include "MagickCore/exception-private.h"
+#include "MagickCore/list.h"
 #include "MagickCore/magick.h"
 #include "MagickCore/memory_.h"
 #include "MagickCore/monitor.h"
@@ -66,6 +67,66 @@ static MagickBooleanType
 %                                                                             %
 %                                                                             %
 %                                                                             %
+%   R e a d C L I P I m a g e                                                 %
+%                                                                             %
+%                                                                             %
+%                                                                             %
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%
+%  ReadCLIPImage returns the rendered clip path associated with the image.
+%
+%  The format of the ReadCLIPImage method is:
+%
+%      Image *ReadCLIPImage(const ImageInfo *image_info,
+%        ExceptionInfo *exception)
+%
+%  A description of each parameter follows:
+%
+%    o image_info: the image info.
+%
+%    o exception: return any errors or warnings in this structure.
+%
+*/
+static Image *ReadCLIPImage(const ImageInfo *image_info,
+  ExceptionInfo *exception)
+{
+  Image
+    *clip_image,
+    *image;
+
+  ImageInfo
+    *read_info;
+
+  /*
+    Initialize Image structure.
+  */
+  assert(image_info != (const ImageInfo *) NULL);
+  assert(image_info->signature == MagickSignature);
+  if (image_info->debug != MagickFalse)
+    (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",
+      image_info->filename);
+  assert(exception != (ExceptionInfo *) NULL);
+  assert(exception->signature == MagickSignature);
+  read_info=CloneImageInfo(image_info);
+  SetImageInfoBlob(read_info,(void *) NULL,0);
+  *read_info->magick='\0';
+  clip_image=ReadImage(read_info,exception);
+  read_info=DestroyImageInfo(read_info);
+  if (clip_image == (Image *) NULL)
+    return((Image *) NULL);
+  (void) ClipImage(clip_image,exception);
+  image=GetImageMask(clip_image,exception);
+  clip_image=DestroyImage(clip_image);
+  if (image == (Image *) NULL)
+    ThrowReaderException(CoderError,"ImageDoesNotHaveAClipMask");
+  return(GetFirstImageInList(image));
+}
+\f
+/*
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%                                                                             %
+%                                                                             %
+%                                                                             %
 %   R e g i s t e r C L I P I m a g e                                         %
 %                                                                             %
 %                                                                             %
@@ -90,6 +151,7 @@ ModuleExport size_t RegisterCLIPImage(void)
     *entry;
 
   entry=SetMagickInfo("CLIP");
+  entry->decoder=(DecodeImageHandler *) ReadCLIPImage;
   entry->encoder=(EncodeImageHandler *) WriteCLIPImage;
   entry->description=ConstantString("Image Clip Mask");
   entry->module=ConstantString("CLIP");