% Write Clip Mask To MIFF File. %
% %
% Software Design %
-% John Cristy %
+% Cristy %
% July 1992 %
% %
% %
-% Copyright 1999-2012 ImageMagick Studio LLC, a non-profit organization %
+% Copyright 1999-2015 ImageMagick Studio LLC, a non-profit organization %
% dedicated to making software imaging solutions freely available. %
% %
% You may not use this file except in compliance with the License. You may %
Include declarations.
*/
#include "MagickCore/studio.h"
+#include "MagickCore/attribute.h"
#include "MagickCore/blob.h"
#include "MagickCore/blob-private.h"
#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"
% %
% %
% %
+% 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
+ *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);
+ (void) CopyMagickString(read_info->magick,"MIFF",MagickPathExtent);
+ image=ReadImage(read_info,exception);
+ read_info=DestroyImageInfo(read_info);
+ if (image != (Image *) NULL)
+ {
+ Image
+ *clip_image;
+
+ (void) ClipImage(image,exception);
+ clip_image=GetImageMask(image,exception);
+ if (clip_image == (Image *) NULL)
+ ThrowReaderException(CoderError,"ImageDoesNotHaveAClipMask");
+ image=DestroyImage(image);
+ image=clip_image;
+ }
+ return(GetFirstImageInList(image));
+}
+\f
+/*
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+% %
+% %
+% %
% R e g i s t e r C L I P I m a g e %
% %
% %
MagickInfo
*entry;
- entry=SetMagickInfo("CLIP");
+ entry=AcquireMagickInfo("CLIP","CLIP","Image Clip Mask");
+ entry->decoder=(DecodeImageHandler *) ReadCLIPImage;
entry->encoder=(EncodeImageHandler *) WriteCLIPImage;
- entry->description=ConstantString("Image Clip Mask");
- entry->module=ConstantString("CLIP");
(void) RegisterMagickInfo(entry);
return(MagickImageCoderSignature);
}
MagickBooleanType
status;
- if (image->clip_mask == (Image *) NULL)
+ if (image->read_mask == MagickFalse)
(void) ClipImage(image,exception);
- if (image->clip_mask == (Image *) NULL)
+ if (image->read_mask == MagickFalse)
ThrowWriterException(CoderError,"ImageDoesNotHaveAClipMask");
- clip_image=CloneImage(image->clip_mask,0,0,MagickTrue,exception);
+ clip_image=GetImageMask(image,exception);
if (clip_image == (Image *) NULL)
return(MagickFalse);
- (void) SetImageType(clip_image,TrueColorType,exception);
- (void) CopyMagickString(clip_image->filename,image->filename,MaxTextExtent);
+ (void) CopyMagickString(clip_image->filename,image->filename,MagickPathExtent);
write_info=CloneImageInfo(image_info);
(void) SetImageInfo(write_info,1,exception);
if (LocaleCompare(write_info->magick,"CLIP") == 0)
- (void) FormatLocaleString(clip_image->filename,MaxTextExtent,"miff:%s",
+ (void) FormatLocaleString(clip_image->filename,MagickPathExtent,"miff:%s",
write_info->filename);
status=WriteImage(write_info,clip_image,exception);
clip_image=DestroyImage(clip_image);