2 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
10 % CCCC LLLLL IIIII P %
13 % Write Clip Mask To MIFF File. %
20 % Copyright 1999-2010 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 "magick/studio.h"
43 #include "magick/blob.h"
44 #include "magick/blob-private.h"
45 #include "magick/constitute.h"
46 #include "magick/exception.h"
47 #include "magick/exception-private.h"
48 #include "magick/magick.h"
49 #include "magick/memory_.h"
50 #include "magick/monitor.h"
51 #include "magick/monitor-private.h"
52 #include "magick/quantum-private.h"
53 #include "magick/static.h"
54 #include "magick/string_.h"
55 #include "magick/module.h"
60 static MagickBooleanType
61 WriteCLIPImage(const ImageInfo *,Image *);
64 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
68 % R e g i s t e r C L I P I m a g e %
72 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
74 % RegisterCLIPImage() adds attributes for the CLIP image format to
75 % the list of supported formats. The attributes include the image format
76 % tag, a method to read and/or write the format, whether the format
77 % supports the saving of more than one frame to the same file or blob,
78 % whether the format supports native in-memory I/O, and a brief
79 % description of the format.
81 % The format of the RegisterCLIPImage method is:
83 % size_t RegisterCLIPImage(void)
86 ModuleExport size_t RegisterCLIPImage(void)
91 entry=SetMagickInfo("CLIP");
92 entry->encoder=(EncodeImageHandler *) WriteCLIPImage;
93 entry->description=ConstantString("Image Clip Mask");
94 entry->module=ConstantString("CLIP");
95 (void) RegisterMagickInfo(entry);
96 return(MagickImageCoderSignature);
100 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
104 % U n r e g i s t e r C L I P I m a g e %
108 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
110 % UnregisterCLIPImage() removes format registrations made by the
111 % CLIP module from the list of supported formats.
113 % The format of the UnregisterCLIPImage method is:
115 % UnregisterCLIPImage(void)
118 ModuleExport void UnregisterCLIPImage(void)
120 (void) UnregisterMagickInfo("CLIP");
124 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
128 % W r i t e C L I P I m a g e %
132 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
134 % WriteCLIPImage() writes an image of clip bytes to a file. It consists of
135 % data from the clip mask of the image.
137 % The format of the WriteCLIPImage method is:
139 % MagickBooleanType WriteCLIPImage(const ImageInfo *image_info,
142 % A description of each parameter follows.
144 % o image_info: the image info.
146 % o image: The image.
149 static MagickBooleanType WriteCLIPImage(const ImageInfo *image_info,
161 if (image->clip_mask == (Image *) NULL)
162 (void) ClipImage(image);
163 if (image->clip_mask == (Image *) NULL)
164 ThrowWriterException(CoderError,"ImageDoesNotHaveAClipMask");
165 clip_image=CloneImage(image->clip_mask,0,0,MagickTrue,&image->exception);
166 if (clip_image == (Image *) NULL)
168 (void) SetImageType(clip_image,TrueColorType);
169 (void) CopyMagickString(clip_image->filename,image->filename,MaxTextExtent);
170 write_info=CloneImageInfo(image_info);
171 (void) SetImageInfo(write_info,1,&image->exception);
172 if (LocaleCompare(write_info->magick,"CLIP") == 0)
173 (void) FormatMagickString(clip_image->filename,MaxTextExtent,"miff:%s",
174 write_info->filename);
175 status=WriteImage(write_info,clip_image);
176 clip_image=DestroyImage(clip_image);
177 write_info=DestroyImageInfo(write_info);