2 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
10 % CCCC LLLLL IIIII P %
13 % Write Clip Mask To MIFF File. %
20 % Copyright 1999-2013 ImageMagick Studio LLC, a non-profit organization %
21 % dedicated to making software imaging solutions freely available. %
23 % You may not use this file except in compliance with the License. You may %
24 % obtain a copy of the License at %
26 % http://www.imagemagick.org/script/license.php %
28 % Unless required by applicable law or agreed to in writing, software %
29 % distributed under the License is distributed on an "AS IS" BASIS, %
30 % WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. %
31 % See the License for the specific language governing permissions and %
32 % limitations under the License. %
34 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
42 #include "MagickCore/studio.h"
43 #include "MagickCore/attribute.h"
44 #include "MagickCore/blob.h"
45 #include "MagickCore/blob-private.h"
46 #include "MagickCore/constitute.h"
47 #include "MagickCore/exception.h"
48 #include "MagickCore/exception-private.h"
49 #include "MagickCore/magick.h"
50 #include "MagickCore/memory_.h"
51 #include "MagickCore/monitor.h"
52 #include "MagickCore/monitor-private.h"
53 #include "MagickCore/quantum-private.h"
54 #include "MagickCore/static.h"
55 #include "MagickCore/string_.h"
56 #include "MagickCore/module.h"
61 static MagickBooleanType
62 WriteCLIPImage(const ImageInfo *,Image *,ExceptionInfo *);
65 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
69 % R e g i s t e r C L I P I m a g e %
73 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
75 % RegisterCLIPImage() adds attributes for the CLIP image format to
76 % the list of supported formats. The attributes include the image format
77 % tag, a method to read and/or write the format, whether the format
78 % supports the saving of more than one frame to the same file or blob,
79 % whether the format supports native in-memory I/O, and a brief
80 % description of the format.
82 % The format of the RegisterCLIPImage method is:
84 % size_t RegisterCLIPImage(void)
87 ModuleExport size_t RegisterCLIPImage(void)
92 entry=SetMagickInfo("CLIP");
93 entry->encoder=(EncodeImageHandler *) WriteCLIPImage;
94 entry->description=ConstantString("Image Clip Mask");
95 entry->module=ConstantString("CLIP");
96 (void) RegisterMagickInfo(entry);
97 return(MagickImageCoderSignature);
101 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
105 % U n r e g i s t e r C L I P I m a g e %
109 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
111 % UnregisterCLIPImage() removes format registrations made by the
112 % CLIP module from the list of supported formats.
114 % The format of the UnregisterCLIPImage method is:
116 % UnregisterCLIPImage(void)
119 ModuleExport void UnregisterCLIPImage(void)
121 (void) UnregisterMagickInfo("CLIP");
125 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
129 % W r i t e C L I P I m a g e %
133 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
135 % WriteCLIPImage() writes an image of clip bytes to a file. It consists of
136 % data from the clip mask of the image.
138 % The format of the WriteCLIPImage method is:
140 % MagickBooleanType WriteCLIPImage(const ImageInfo *image_info,
141 % Image *image,ExceptionInfo *exception)
143 % A description of each parameter follows.
145 % o image_info: the image info.
147 % o image: The image.
149 % o exception: return any errors or warnings in this structure.
152 static MagickBooleanType WriteCLIPImage(const ImageInfo *image_info,
153 Image *image,ExceptionInfo *exception)
164 if (image->mask == MagickFalse)
165 (void) ClipImage(image,exception);
166 if (image->mask == MagickFalse)
167 ThrowWriterException(CoderError,"ImageDoesNotHaveAClipMask");
168 clip_image=GetImageMask(image,exception);
169 if (clip_image == (Image *) NULL)
171 (void) CopyMagickString(clip_image->filename,image->filename,MaxTextExtent);
172 write_info=CloneImageInfo(image_info);
173 (void) SetImageInfo(write_info,1,exception);
174 if (LocaleCompare(write_info->magick,"CLIP") == 0)
175 (void) FormatLocaleString(clip_image->filename,MaxTextExtent,"miff:%s",
176 write_info->filename);
177 status=WriteImage(write_info,clip_image,exception);
178 clip_image=DestroyImage(clip_image);
179 write_info=DestroyImageInfo(write_info);