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/mpc.c File Reference

#include "magick/studio.h"
#include "magick/attribute.h"
#include "magick/blob.h"
#include "magick/blob_private.h"
#include "magick/cache.h"
#include "magick/color.h"
#include "magick/color_private.h"
#include "magick/constitute.h"
#include "magick/error.h"
#include "magick/error_private.h"
#include "magick/geometry.h"
#include "magick/hashmap.h"
#include "magick/image.h"
#include "magick/image_private.h"
#include "magick/list.h"
#include "magick/magick.h"
#include "magick/memory_.h"
#include "magick/monitor.h"
#include "magick/option.h"
#include "magick/profile.h"
#include "magick/static.h"
#include "magick/string_.h"
#include "magick/utility.h"

Include dependency graph for mpc.c:

Include dependency graph

Go to the source code of this file.

Defines

#define PopCharPixel(q, pixel)
#define PopLongPixel(q, pixel)
#define PopShortPixel(q, pixel)
#define PushCharPixel(pixel, p)
#define PushLongPixel(pixel, p)
#define PushShortPixel(pixel, p)

Functions

MagickBooleanType WriteMPCImage (const ImageInfo *, Image *)
MagickBooleanType IsMPC (const unsigned char *magick, const size_t length)
ImageReadMPCImage (const ImageInfo *image_info, ExceptionInfo *exception)
ModuleExport void RegisterMPCImage (void)
ModuleExport void UnregisterMPCImage (void)


Define Documentation

#define PopCharPixel q,
pixel   ) 
 

Value:

{ \ *(q)++=(unsigned char) (pixel); \ }

Definition at line 70 of file mpc.c.

#define PopLongPixel q,
pixel   ) 
 

Value:

{ \ *(q)++=(unsigned char) ((pixel) >> 24); \ *(q)++=(unsigned char) ((pixel) >> 16); \ *(q)++=(unsigned char) ((pixel) >> 8); \ *(q)++=(unsigned char) (pixel); \ }

Definition at line 74 of file mpc.c.

#define PopShortPixel q,
pixel   ) 
 

Value:

{ \ *(q)++=(unsigned char) ((pixel) >> 8); \ *(q)++=(unsigned char) (pixel); \ }

Definition at line 81 of file mpc.c.

#define PushCharPixel pixel,
 ) 
 

Value:

{ \ pixel=(unsigned long) (*(p)); \ (p)++; \ }

Definition at line 86 of file mpc.c.

#define PushLongPixel pixel,
 ) 
 

Value:

{ \ pixel=(unsigned long) \ ((*(p) << 24) | (*((p)+1) << 16) | (*((p)+2) << 8) | *((p)+3)); \ (p)+=4; \ }

Definition at line 91 of file mpc.c.

#define PushShortPixel pixel,
 ) 
 

Value:

{ \ pixel=(unsigned long) ((*(p) << 8) | *((p)+1)); \ (p)+=2; \ }

Definition at line 97 of file mpc.c.


Function Documentation

MagickBooleanType IsMPC const unsigned char *  magick,
const size_t  length
[static]
 

Definition at line 136 of file mpc.c.

References LocaleNCompare(), MagickBooleanType, MagickFalse, and MagickTrue.

Referenced by RegisterMPCImage().

00137 { 00138 if (length < 14) 00139 return(MagickFalse); 00140 if (LocaleNCompare((char *) magick,"id=MagickCache",14) == 0) 00141 return(MagickTrue); 00142 return(MagickFalse); 00143 }

Here is the call graph for this function:

Image* ReadMPCImage const ImageInfo image_info,
ExceptionInfo exception
[static]
 

Definition at line 174 of file mpc.c.

