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/art.c

Go to the documentation of this file.
00001 /* 00002 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 00003 % % 00004 % % 00005 % AAA RRRR TTTTT % 00006 % A A R R T % 00007 % AAAAA RRRR T % 00008 % A A R R T % 00009 % A A R R T % 00010 % % 00011 % % 00012 % Read/Write PFS: 1st Publisher Image Format. % 00013 % % 00014 % Software Design % 00015 % Jaroslav Fojtik % 00016 % January 2001 % 00017 % % 00018 % % 00019 % Permission is hereby granted, free of charge, to any person obtaining a % 00020 % copy of this software and associated documentation files ("ImageMagick"), % 00021 % to deal in ImageMagick without restriction, including without limitation % 00022 % the rights to use, copy, modify, merge, publish, distribute, sublicense, % 00023 % and/or sell copies of ImageMagick, and to permit persons to whom the % 00024 % ImageMagick is furnished to do so, subject to the following conditions: % 00025 % % 00026 % The above copyright notice and this permission notice shall be included in % 00027 % all copies or substantial portions of ImageMagick. % 00028 % % 00029 % The software is provided "as is", without warranty of any kind, express or % 00030 % implied, including but not limited to the warranties of merchantability, % 00031 % fitness for a particular purpose and noninfringement. In no event shall % 00032 % ImageMagick Studio be liable for any claim, damages or other liability, % 00033 % whether in an action of contract, tort or otherwise, arising from, out of % 00034 % or in connection with ImageMagick or the use or other dealings in % 00035 % ImageMagick. % 00036 % % 00037 % Except as contained in this notice, the name of the ImageMagick Studio % 00038 % shall not be used in advertising or otherwise to promote the sale, use or % 00039 % other dealings in ImageMagick without prior written authorization from the % 00040 % ImageMagick Studio. % 00041 % % 00042 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 00043 % 00044 % 00045 */ 00046 00047 /* 00048 Include declarations. 00049 */ 00050 #include "magick/studio.h" 00051 #include "magick/blob.h" 00052 #include "magick/blob_private.h" 00053 #include "magick/error.h" 00054 #include "magick/error_private.h" 00055 #include "magick/image.h" 00056 #include "magick/image_private.h" 00057 #include "magick/list.h" 00058 #include "magick/log.h" 00059 #include "magick/magick.h" 00060 #include "magick/memory_.h" 00061 #include "magick/monitor.h" 00062 #include "magick/static.h" 00063 #include "magick/string_.h" 00064 00065 00066 static void InsertRow(unsigned char *p,int y,Image *image) 00067 { 00068 unsigned long bit; long x; 00069 register PixelPacket *q; 00070 IndexPacket index; 00071 register IndexPacket *indexes; 00072 00073 00074 switch (image->depth) 00075 { 00076 case 1: /* Convert bitmap scanline. */ 00077 { 00078 q=SetImagePixels(image,0,y,image->columns,1); 00079 if (q == (PixelPacket *) NULL) 00080 break; 00081 indexes=GetIndexes(image); 00082 for (x=0; x < ((long) image->columns-7); x+=8) 00083 { 00084 for (bit=0; bit < 8; bit++) 00085 { 00086 index=(IndexPacket) (((*p) & (0x80 >> bit)) != 0 ? 0x01 : 0x00); 00087 indexes[x+bit]=index; 00088 *q++=image->colormap[index]; 00089 } 00090 p++; 00091 } 00092 if ((image->columns % 8) != 0) 00093 { 00094 for (bit=0; bit < (image->columns % 8); bit++) 00095 { 00096 index=(IndexPacket) (((*p) & (0x80 >> bit)) != 0 ? 0x01 : 0x00); 00097 indexes[x+bit]=index; 00098 *q++=image->colormap[index]; 00099 } 00100 p++; 00101 } 00102 if (SyncImagePixels(image) == MagickFalse) 00103 break; 00104 /* if (image->previous == (Image *) NULL) 00105 if (QuantumTick(y,image->rows) != MagickFalse) 00106 ProgressMonitor(LoadImageTag,image->rows-y-1,image->rows);*/ 00107 break; 00108 } 00109 } 00110 } 00111 00112 00113 00114 /* 00115 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 00116 % % 00117 % % 00118 % % 00119 % R e a d A R T I m a g e % 00120 % % 00121 % % 00122 % % 00123 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 00124 % 00125 % ReadARTImage() reads an ART X image file and returns it. It 00126 % allocates the memory necessary for the new Image structure and returns a 00127 % pointer to the new image. 00128 % 00129 % The format of the ReadARTImage method is: 00130 % 00131 % Image *ReadARTImage(const ImageInfo *image_info,ExceptionInfo *exception) 00132 % 00133 % A description of each parameter follows: 00134 % 00135 % o image_info: The image info. 00136 % 00137 % o exception: return any errors or warnings in this structure. 00138 % 00139 % 00140 */ 00141 static Image *ReadARTImage(const ImageInfo *image_info,ExceptionInfo *exception) 00142 { 00143 Image *image; 00144 int i; 00145 unsigned long width,height,dummy; 00146 long ldblk; 00147 unsigned char *BImgBuff=NULL; 00148 unsigned char k; 00149 MagickBooleanType status; 00150 00151 /* 00152 Open image file. 00153 */ 00154 assert(image_info != (const ImageInfo *) NULL); 00155 assert(image_info->signature == MagickSignature); 00156 if (image_info->debug != MagickFalse) 00157 (void) LogMagickEvent(TraceEvent,GetMagickModule(),image_info->filename); 00158 assert(exception != (ExceptionInfo *) NULL); 00159 assert(exception->signature == MagickSignature); 00160 image=AllocateImage(image_info); 00161 status=OpenBlob(image_info,image,ReadBinaryBlobMode,exception); 00162 if (status == MagickFalse) 00163 { 00164 DestroyImageList(image); 00165 return((Image *) NULL); 00166 } 00167 /* 00168 Read ART image. 00169 */ 00170 dummy=ReadBlobLSBShort(image); 00171 width=ReadBlobLSBShort(image); 00172 dummy=ReadBlobLSBShort(image); 00173 height=ReadBlobLSBShort(image); 00174 00175 ldblk=(long) ((width+7) / 8); 00176 k=(unsigned char) ((-ldblk) & 0x01); 00177 if (GetBlobSize(image) != (MagickSizeType) (8+(ldblk+(long) k)*height)) 00178 ThrowReaderException(CorruptImageError,"ImproperImageHeader"); 00179 image->columns=width; 00180 image->rows=height; 00181 image->depth=1; 00182 image->colors=1l << image->depth; 00183 00184 /* printf("ART header checked OK %d,%d\n",image->colors,image->depth); */ 00185 00186 if (AllocateImageColormap(image,image->colors) == MagickFalse) goto NoMemory; 00187 00188 /* ----- Load RLE compressed raster ----- */ 00189 BImgBuff=(unsigned char *) AcquireMagickMemory((size_t) ldblk); /*Ldblk was set in the check phase*/ 00190 if (BImgBuff==NULL) 00191 NoMemory: 00192 ThrowReaderException(ResourceLimitError,"MemoryAllocationFailed"); 00193 for (i=0;i< (int) height;i++) 00194 { 00195 (void) ReadBlob(image,(size_t) ldblk,BImgBuff); 00196 (void) ReadBlob(image,(size_t) k,(unsigned char *) &dummy); 00197 InsertRow(BImgBuff,i,image); 00198 } 00199 BImgBuff=(unsigned char *) RelinquishMagickMemory(BImgBuff); 00200 if (EOFBlob(image) != MagickFalse) 00201 ThrowFileException(exception,CorruptImageError,"UnexpectedEndOfFile", 00202 image->filename); 00203 CloseBlob(image); 00204 return(GetFirstImageInList(image)); 00205 } 00206 00207 /* 00208 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 00209 % % 00210 % % 00211 % % 00212 % R e g i s t e r A R T I m a g e % 00213 % % 00214 % % 00215 % % 00216 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 00217 % 00218 % RegisterARTImage() adds attributes for the ART image format to 00219 % the list of supported formats. The attributes include the image format 00220 % tag, a method to read and/or write the format, whether the format 00221 % supports the saving of more than one frame to the same file or blob, 00222 % whether the format supports native in-memory I/O, and a brief 00223 % description of the format. 00224 % 00225 % The format of the RegisterARTImage method is: 00226 % 00227 % RegisterARTImage(void) 00228 % 00229 */ 00230 ModuleExport void RegisterARTImage(void) 00231 { 00232 MagickInfo 00233 *entry; 00234 00235 static const char 00236 *ARTNote= 00237 { 00238 "Format originally used on the Macintosh (MacPaint?) and later used\n" 00239 "for PFS: 1st Publisher clip art. NOT the AOL ART format." 00240 }; 00241 00242 entry=SetMagickInfo("ART"); 00243 entry->decoder=(DecoderHandler *) ReadARTImage; 00244 entry->description=AcquireString("PFS: 1st Publisher"); 00245 entry->module=AcquireString("ART"); 00246 entry->note=AcquireString(ARTNote); 00247 (void) RegisterMagickInfo(entry); 00248 } 00249 00250 /* 00251 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 00252 % % 00253 % % 00254 % % 00255 % U n r e g i s t e r A R T I m a g e % 00256 % % 00257 % % 00258 % % 00259 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 00260 % 00261 % UnregisterARTImage() removes format registrations made by the 00262 % ART module from the list of supported formats. 00263 % 00264 % The format of the UnregisterARTImage method is: 00265 % 00266 % UnregisterARTImage(void) 00267 % 00268 */ 00269 ModuleExport void UnregisterARTImage(void) 00270 { 00271 (void) UnregisterMagickInfo("ART"); 00272 }

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