2 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
13 % Read/Write the Magick Persistent Registry. %
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/blob.h"
44 #include "MagickCore/blob-private.h"
45 #include "MagickCore/exception.h"
46 #include "MagickCore/exception-private.h"
47 #include "MagickCore/magick.h"
48 #include "MagickCore/memory_.h"
49 #include "MagickCore/registry.h"
50 #include "MagickCore/quantum-private.h"
51 #include "MagickCore/static.h"
52 #include "MagickCore/string_.h"
53 #include "MagickCore/module.h"
58 static MagickBooleanType
59 WriteMPRImage(const ImageInfo *,Image *,ExceptionInfo *);
62 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
66 % R e a d M P R I m a g e %
70 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
72 % ReadMPRImage() reads a Magick Persistent Registry image as a blob from
73 % memory. It allocates the memory necessary for the new Image structure and
74 % returns a pointer to the new image.
76 % The format of the ReadMPRImage method is:
78 % Image *ReadMPRImage(const ImageInfo *image_info,
79 % ExceptionInfo *exception)
81 % A description of each parameter follows:
83 % o image_info: the image info.
85 % o exception: return any errors or warnings in this structure.
88 static Image *ReadMPRImage(const ImageInfo *image_info,ExceptionInfo *exception)
93 assert(image_info != (const ImageInfo *) NULL);
94 assert(image_info->signature == MagickSignature);
95 if (image_info->debug != MagickFalse)
96 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",
97 image_info->filename);
98 assert(exception != (ExceptionInfo *) NULL);
99 assert(exception->signature == MagickSignature);
100 image=(Image *) GetImageRegistry(ImageRegistryType,image_info->filename,
102 if (image != (Image *) NULL)
103 (void) SyncImageSettings(image_info,image,exception);
108 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
112 % R e g i s t e r M P R I m a g e %
116 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
118 % RegisterMPRImage() adds attributes for the MPR image format to
119 % the list of supported formats. The attributes include the image format
120 % tag, a method to read and/or write the format, whether the format
121 % supports the saving of more than one frame to the same file or blob,
122 % whether the format supports native in-memory I/O, and a brief
123 % description of the format.
125 % The format of the RegisterMPRImage method is:
127 % size_t RegisterMPRImage(void)
130 ModuleExport size_t RegisterMPRImage(void)
135 entry=SetMagickInfo("MPR");
136 entry->decoder=(DecodeImageHandler *) ReadMPRImage;
137 entry->encoder=(EncodeImageHandler *) WriteMPRImage;
138 entry->adjoin=MagickFalse;
139 entry->format_type=ImplicitFormatType;
140 entry->stealth=MagickTrue;
141 entry->description=ConstantString("Magick Persistent Registry");
142 entry->module=ConstantString("MPR");
143 (void) RegisterMagickInfo(entry);
144 entry=SetMagickInfo("MPRI");
145 entry->decoder=(DecodeImageHandler *) ReadMPRImage;
146 entry->encoder=(EncodeImageHandler *) WriteMPRImage;
147 entry->adjoin=MagickFalse;
148 entry->format_type=ImplicitFormatType;
149 entry->stealth=MagickTrue;
150 entry->description=ConstantString("Magick Persistent Registry");
151 entry->module=ConstantString("MPRI");
152 (void) RegisterMagickInfo(entry);
153 return(MagickImageCoderSignature);
157 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
161 % U n r e g i s t e r M P R I m a g e %
165 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
167 % UnregisterMPRImage() removes format registrations made by the
168 % MPR module from the list of supported formats.
170 % The format of the UnregisterMPRImage method is:
172 % UnregisterMPRImage(void)
175 ModuleExport void UnregisterMPRImage(void)
177 (void) UnregisterMagickInfo("MPRI");
178 (void) UnregisterMagickInfo("MPR");
182 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
186 % W r i t e M P R I m a g e %
190 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
192 % WriteMPRImage() writes an image into the Magick Persistent Registry
193 % image as a blob from memory. It allocates the memory necessary for the
194 % new Image structure and returns a pointer to the new image.
196 % The format of the WriteMPRImage method is:
198 % MagickBooleanType WriteMPRImage(const ImageInfo *image_info,
199 % Image *image,ExceptionInfo *exception)
201 % A description of each parameter follows.
203 % o image_info: the image info.
205 % o image: The image.
207 % o exception: return any errors or warnings in this structure.
210 static MagickBooleanType WriteMPRImage(const ImageInfo *image_info,Image *image,
211 ExceptionInfo *exception)
216 assert(image_info != (const ImageInfo *) NULL);
217 assert(image_info->signature == MagickSignature);
218 assert(image != (Image *) NULL);
219 assert(image->signature == MagickSignature);
220 if (image->debug != MagickFalse)
221 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
222 status=SetImageRegistry(ImageRegistryType,image->filename,image,exception);