References AcquireMagickMemory(), AcquireString(), AcquireStringInfo(), AllocateImage(), AllocateImageColormap(), AllocateNextImage(), AppendElementToLinkedList(), AppendImageFormat(), assert, _Image::background_color, _PixelPacket::blue, _ChromaticityInfo::blue_primary, _Image::border_color, CacheError, _Image::chromaticity, ClassType, _Image::client_data, CloneString(), CloseBlob(), _Image::colormap, _Image::colors, _Image::colorspace, ColorspaceType, _Image::columns, _Image::compression, CompressionType, CopyMagickString(), CorruptImageError, _StringInfo::datum, _ImageInfo::debug, _Image::delay, _Image::depth, DestroyImage(), DestroyImageList(), DestroyLinkedList(), DestroyStringInfo(), _Image::directory, _Image::dispose, DisposeType, EOFBlob(), _Image::error, _Image::filename, _ImageInfo::filename, _Image::gamma, GetBlobSize(), GetFirstImageInList(), GetImageProfile(), GetImageQuantumDepth(), GetMagickModule, GetNextElementInLinkedList(), GetPageGeometry(), _PixelPacket::green, _ChromaticityInfo::green_primary, _Image::iterations, _StringInfo::length, LoadImagesTag, LocaleCompare(), LocaleNCompare(), LogMagickEvent(), MagickBooleanOptions, MagickBooleanType, MagickClassOptions, MagickColorspaceOptions, MagickCompressionOptions, MagickDisposeOptions, MagickFalse, MagickIntentOptions, MagickOffsetType, MagickProgressMonitor, MagickResolutionOptions, MagickSignature, MagickStatusType, MagickTrue, _Image::matte, _Image::matte_color, MaxTextExtent, _ErrorInfo::mean_error_per_pixel, _Image::montage, name, NewLinkedList(), _Image::next, NoCompression, _ErrorInfo::normalized_maximum_error, _ErrorInfo::normalized_mean_error, _ImageInfo::number_scenes, OpenBlob(), _Image::page, ParseAbsoluteGeometry(), ParseGeometry(), ParseMagickOption(), PersistCache(), _ImageInfo::ping, _Image::progress_monitor, PseudoClass, PushCharPixel, PushLongPixel, PushShortPixel, QuantumDepth, QueryColorDatabase(), ReadBinaryBlobMode, ReadBlob(), ReadBlobByte(), _PixelPacket::red, _ChromaticityInfo::red_primary, RelinquishMagickMemory(), _Image::rendering_intent, RenderingIntent, ResetLinkedListIterator(), ResizeMagickMemory(), ResolutionType, ResourceLimitError, _GeometryInfo::rho, _Image::rows, ScaleCharToQuantum, ScaleLongToQuantum, ScaleShortToQuantum, _ImageInfo::scene, _Image::scene, SetImageAttribute(), SetImageProfile(), _GeometryInfo::sigma, SigmaValue, _ExceptionInfo::signature, _ImageInfo::signature, _Image::storage_class, SyncNextImageInList(), TellBlob(), ThrowFileException, ThrowReaderException, TraceEvent, UndefinedClass, UndefinedCompression, _Image::units, _ChromaticityInfo::white_point, _PrimaryInfo::x, _Image::x_resolution, _PrimaryInfo::y, and _Image::y_resolution.

Referenced by RegisterMPCImage().

