Powered by Pair ImageMagick logo
Image Magick
Main Page | Namespace List | Class Hierarchy | Alphabetical List | Data Structures | File List | Namespace Members | Data Fields | Globals | Related Pages

ImageMagick-6.1.1/coders/mpr.c

Go to the documentation of this file.
00001 /* 00002 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 00003 % % 00004 % % 00005 % % 00006 % M M PPPP RRRR % 00007 % MM MM P P R R % 00008 % M M M PPPP RRRR % 00009 % M M P R R % 00010 % M M P R R % 00011 % % 00012 % % 00013 % Read/Write the Magick Persistent Registry. % 00014 % % 00015 % Software Design % 00016 % John Cristy % 00017 % July 1992 % 00018 % % 00019 % % 00020 % Copyright 1999-2004 ImageMagick Studio LLC, a non-profit organization % 00021 % dedicated to making software imaging solutions freely available. % 00022 % % 00023 % You may not use this file except in compliance with the License. You may % 00024 % obtain a copy of the License at % 00025 % % 00026 % http://www.imagemagick.org/www/Copyright.html % 00027 % % 00028 % Unless required by applicable law or agreed to in writing, software % 00029 % distributed under the License is distributed on an "AS IS" BASIS, % 00030 % WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. % 00031 % See the License for the specific language governing permissions and % 00032 % limitations under the License. % 00033 % % 00034 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 00035 % 00036 % 00037 */ 00038 00039 /* 00040 Include declarations. 00041 */ 00042 #include "magick/studio.h" 00043 #include "magick/blob.h" 00044 #include "magick/blob_private.h" 00045 #include "magick/error.h" 00046 #include "magick/error_private.h" 00047 #include "magick/magick.h" 00048 #include "magick/memory_.h" 00049 #include "magick/registry.h" 00050 #include "magick/static.h" 00051 #include "magick/string_.h" 00052 00053 /* 00054 Forward declarations. 00055 */ 00056 static MagickBooleanType 00057 WriteMPRImage(const ImageInfo *,Image *); 00058 00059 /* 00060 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 00061 % % 00062 % % 00063 % % 00064 % R e a d M P R I m a g e % 00065 % % 00066 % % 00067 % % 00068 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 00069 % 00070 % ReadMPRImage() reads a Magick Persistent Registry image as a blob from 00071 % memory. It allocates the memory necessary for the new Image structure and 00072 % returns a pointer to the new image. 00073 % 00074 % The format of the ReadMPRImage method is: 00075 % 00076 % Image *ReadMPRImage(const ImageInfo *image_info, 00077 % ExceptionInfo *exception) 00078 % 00079 % A description of each parameter follows: 00080 % 00081 % o image_info: The image info. 00082 % 00083 % o exception: return any errors or warnings in this structure. 00084 % 00085 % 00086 */ 00087 static Image *ReadMPRImage(const ImageInfo *image_info, 00088 ExceptionInfo *exception) 00089 { 00090 char 00091 *p; 00092 00093 long 00094 id; 00095 00096 RegistryType 00097 type; 00098 00099 size_t 00100 length; 00101 00102 assert(image_info != (const ImageInfo *) NULL); 00103 assert(image_info->signature == MagickSignature); 00104 if (image_info->debug != MagickFalse) 00105 (void) LogMagickEvent(TraceEvent,GetMagickModule(),image_info->filename); 00106 assert(exception != (ExceptionInfo *) NULL); 00107 assert(exception->signature == MagickSignature); 00108 if (LocaleCompare(image_info->magick,"MPRI") != 0) 00109 return(GetImageFromMagickRegistry(image_info->filename,&id,exception)); 00110 id=strtol(image_info->filename,&p,0); 00111 return((Image *) GetMagickRegistry(id,&type,&length,exception)); 00112 } 00113 00114 /* 00115 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 00116 % % 00117 % % 00118 % % 00119 % R e g i s t e r M P R I m a g e % 00120 % % 00121 % % 00122 % % 00123 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 00124 % 00125 % RegisterMPRImage() adds attributes for the MPR image format to 00126 % the list of supported formats. The attributes include the image format 00127 % tag, a method to read and/or write the format, whether the format 00128 % supports the saving of more than one frame to the same file or blob, 00129 % whether the format supports native in-memory I/O, and a brief 00130 % description of the format. 00131 % 00132 % The format of the RegisterMPRImage method is: 00133 % 00134 % RegisterMPRImage(void) 00135 % 00136 */ 00137 ModuleExport void RegisterMPRImage(void) 00138 { 00139 MagickInfo 00140 *entry; 00141 00142 entry=SetMagickInfo("MPR"); 00143 entry->decoder=(DecoderHandler *) ReadMPRImage; 00144 entry->encoder=(EncoderHandler *) WriteMPRImage; 00145 entry->adjoin=MagickFalse; 00146 entry->stealth=MagickTrue; 00147 entry->description=AcquireString("Magick Persistent Registry"); 00148 entry->module=AcquireString("MPR"); 00149 (void) RegisterMagickInfo(entry); 00150 entry=SetMagickInfo("MPRI"); 00151 entry->decoder=(DecoderHandler *) ReadMPRImage; 00152 entry->encoder=(EncoderHandler *) WriteMPRImage; 00153 entry->stealth=MagickTrue; 00154 entry->adjoin=MagickFalse; 00155 entry->stealth=MagickTrue; 00156 entry->description=AcquireString("Magick Persistent Registry"); 00157 entry->module=AcquireString("MPRI"); 00158 (void) RegisterMagickInfo(entry); 00159 } 00160 00161 /* 00162 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 00163 % % 00164 % % 00165 % % 00166 % U n r e g i s t e r M P R I m a g e % 00167 % % 00168 % % 00169 % % 00170 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 00171 % 00172 % UnregisterMPRImage() removes format registrations made by the 00173 % MPR module from the list of supported formats. 00174 % 00175 % The format of the UnregisterMPRImage method is: 00176 % 00177 % UnregisterMPRImage(void) 00178 % 00179 */ 00180 ModuleExport void UnregisterMPRImage(void) 00181 { 00182 (void) UnregisterMagickInfo("MPR"); 00183 (void) UnregisterMagickInfo("MPRI"); 00184 } 00185 00186 /* 00187 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 00188 % % 00189 % % 00190 % % 00191 % W r i t e M P R I m a g e % 00192 % % 00193 % % 00194 % % 00195 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 00196 % 00197 % WriteMPRImage() writes an image into the Magick Persistent Registry 00198 % image as a blob from memory. It allocates the memory necessary for the 00199 % new Image structure and returns a pointer to the new image. 00200 % 00201 % The format of the WriteMPRImage method is: 00202 % 00203 % MagickBooleanType WriteMPRImage(const ImageInfo *image_info,Image *image) 00204 % 00205 % A description of each parameter follows. 00206 % 00207 % o image_info: The image info. 00208 % 00209 % o image: The image. 00210 % 00211 % 00212 */ 00213 static MagickBooleanType WriteMPRImage(const ImageInfo *image_info,Image *image) 00214 { 00215 ExceptionInfo 00216 exception; 00217 00218 Image 00219 *registry_image; 00220 00221 long 00222 id; 00223 00224 assert(image_info != (const ImageInfo *) NULL); 00225 assert(image_info->signature == MagickSignature); 00226 assert(image != (Image *) NULL); 00227 assert(image->signature == MagickSignature); 00228 if (image->debug != MagickFalse) 00229 (void) LogMagickEvent(TraceEvent,GetMagickModule(),image->filename); 00230 GetExceptionInfo(&exception); 00231 registry_image=GetImageFromMagickRegistry(image->filename,&id,&exception); 00232 DestroyExceptionInfo(&exception); 00233 if (registry_image != (Image *) NULL) 00234 { 00235 (void) DeleteMagickRegistry(id); 00236 registry_image=DestroyImage(registry_image); 00237 } 00238 id=SetMagickRegistry(ImageRegistryType,image,sizeof(Image),&image->exception); 00239 return((MagickBooleanType) (id >= 0)); 00240 }

Generated on Mon Oct 25 13:40:38 2004 for ImageMagick by doxygen 1.3.7
ImageMagick Copyright © 2004, ImageMagick Studio LLC