00175 { 00176 char 00177 cache_filename[MaxTextExtent], 00178 id[MaxTextExtent], 00179 keyword[MaxTextExtent], 00180 *options; 00181 00182 GeometryInfo 00183 geometry_info; 00184 00185 Image 00186 *image; 00187 00188 int 00189 c; 00190 00191 LinkedListInfo 00192 *profiles; 00193 00194 MagickBooleanType 00195 status; 00196 00197 MagickOffsetType 00198 offset; 00199 00200 MagickStatusType 00201 flags; 00202 00203 register long 00204 i; 00205 00206 register unsigned char 00207 *p; 00208 00209 size_t 00210 length; 00211 00212 StringInfo 00213 *profile; 00214 00215 unsigned long 00216 depth, 00217 quantum_depth; 00218 00219 /* 00220 Open image file. 00221 */ 00222 assert(image_info != (const ImageInfo *) NULL); 00223 assert(image_info->signature == MagickSignature); 00224 if (image_info->debug != MagickFalse) 00225 (void) LogMagickEvent(TraceEvent,GetMagickModule(),image_info->filename); 00226 assert(exception != (ExceptionInfo *) NULL); 00227 assert(exception->signature == MagickSignature); 00228 image=AllocateImage(image_info); 00229 status=OpenBlob(image_info,image,ReadBinaryBlobMode,exception); 00230 if (status == MagickFalse) 00231 { 00232 DestroyImageList(image); 00233 return((Image *) NULL); 00234 } 00235 (void) CopyMagickString(cache_filename,image->filename,MaxTextExtent); 00236 AppendImageFormat("cache",cache_filename); 00237 c=ReadBlobByte(image); 00238 if (c == EOF) 00239 { 00240 image=DestroyImage(image); 00241 return((Image *) NULL); 00242 } 00243 *id='\0'; 00244 offset=0; 00245 do 00246 { 00247 /* 00248 Decode image header; header terminates one character beyond a ':'. 00249 */ 00250 profiles=(LinkedListInfo *) NULL; 00251 length=MaxTextExtent; 00252 options=AcquireString((char *) NULL); 00253 quantum_depth=QuantumDepth; 00254 image->depth=8; 00255 image->compression=NoCompression; 00256 while ((isgraph(c) != MagickFalse) && (c != (int) ':')) 00257 { 00258 register char 00259 *p; 00260 00261 if (c == (int) '{') 00262 { 00263 char 00264 *comment; 00265 00266 /* 00267 Read comment-- any text between { }. 00268 */ 00269 length=MaxTextExtent; 00270 comment=AcquireString((char *) NULL); 00271 for (p=comment; comment != (char *) NULL; p++) 00272 { 00273 c=ReadBlobByte(image); 00274 if ((c == EOF) || (c == (int) '}')) 00275 break; 00276 if ((size_t) (p-comment+1) >= length) 00277 { 00278 *p='\0'; 00279 length<<=1; 00280 comment=(char *) ResizeMagickMemory(comment, 00281 (length+MaxTextExtent)*sizeof(*comment)); 00282 if (comment == (char *) NULL) 00283 break; 00284 p=comment+strlen(comment); 00285 } 00286 *p=(char) c; 00287 } 00288 if (comment == (char *) NULL) 00289 ThrowReaderException(ResourceLimitError,"MemoryAllocationFailed"); 00290 *p='\0'; 00291 (void) SetImageAttribute(image,"Comment",comment); 00292 comment=(char *) RelinquishMagickMemory(comment); 00293 c=ReadBlobByte(image); 00294 } 00295 else 00296 if (isalnum(c) != MagickFalse) 00297 { 00298 /* 00299 Get the keyword. 00300 */ 00301 p=keyword; 00302 do 00303 { 00304 if (isspace((int) ((unsigned char) c)) != 0) 00305 break; 00306 if (c == (int) '=') 00307 break; 00308 if ((size_t) (p-keyword) < (MaxTextExtent-1)) 00309 *p++=(char) c; 00310 c=ReadBlobByte(image); 00311 } while (c != EOF); 00312 *p='\0'; 00313 p=options; 00314 while (isspace((int) ((unsigned char) c)) != 0) 00315 c=ReadBlobByte(image); 00316 if (c == (int) '=') 00317 { 00318 /* 00319 Get the keyword value. 00320 */ 00321 c=ReadBlobByte(image); 00322 while ((c != (int) '}') && (c != EOF)) 00323 { 00324 if ((size_t) (p-options+1) >= length) 00325 { 00326 *p='\0'; 00327 length<<=1; 00328 options=(char *) ResizeMagickMemory(options, 00329 (length+MaxTextExtent)*sizeof(*options)); 00330 if (options == (char *) NULL) 00331 break; 00332 p=options+strlen(options); 00333 } 00334 if (options == (char *) NULL) 00335 ThrowReaderException(ResourceLimitError, 00336 "MemoryAllocationFailed"); 00337 *p++=(char) c; 00338 c=ReadBlobByte(image); 00339 if (*options != '{') 00340 if (isspace((int) ((unsigned char) c)) != 0) 00341 break; 00342 } 00343 } 00344 *p='\0'; 00345 if (*options == '{') 00346 (void) CopyMagickString(options,options+1,MaxTextExtent); 00347 /* 00348 Assign a value to the specified keyword. 00349 */ 00350 switch (*keyword) 00351 { 00352 case 'b': 00353 case 'B': 00354 { 00355 if (LocaleCompare(keyword,"background-color") == 0) 00356 { 00357 (void) QueryColorDatabase(options,&image->background_color, 00358 exception); 00359 break; 00360 } 00361 if (LocaleCompare(keyword,"blue-primary") == 0) 00362 { 00363 flags=ParseGeometry(options,&geometry_info); 00364 image->chromaticity.blue_primary.x=geometry_info.rho; 00365 image->chromaticity.blue_primary.y=geometry_info.sigma; 00366 if ((flags & SigmaValue) == 0) 00367 image->chromaticity.blue_primary.y= 00368 image->chromaticity.blue_primary.x; 00369 break; 00370 } 00371 if (LocaleCompare(keyword,"border-color") == 0) 00372 { 00373 (void) QueryColorDatabase(options,&image->border_color, 00374 exception); 00375 break; 00376 } 00377 (void) SetImageAttribute(image,keyword,options); 00378 break; 00379 } 00380 case 'c': 00381 case 'C': 00382 { 00383 if (LocaleCompare(keyword,"class") == 0) 00384 { 00385 image->storage_class=(ClassType) 00386 ParseMagickOption(MagickClassOptions,MagickFalse,options); 00387 break; 00388 } 00389 if (LocaleCompare(keyword,"colors") == 0) 00390 { 00391 image->colors=(unsigned long) atol(options); 00392 break; 00393 } 00394 if (LocaleCompare(keyword,"colorspace") == 0) 00395 { 00396 image->colorspace=(ColorspaceType) ParseMagickOption( 00397 MagickColorspaceOptions,MagickFalse,options); 00398 break; 00399 } 00400 if (LocaleCompare(keyword,"compression") == 0) 00401 { 00402 image->compression=(CompressionType) ParseMagickOption( 00403 MagickCompressionOptions,MagickFalse,options); 00404 break; 00405 } 00406 if (LocaleCompare(keyword,"columns") == 0) 00407 { 00408 image->columns=(unsigned long) atol(options); 00409 break; 00410 } 00411 (void) SetImageAttribute(image,keyword,options); 00412 break; 00413 } 00414 case 'd': 00415 case 'D': 00416 { 00417 if (LocaleCompare(keyword,"delay") == 0) 00418 { 00419 image->delay=(unsigned long) atol(options); 00420 break; 00421 } 00422 if (LocaleCompare(keyword,"depth") == 0) 00423 { 00424 image->depth=(unsigned long) atol(options); 00425 break; 00426 } 00427 if (LocaleCompare(keyword,"dispose") == 0) 00428 { 00429 image->dispose=(DisposeType) ParseMagickOption( 00430 MagickDisposeOptions,MagickFalse,options); 00431 break; 00432 } 00433 (void) SetImageAttribute(image,keyword,options); 00434 break; 00435 } 00436 case 'e': 00437 case 'E': 00438 { 00439 if (LocaleCompare(keyword,"error") == 0) 00440 { 00441 image->error.mean_error_per_pixel=atof(options); 00442 break; 00443 } 00444 (void) SetImageAttribute(image,keyword,options); 00445 break; 00446 } 00447 case 'g': 00448 case 'G': 00449 { 00450 if (LocaleCompare(keyword,"gamma") == 0) 00451 { 00452 image->gamma=atof(options); 00453 break; 00454 } 00455 if (LocaleCompare(keyword,"green-primary") == 0) 00456 { 00457 flags=ParseGeometry(options,&geometry_info); 00458 image->chromaticity.green_primary.x=geometry_info.rho; 00459 image->chromaticity.green_primary.y=geometry_info.sigma; 00460 if ((flags & SigmaValue) == 0) 00461 image->chromaticity.green_primary.y= 00462 image->chromaticity.green_primary.x; 00463 break; 00464 } 00465 (void) SetImageAttribute(image,keyword,options); 00466 break; 00467 } 00468 case 'i': 00469 case 'I': 00470 { 00471 if (LocaleCompare(keyword,"id") == 0) 00472 { 00473 (void) CopyMagickString(id,options,MaxTextExtent); 00474 break; 00475 } 00476 if (LocaleCompare(keyword,"iterations") == 0) 00477 { 00478 image->iterations=(unsigned long) atol(options); 00479 break; 00480 } 00481 (void) SetImageAttribute(image,keyword,options); 00482 break; 00483 } 00484 case 'm': 00485 case 'M': 00486 { 00487 if (LocaleCompare(keyword,"matte") == 0) 00488 { 00489 image->matte=(MagickBooleanType) ParseMagickOption( 00490 MagickBooleanOptions,MagickFalse,options); 00491 break; 00492 } 00493 if (LocaleCompare(keyword,"matte-color") == 0) 00494 { 00495 (void) QueryColorDatabase(options,&image->matte_color, 00496 exception); 00497 break; 00498 } 00499 if (LocaleCompare(keyword,"maximum-error") == 0) 00500 { 00501 image->error.normalized_maximum_error=atof(options); 00502 break; 00503 } 00504 if (LocaleCompare(keyword,"mean-error") == 0) 00505 { 00506 image->error.normalized_mean_error=atof(options); 00507 break; 00508 } 00509 if (LocaleCompare(keyword,"montage") == 0) 00510 { 00511 (void) CloneString(&image->montage,options); 00512 break; 00513 } 00514 (void) SetImageAttribute(image,keyword,options); 00515 break; 00516 } 00517 case 'p': 00518 case 'P': 00519 { 00520 if (LocaleCompare(keyword,"page") == 0) 00521 { 00522 char 00523 *geometry; 00524 00525 geometry=GetPageGeometry(options); 00526 (void) ParseAbsoluteGeometry(geometry,&image->page); 00527 geometry=(char *) RelinquishMagickMemory(geometry); 00528 break; 00529 } 00530 if (LocaleNCompare(keyword,"profile-",8) == 0) 00531 { 00532 if (profiles == (LinkedListInfo *) NULL) 00533 profiles=NewLinkedList(0); 00534 (void) AppendElementToLinkedList(profiles, 00535 AcquireString(keyword+8)); 00536 profile=AcquireStringInfo((size_t) atol(options)); 00537 (void) SetImageProfile(image,keyword+8,profile); 00538 profile=DestroyStringInfo(profile); 00539 break; 00540 } 00541 (void) SetImageAttribute(image,keyword,options); 00542 break; 00543 } 00544 case 'o': 00545 case 'O': 00546 { 00547 if (LocaleCompare(keyword,"opaque") == 0) 00548 { 00549 image->matte=(MagickBooleanType) ParseMagickOption( 00550 MagickBooleanOptions,MagickFalse,options); 00551 break; 00552 } 00553 (void) SetImageAttribute(image,keyword,options); 00554 break; 00555 } 00556 case 'q': 00557 case 'Q': 00558 { 00559 if (LocaleCompare(keyword,"quantum-depth") == 0) 00560 { 00561 quantum_depth=(unsigned long) atol(options); 00562 break; 00563 } 00564 (void) SetImageAttribute(image,keyword,options); 00565 break; 00566 } 00567 case 'r': 00568 case 'R': 00569 { 00570 if (LocaleCompare(keyword,"red-primary") == 0) 00571 { 00572 flags=ParseGeometry(options,&geometry_info); 00573 image->chromaticity.red_primary.x=geometry_info.rho; 00574 if ((flags & SigmaValue) != 0) 00575 image->chromaticity.red_primary.y=geometry_info.sigma; 00576 break; 00577 } 00578 if (LocaleCompare(keyword,"rendering-intent") == 0) 00579 { 00580 image->rendering_intent=(RenderingIntent) ParseMagickOption( 00581 MagickIntentOptions,MagickFalse,options); 00582 break; 00583 } 00584 if (LocaleCompare(keyword,"resolution") == 0) 00585 { 00586 flags=ParseGeometry(options,&geometry_info); 00587 image->x_resolution=geometry_info.rho; 00588 image->y_resolution=geometry_info.sigma; 00589 if ((flags & SigmaValue) == 0) 00590 image->y_resolution=image->x_resolution; 00591 break; 00592 } 00593 if (LocaleCompare(keyword,"rows") == 0) 00594 { 00595 image->rows=(unsigned long) atol(options); 00596 break; 00597 } 00598 (void) SetImageAttribute(image,keyword,options); 00599 break; 00600 } 00601 case 's': 00602 case 'S': 00603 { 00604 if (LocaleCompare(keyword,"scene") == 0) 00605 { 00606 image->scene=(unsigned long) atol(options); 00607 break; 00608 } 00609 (void) SetImageAttribute(image,keyword,options); 00610 break; 00611 } 00612 case 'u': 00613 case 'U': 00614 { 00615 if (LocaleCompare(keyword,"units") == 0) 00616 { 00617 image->units=(ResolutionType) ParseMagickOption( 00618 MagickResolutionOptions,MagickFalse,options); 00619 break; 00620 } 00621 (void) SetImageAttribute(image,keyword,options); 00622 break; 00623 } 00624 case 'w': 00625 case 'W': 00626 { 00627 if (LocaleCompare(keyword,"white-point") == 0) 00628 { 00629 flags=ParseGeometry(options,&geometry_info); 00630 image->chromaticity.white_point.x=geometry_info.rho; 00631 image->chromaticity.white_point.y=geometry_info.sigma; 00632 if ((flags & SigmaValue) == 0) 00633 image->chromaticity.white_point.y= 00634 image->chromaticity.white_point.x; 00635 break; 00636 } 00637 (void) SetImageAttribute(image,keyword,options); 00638 break; 00639 } 00640 default: 00641 { 00642 (void) SetImageAttribute(image,keyword,options); 00643 break; 00644 } 00645 } 00646 } 00647 else 00648 c=ReadBlobByte(image); 00649 while (isspace((int) ((unsigned char) c)) != 0) 00650 c=ReadBlobByte(image); 00651 } 00652 options=(char *) RelinquishMagickMemory(options); 00653 (void) ReadBlobByte(image); 00654 /* 00655 Verify that required image information is defined. 00656 */ 00657 if ((LocaleCompare(id,"MagickCache") != 0) || 00658 (image->storage_class == UndefinedClass) || 00659 (image->compression == UndefinedCompression) || (image->columns == 0) || 00660 (image->rows == 0)) 00661 ThrowReaderException(CorruptImageError,"ImproperImageHeader"); 00662 if (quantum_depth != QuantumDepth) 00663 ThrowReaderException(CacheError,"InconsistentPersistentCacheDepth"); 00664 if (image->montage != (char *) NULL) 00665 { 00666 register char 00667 *p; 00668 00669 /* 00670 Image directory. 00671 */ 00672 length=MaxTextExtent; 00673 image->directory=AcquireString((char *) NULL); 00674 p=image->directory; 00675 do 00676 { 00677 *p='\0'; 00678 if ((strlen(image->directory)+MaxTextExtent) >= length) 00679 { 00680 /* 00681 Allocate more memory for the image directory. 00682 */ 00683 length<<=1; 00684 image->directory=(char *) ResizeMagickMemory(image->directory, 00685 (length+MaxTextExtent)*sizeof(*image->directory)); 00686 if (image->directory == (char *) NULL) 00687 ThrowReaderException(CorruptImageError,"UnableToReadImageData"); 00688 p=image->directory+strlen(image->directory); 00689 } 00690 c=ReadBlobByte(image); 00691 *p++=(char) c; 00692 } while (c != (int) '\0'); 00693 } 00694 if (profiles != (LinkedListInfo *) NULL) 00695 { 00696 const char 00697 *name; 00698 00699 /* 00700 Read image profiles. 00701 */ 00702 ResetLinkedListIterator(profiles); 00703 name=(const char *) GetNextElementInLinkedList(profiles); 00704 while (name != (const char *) NULL) 00705 { 00706 profile=GetImageProfile(image,name); 00707 if (profile != (StringInfo *) NULL) 00708 (void) ReadBlob(image,profile->length,profile->datum); 00709 name=(const char *) GetNextElementInLinkedList(profiles); 00710 } 00711 profiles=DestroyLinkedList(profiles,RelinquishMagickMemory); 00712 } 00713 depth=GetImageQuantumDepth(image,MagickFalse); 00714 if (image->storage_class == PseudoClass) 00715 { 00716 /* 00717 Create image colormap. 00718 */ 00719 if (AllocateImageColormap(image,image->colors) == MagickFalse) 00720 ThrowReaderException(ResourceLimitError,"MemoryAllocationFailed"); 00721 if (image->colors != 0) 00722 { 00723 size_t 00724 packet_size; 00725 00726 unsigned char 00727 *colormap; 00728 00729 unsigned long 00730 pixel; 00731 00732 /* 00733 Read image colormap from file. 00734 */ 00735 packet_size=(size_t) (3*depth/8); 00736 colormap=(unsigned char *) 00737 AcquireMagickMemory(packet_size*image->colors); 00738 if (colormap == (unsigned char *) NULL) 00739 ThrowReaderException(ResourceLimitError,"MemoryAllocationFailed"); 00740 (void) ReadBlob(image,packet_size*image->colors,colormap); 00741 p=colormap; 00742 switch (depth) 00743 { 00744 default: 00745 ThrowReaderException(CorruptImageError, 00746 "ImageDepthNotSupported"); 00747 case 8: 00748 { 00749 for (i=0; i < (long) image->colors; i++) 00750 { 00751 PushCharPixel(pixel,p); 00752 image->colormap[i].red=ScaleCharToQuantum(pixel); 00753 PushCharPixel(pixel,p); 00754 image->colormap[i].green=ScaleCharToQuantum(pixel); 00755 PushCharPixel(pixel,p); 00756 image->colormap[i].blue=ScaleCharToQuantum(pixel); 00757 } 00758 break; 00759 } 00760 case 16: 00761 { 00762 for (i=0; i < (long) image->colors; i++) 00763 { 00764 PushShortPixel(pixel,p); 00765 image->colormap[i].red=ScaleShortToQuantum(pixel); 00766 PushShortPixel(pixel,p); 00767 image->colormap[i].green=ScaleShortToQuantum(pixel); 00768 PushShortPixel(pixel,p); 00769 image->colormap[i].blue=ScaleShortToQuantum(pixel); 00770 } 00771 break; 00772 } 00773 case 32: 00774 { 00775 for (i=0; i < (long) image->colors; i++) 00776 { 00777 PushLongPixel(pixel,p); 00778 image->colormap[i].red=ScaleLongToQuantum(pixel); 00779 PushLongPixel(pixel,p); 00780 image->colormap[i].green=ScaleLongToQuantum(pixel); 00781 PushLongPixel(pixel,p); 00782 image->colormap[i].blue=ScaleLongToQuantum(pixel); 00783 } 00784 break; 00785 } 00786 } 00787 colormap=(unsigned char *) RelinquishMagickMemory(colormap); 00788 } 00789 } 00790 if (EOFBlob(image) != MagickFalse) 00791 { 00792 ThrowFileException(exception,CorruptImageError,"UnexpectedEndOfFile", 00793 image->filename); 00794 break; 00795 } 00796 if ((image_info->ping != MagickFalse) && (image_info->number_scenes != 0)) 00797 if (image->scene >= (image_info->scene+image_info->number_scenes-1)) 00798 break; 00799 /* 00800 Attach persistent pixel cache. 00801 */ 00802 status=PersistCache(image,cache_filename,MagickTrue,&offset,exception); 00803 if (status == MagickFalse) 00804 ThrowReaderException(CacheError,"UnableToPersistPixelCache"); 00805 /* 00806 Proceed to next image. 00807 */ 00808 do 00809 { 00810 c=ReadBlobByte(image); 00811 } while ((isgraph(c) == MagickFalse) && (c != EOF)); 00812 if (c != EOF) 00813 { 00814 /* 00815 Allocate next image structure. 00816 */ 00817 AllocateNextImage(image_info,image); 00818 if (image->next == (Image *) NULL) 00819 { 00820 DestroyImageList(image); 00821 return((Image *) NULL); 00822 } 00823 image=SyncNextImageInList(image); 00824 if (image->progress_monitor != (MagickProgressMonitor) NULL) 00825 { 00826 status=image->progress_monitor(LoadImagesTag,TellBlob(image), 00827 GetBlobSize(image),image->client_data); 00828 if (status == MagickFalse) 00829 break; 00830 } 00831 } 00832 } while (c != EOF); 00833 CloseBlob(image); 00834 return(GetFirstImageInList(image)); 00835 }

Here is the call graph for this function:

ModuleExport void RegisterMPCImage void   ) 
 

Definition at line 860 of file mpc.c.

References AcquireString(), _MagickInfo::decoder, DecoderHandler, _MagickInfo::description, _MagickInfo::encoder, EncoderHandler, IsMPC(), _MagickInfo::magick, MagickHandler, _MagickInfo::module, ModuleExport, ReadMPCImage(), RegisterMagickInfo(), SetMagickInfo(), and WriteMPCImage().

Referenced by RegisterStaticModules().

00861 { 00862 MagickInfo 00863 *entry; 00864 00865 entry=SetMagickInfo("CACHE"); 00866 entry->description=AcquireString("Magick Persistent Cache image format"); 00867 entry->module=AcquireString("CACHE"); 00868 (void) RegisterMagickInfo(entry); 00869 entry=SetMagickInfo("MPC"); 00870 entry->decoder=(DecoderHandler *) ReadMPCImage; 00871 entry->encoder=(EncoderHandler *) WriteMPCImage; 00872 entry->magick=(MagickHandler *) IsMPC; 00873 entry->description=AcquireString("Magick Persistent Cache image format"); 00874 entry->module=AcquireString("MPC"); 00875 (void) RegisterMagickInfo(entry); 00876 }

Here is the call graph for this function:

ModuleExport void UnregisterMPCImage void   ) 
 

Definition at line 897 of file mpc.c.

References ModuleExport, and UnregisterMagickInfo().

Referenced by UnregisterStaticModules().

00898 { 00899 (void) UnregisterMagickInfo("CACHE"); 00900 (void) UnregisterMagickInfo("MPC"); 00901 }

Here is the call graph for this function:

MagickBooleanType WriteMPCImage const ImageInfo ,
Image
[static]
 

Definition at line 928 of file mpc.c.

References AcquireMagickMemory(), _ImageInfo::adjoin, AppendImageFormat(), assert, _PixelPacket::blue, _ChromaticityInfo::blue_primary, CacheError, _Image::chromaticity, _Image::client_data, CloseBlob(), _Image::colormap, _Image::colors, _Image::colorspace, _Image::columns, _Image::compose, _Image::compression, CopyMagickString(), CorruptImageError, _StringInfo::datum, _Image::debug, _Image::delay, _Image::depth, _Image::directory, _Image::dispose, _Image::error, _Image::exception, _Image::filename, FormatMagickString(), _Image::gamma, GetImageAttribute(), GetImageListLength(), GetImageProfile(), GetImageQuantumDepth(), GetMagickModule, GetNextImageProfile(), _PixelPacket::green, _ChromaticityInfo::green_primary, _RectangleInfo::height, Image, _Image::iterations, _ImageAttribute::key, _StringInfo::length, LogMagickEvent(), MagickBooleanOptions, MagickBooleanType, MagickClassOptions, MagickColorspaceOptions, MagickCompositeOptions, MagickCompressionOptions, MagickDisposeOptions, MagickFalse, MagickIntentOptions, MagickOffsetType, MagickOptionToMnemonic(), MagickProgressMonitor, MagickResolutionOptions, MagickSignature, MagickTrue, _Image::matte, MaxTextExtent, _ErrorInfo::mean_error_per_pixel, _Image::montage, name, _ImageAttribute::next, _Image::next, _ErrorInfo::normalized_maximum_error, _ErrorInfo::normalized_mean_error, OpenBlob(), _Image::page, PersistCache(), PopCharPixel, PopLongPixel, PopShortPixel, _Image::previous, _Image::profiles, _Image::progress_monitor, PseudoClass, QuantumDepth, _PixelPacket::red, _ChromaticityInfo::red_primary, RelinquishMagickMemory(), _Image::rendering_intent, ResetImageProfileIterator(), _Image::rows, SaveImagesTag, ScaleQuantumToChar, ScaleQuantumToLong, ScaleQuantumToShort, _Image::scene, _Image::signature, _ImageInfo::signature, _Image::storage_class, SyncNextImageInList(), ThrowWriterException, TraceEvent, UndefinedColorspace, UndefinedCompositeOp, UndefinedCompression, UndefinedDispose, UndefinedIntent, UndefinedResolution, _Image::units, _ImageAttribute::value, _ChromaticityInfo::white_point, _RectangleInfo::width, WriteBinaryBlobMode, WriteBlob(), WriteBlobByte(), WriteBlobString(), _PrimaryInfo::x, _RectangleInfo::x, _Image::x_resolution, _PrimaryInfo::y, _RectangleInfo::y, and _Image::y_resolution.

Referenced by RegisterMPCImage().

00929 { 00930 char 00931 buffer[MaxTextExtent], 00932 cache_filename[MaxTextExtent]; 00933 00934 const ImageAttribute 00935 *attribute; 00936 00937 MagickBooleanType 00938 status; 00939 00940 MagickOffsetType 00941 offset, 00942 scene; 00943 00944 register long 00945 i; 00946 00947 /* 00948 Open persistent cache. 00949 */ 00950 assert(image_info != (const ImageInfo *) NULL); 00951 assert(image_info->signature == MagickSignature); 00952 assert(image != (Image *) NULL); 00953 assert(image->signature == MagickSignature); 00954 if (image->debug != MagickFalse) 00955 (void) LogMagickEvent(TraceEvent,GetMagickModule(),image->filename); 00956 status=OpenBlob(image_info,image,WriteBinaryBlobMode,&image->exception); 00957 if (status == MagickFalse) 00958 return(status); 00959 (void) CopyMagickString(cache_filename,image->filename,MaxTextExtent); 00960 AppendImageFormat("cache",cache_filename); 00961 scene=0; 00962 offset=0; 00963 do 00964 { 00965 /* 00966 Write persistent cache meta-information. 00967 */ 00968 (void) WriteBlobString(image,"id=MagickCache\n"); 00969 (void) FormatMagickString(buffer,MaxTextExtent,"quantum-depth=%d\n", 00970 QuantumDepth); 00971 (void) WriteBlobString(image,buffer); 00972 (void) FormatMagickString(buffer,MaxTextExtent, 00973 "class=%s colors=%lu matte=%s\n",MagickOptionToMnemonic( 00974 MagickClassOptions,image->storage_class),image->colors, 00975 MagickOptionToMnemonic(MagickBooleanOptions,(long) image->matte)); 00976 (void) WriteBlobString(image,buffer); 00977 (void) FormatMagickString(buffer,MaxTextExtent, 00978 "columns=%lu rows=%lu depth=%lu\n",image->columns,image->rows, 00979 image->depth); 00980 (void) WriteBlobString(image,buffer); 00981 if (image->colorspace != UndefinedColorspace) 00982 { 00983 (void) FormatMagickString(buffer,MaxTextExtent,"colorspace=%s\n", 00984 MagickOptionToMnemonic(MagickColorspaceOptions,image->colorspace)); 00985 (void) WriteBlobString(image,buffer); 00986 } 00987 if (image->compression != UndefinedCompression) 00988 { 00989 (void) FormatMagickString(buffer,MaxTextExtent,"compression=%s\n", 00990 MagickOptionToMnemonic(MagickCompressionOptions,image->compression)); 00991 (void) WriteBlobString(image,buffer); 00992 } 00993 if (image->units != UndefinedResolution) 00994 { 00995 (void) FormatMagickString(buffer,MaxTextExtent,"units=%s\n", 00996 MagickOptionToMnemonic(MagickResolutionOptions,image->units)); 00997 (void) WriteBlobString(image,buffer); 00998 } 00999 if ((image->x_resolution != 0) || (image->y_resolution != 0)) 01000 { 01001 (void) FormatMagickString(buffer,MaxTextExtent,"resolution=%gx%g\n", 01002 image->x_resolution,image->y_resolution); 01003 (void) WriteBlobString(image,buffer); 01004 } 01005 if ((image->page.width != 0) || (image->page.height != 0)) 01006 { 01007 (void) FormatMagickString(buffer,MaxTextExtent,"page=%lux%lu%+ld%+ld\n", 01008 image->page.width,image->page.height,image->page.x,image->page.y); 01009 (void) WriteBlobString(image,buffer); 01010 } 01011 else 01012 if ((image->page.x != 0) || (image->page.y != 0)) 01013 { 01014 (void) FormatMagickString(buffer,MaxTextExtent,"page=%+ld%+ld\n", 01015 image->page.x,image->page.y); 01016 (void) WriteBlobString(image,buffer); 01017 } 01018 if ((image->next != (Image *) NULL) || (image->previous != (Image *) NULL)) 01019 { 01020 if (image->scene == 0) 01021 (void) FormatMagickString(buffer,MaxTextExtent, 01022 "iterations=%lu delay=%lu\n",image->iterations,image->delay); 01023 else 01024 (void) FormatMagickString(buffer,MaxTextExtent, 01025 "scene=%lu iterations=%lu delay=%lu\n",image->scene, 01026 image->iterations,image->delay); 01027 (void) WriteBlobString(image,buffer); 01028 } 01029 else 01030 { 01031 if (image->sc