/* %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % % % % % % C l o n e P i x e l I t e r a t o r % % % % % % % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % ClonePixelIterator() makes an exact copy of the specified iterator. % % The format of the ClonePixelIterator method is: % % PixelIterator *ClonePixelIterator(const PixelIterator *iterator) % % A description of each parameter follows: % % o iterator: the magick iterator. % */ WandExport PixelIterator *ClonePixelIterator(const PixelIterator *iterator) { PixelIterator *clone_iterator; assert(iterator != (PixelIterator *) NULL); assert(iterator->signature == WandSignature); if (iterator->debug != MagickFalse) (void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",iterator->name); clone_iterator=(PixelIterator *) AcquireMagickMemory(sizeof(*clone_iterator)); if (clone_iterator == (PixelIterator *) NULL) ThrowWandFatalException(ResourceLimitFatalError,"MemoryAllocationFailed", iterator->name); (void) ResetMagickMemory(clone_iterator,0,sizeof(*clone_iterator)); clone_iterator->id=AcquireWandId(); (void) FormatMagickString(clone_iterator->name,MaxTextExtent,"%s-%lu", PixelIteratorId,clone_iterator->id); clone_iterator->exception=AcquireExceptionInfo(); InheritException(clone_iterator->exception,iterator->exception); clone_iterator->view=CloneCacheView(iterator->view); clone_iterator->region=iterator->region; clone_iterator->active=iterator->active; clone_iterator->y=iterator->y; clone_iterator->pixel_wands=ClonePixelWands((const PixelWand **) iterator->pixel_wands,iterator->region.width); clone_iterator->debug=iterator->debug; if (clone_iterator->debug != MagickFalse) (void) LogMagickEvent(WandEvent,GetMagickModule(),"%s", clone_iterator->name); clone_iterator->signature=WandSignature; return(clone_iterator); }
/* %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % % % % % % o p e n d i r % % % % % % % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % opendir() opens the directory named by filename and associates a directory % stream with it. % % The format of the opendir method is: % % opendir(entry) % % A description of each parameter follows: % % o entry: Specifies a pointer to a DIR structure. % % */ DIR *opendir(char *name) { DIR *directory; /* Allocate memory for handle and the pattern. */ directory=(DIR *) AcquireMagickMemory(sizeof(DIR)); if (directory == (DIR *) NULL) { errno=ENOMEM; return((DIR *) NULL); } if (strcmp(".",name) == 0) name=""; directory->pattern=(char *) AcquireQuantumMemory(strlen(name)+sizeof("*.*")+ 1UL,sizeof(*directory->pattern)); if (directory->pattern == (char *) NULL) { directory=DestroyString(directory); errno=ENOMEM; return(NULL); } /* Initialize descriptor. */ (void) FormatMagickString(directory->pattern,MaxTextExtent,"%s*.*",name); directory->context=0; directory->pat.dsc$a_pointer=directory->pattern; directory->pat.dsc$w_length=strlen(directory->pattern); directory->pat.dsc$b_dtype=DSC$K_DTYPE_T; directory->pat.dsc$b_class=DSC$K_CLASS_S; return(directory); }
/* %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % % % % % % N e w M a g i c k W a n d % % % % % % % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % NewMagickWand() returns a wand required for all other methods in the API. % % The format of the NewMagickWand method is: % % MagickWand *NewMagickWand(void) % */ WandExport MagickWand *NewMagickWand(void) { const char *quantum; MagickWand *wand; size_t depth; depth=MAGICKCORE_QUANTUM_DEPTH; quantum=GetMagickQuantumDepth(&depth); if (depth != MAGICKCORE_QUANTUM_DEPTH) ThrowWandFatalException(WandError,"QuantumDepthMismatch",quantum); wand=(MagickWand *) AcquireMagickMemory(sizeof(*wand)); if (wand == (MagickWand *) NULL) ThrowWandFatalException(ResourceLimitFatalError,"MemoryAllocationFailed", GetExceptionMessage(errno)); (void) ResetMagickMemory(wand,0,sizeof(*wand)); wand->id=AcquireWandId(); (void) FormatMagickString(wand->name,MaxTextExtent,"%s-%.20g",MagickWandId, (double) wand->id); wand->exception=AcquireExceptionInfo(); wand->image_info=AcquireImageInfo(); wand->quantize_info=CloneQuantizeInfo((QuantizeInfo *) NULL); wand->images=NewImageList(); wand->debug=IsEventLogging(); if (wand->debug != MagickFalse) (void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",wand->name); wand->signature=WandSignature; return(wand); }
/* %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % % % % % % N e w P i x e l V i e w R e g i o n % % % % % % % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % NewPixelViewRegion() returns a pixel view required for all other methods % in the Pixel View API. % % The format of the NewPixelViewRegion method is: % % PixelView *NewPixelViewRegion(MagickWand *wand,const long x, % const long y,const unsigned long width,const unsigned long height) % % A description of each parameter follows: % % o wand: the magick wand. % % o x,y,columns,rows: These values define the perimeter of a region of % pixel_wands view. % */ WandExport PixelView *NewPixelViewRegion(MagickWand *wand,const long x, const long y,const unsigned long width,const unsigned long height) { PixelView *pixel_view; assert(wand != (MagickWand *) NULL); assert(wand->signature == MagickSignature); pixel_view=(PixelView *) AcquireMagickMemory(sizeof(*pixel_view)); if (pixel_view == (PixelView *) NULL) ThrowWandFatalException(ResourceLimitFatalError,"MemoryAllocationFailed", GetExceptionMessage(errno)); (void) ResetMagickMemory(pixel_view,0,sizeof(*pixel_view)); pixel_view->id=AcquireWandId(); (void) FormatMagickString(pixel_view->name,MaxTextExtent,"%s-%lu", PixelViewId,pixel_view->id); pixel_view->exception=AcquireExceptionInfo(); pixel_view->view=AcquireCacheView(pixel_view->wand->images); pixel_view->wand=wand; pixel_view->region.width=width; pixel_view->region.height=height; pixel_view->region.x=x; pixel_view->region.y=y; pixel_view->number_threads=GetOpenMPMaximumThreads(); pixel_view->pixel_wands=AcquirePixelsThreadSet(pixel_view->region.width, pixel_view->number_threads); if (pixel_view->pixel_wands == (PixelWand ***) NULL) ThrowWandFatalException(ResourceLimitFatalError,"MemoryAllocationFailed", GetExceptionMessage(errno)); pixel_view->debug=IsEventLogging(); pixel_view->signature=WandSignature; return(pixel_view); }
/* %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % % % % % % N e w M a g i c k W a n d % % % % % % % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % NewMagickWand() returns a wand required for all other methods in the API. % % The format of the NewMagickWand method is: % % MagickWand *NewMagickWand(void) % */ WandExport MagickWand *NewMagickWand(void) { const char *quantum; MagickWand *wand; unsigned long depth; depth=QuantumDepth; quantum=GetMagickQuantumDepth(&depth); if (depth != QuantumDepth) ThrowWandFatalException(WandError,"QuantumDepthMismatch",quantum); wand=(MagickWand *) AcquireMagickMemory(sizeof(*wand)); if (wand == (MagickWand *) NULL) ThrowWandFatalException(ResourceLimitFatalError,"MemoryAllocationFailed", strerror(errno)); (void) ResetMagickMemory(wand,0,sizeof(*wand)); wand->id=AcquireWandId(); (void) FormatMagickString(wand->name,MaxTextExtent,"%s-%lu",MagickWandId, wand->id); GetExceptionInfo(&wand->exception); wand->image_info=CloneImageInfo((ImageInfo *) NULL); wand->quantize_info=CloneQuantizeInfo((QuantizeInfo *) NULL); wand->images=NewImageList(); wand->debug=IsEventLogging(); if (wand->debug != MagickFalse) (void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",wand->name); wand->signature=MagickSignature; return(wand); }
/* %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % % % % % % N e w W a n d V i e w E x t e n t % % % % % % % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % NewWandViewExtent() returns a wand view required for all other methods % in the Wand View API. % % The format of the NewWandViewExtent method is: % % WandView *NewWandViewExtent(MagickWand *wand,const ssize_t x, % const ssize_t y,const size_t width,const size_t height) % % A description of each parameter follows: % % o wand: the magick wand. % % o x,y,columns,rows: These values define the perimeter of a extent of % pixel_wands view. % */ WandExport WandView *NewWandViewExtent(MagickWand *wand,const ssize_t x, const ssize_t y,const size_t width,const size_t height) { WandView *wand_view; assert(wand != (MagickWand *) NULL); assert(wand->signature == WandSignature); wand_view=(WandView *) AcquireMagickMemory(sizeof(*wand_view)); if (wand_view == (WandView *) NULL) ThrowWandFatalException(ResourceLimitFatalError,"MemoryAllocationFailed", GetExceptionMessage(errno)); (void) ResetMagickMemory(wand_view,0,sizeof(*wand_view)); wand_view->id=AcquireWandId(); (void) FormatMagickString(wand_view->name,MaxTextExtent,"%s-%.20g", WandViewId,(double) wand_view->id); wand_view->description=ConstantString("WandView"); wand_view->view=AcquireCacheView(wand_view->wand->images); wand_view->wand=wand; wand_view->extent.width=width; wand_view->extent.height=height; wand_view->extent.x=x; wand_view->extent.y=y; wand_view->number_threads=GetOpenMPMaximumThreads(); wand_view->exception=AcquireExceptionInfo(); wand_view->pixel_wands=AcquirePixelsThreadSet(wand_view->extent.width, wand_view->number_threads); if (wand_view->pixel_wands == (PixelWand ***) NULL) ThrowWandFatalException(ResourceLimitFatalError,"MemoryAllocationFailed", GetExceptionMessage(errno)); wand_view->debug=IsEventLogging(); wand_view->signature=WandSignature; return(wand_view); }
/* %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % % % % % % C l o n e P i x e l V i e w % % % % % % % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % ClonePixelView() makes a copy of the specified pixel view. % % The format of the ClonePixelView method is: % % PixelView *ClonePixelView(const PixelView *pixel_view) % % A description of each parameter follows: % % o pixel_view: the pixel view. % */ WandExport PixelView *ClonePixelView(const PixelView *pixel_view) { PixelView *clone_view; register long i; assert(pixel_view != (PixelView *) NULL); assert(pixel_view->signature == WandSignature); if (pixel_view->debug != MagickFalse) (void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",pixel_view->name); clone_view=(PixelView *) AcquireMagickMemory(sizeof(*clone_view)); if (clone_view == (PixelView *) NULL) ThrowWandFatalException(ResourceLimitFatalError,"MemoryAllocationFailed", pixel_view->name); (void) ResetMagickMemory(clone_view,0,sizeof(*clone_view)); clone_view->id=AcquireWandId(); (void) FormatMagickString(clone_view->name,MaxTextExtent,"%s-%lu",PixelViewId, clone_view->id); clone_view->exception=AcquireExceptionInfo(); InheritException(clone_view->exception,pixel_view->exception); clone_view->view=CloneCacheView(pixel_view->view); clone_view->region=pixel_view->region; clone_view->number_threads=pixel_view->number_threads; for (i=0; i < (long) pixel_view->number_threads; i++) clone_view->pixel_wands[i]=ClonePixelWands((const PixelWand **) pixel_view->pixel_wands[i],pixel_view->region.width); clone_view->debug=pixel_view->debug; if (clone_view->debug != MagickFalse) (void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",clone_view->name); clone_view->signature=WandSignature; return(clone_view); }
/* %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % % % % % % C l o n e W a n d V i e w % % % % % % % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % CloneWandView() makes a copy of the specified wand view. % % The format of the CloneWandView method is: % % WandView *CloneWandView(const WandView *wand_view) % % A description of each parameter follows: % % o wand_view: the wand view. % */ WandExport WandView *CloneWandView(const WandView *wand_view) { WandView *clone_view; register ssize_t i; assert(wand_view != (WandView *) NULL); assert(wand_view->signature == WandSignature); if (wand_view->debug != MagickFalse) (void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",wand_view->name); clone_view=(WandView *) AcquireMagickMemory(sizeof(*clone_view)); if (clone_view == (WandView *) NULL) ThrowWandFatalException(ResourceLimitFatalError,"MemoryAllocationFailed", wand_view->name); (void) ResetMagickMemory(clone_view,0,sizeof(*clone_view)); clone_view->id=AcquireWandId(); (void) FormatMagickString(clone_view->name,MaxTextExtent,"%s-%.20g", WandViewId,(double) clone_view->id); clone_view->description=ConstantString(wand_view->description); clone_view->view=CloneCacheView(wand_view->view); clone_view->extent=wand_view->extent; clone_view->number_threads=wand_view->number_threads; clone_view->exception=AcquireExceptionInfo(); InheritException(clone_view->exception,wand_view->exception); for (i=0; i < (ssize_t) wand_view->number_threads; i++) clone_view->pixel_wands[i]=ClonePixelWands((const PixelWand **) wand_view->pixel_wands[i],wand_view->extent.width); clone_view->debug=wand_view->debug; if (clone_view->debug != MagickFalse) (void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",clone_view->name); clone_view->signature=WandSignature; return(clone_view); }
/* %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % % % % % % G e t M a g i c k H o m e U R L % % % % % % % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % GetMagickHomeURL() returns the ImageMagick home URL. % % The format of the GetMagickHomeURL method is: % % char *GetMagickHomeURL(void) % */ MagickExport char *GetMagickHomeURL(void) { char path[MaxTextExtent]; const char *element; ExceptionInfo *exception; LinkedListInfo *paths; exception=AcquireExceptionInfo(); paths=GetConfigurePaths(MagickURLFilename,exception); exception=DestroyExceptionInfo(exception); if (paths == (LinkedListInfo *) NULL) return(ConstantString(MagickHomeURL)); element=(const char *) GetNextValueInLinkedList(paths); while (element != (const char *) NULL) { (void) FormatMagickString(path,MaxTextExtent,"%s%s%s",element, DirectorySeparator,MagickURLFilename); if (IsAccessible(path) != MagickFalse) return(ConstantString(path)); element=(const char *) GetNextValueInLinkedList(paths); } return(ConstantString(MagickHomeURL)); }
/* %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % % % % % % L i s t T y p e I n f o % % % % % % % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % ListTypeInfo() lists the fonts to a file. % % The format of the ListTypeInfo method is: % % MagickBooleanType ListTypeInfo(FILE *file,ExceptionInfo *exception) % % A description of each parameter follows. % % o file: An pointer to a FILE. % % o exception: Return any errors or warnings in this structure. % */ MagickExport MagickBooleanType ListTypeInfo(FILE *file,ExceptionInfo *exception) { char weight[MaxTextExtent]; const char *family, *name, *path, *stretch, *style; const TypeInfo **type_info; register long i; unsigned long number_fonts; if (file == (FILE *) NULL) file=stdout; number_fonts=0; type_info=GetTypeInfoList("*",&number_fonts,exception); if (type_info == (const TypeInfo **) NULL) return(MagickFalse); *weight='\0'; path=(const char *) NULL; for (i=0; i < (long) number_fonts; i++) { if (type_info[i]->stealth != MagickFalse) continue; if ((path == (const char *) NULL) || (LocaleCompare(path,type_info[i]->path) != 0)) { if (type_info[i]->path != (char *) NULL) (void) fprintf(file,"\nPath: %s\n\n",type_info[i]->path); (void) fprintf(file,"%-32.32s %-22.22s %-7.7s %-8.8s %-3s\n", "Name","Family","Style","Stretch","Weight"); (void) fprintf(file,"--------------------------------------------------" "------------------------------\n"); } path=type_info[i]->path; name="unknown"; if (type_info[i]->name != (char *) NULL) name=type_info[i]->name; family="unknown"; if (type_info[i]->family != (char *) NULL) family=type_info[i]->family; style=MagickOptionToMnemonic(MagickStyleOptions,type_info[i]->style); stretch=MagickOptionToMnemonic(MagickStretchOptions,type_info[i]->stretch); (void) FormatMagickString(weight,MaxTextExtent,"%lu",type_info[i]->weight); (void) fprintf(file,"%-32.32s %-22.22s %-7.7s %-9.9s %6s\n",name,family, style,stretch,weight); } (void) fflush(file); type_info=(const TypeInfo **) RelinquishMagickMemory((void *) type_info); return(MagickTrue); }
/* %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % % % % % % W r i t e C L I P I m a g e % % % % % % % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % WriteCLIPImage() writes an image of clip bytes to a file. It consists of % data from the clip mask of the image. % % The format of the WriteCLIPImage method is: % % MagickBooleanType WriteCLIPImage(const ImageInfo *image_info, % Image *image) % % A description of each parameter follows. % % o image_info: The image info. % % o image: The image. % */ static MagickBooleanType WriteCLIPImage(const ImageInfo *image_info, Image *image) { Image *clip_image; ImageInfo *write_info; MagickBooleanType status; if (image->clip_mask == (Image *) NULL) (void) ClipImage(image); if (image->clip_mask == (Image *) NULL) ThrowWriterException(CoderError,"ImageDoesNotHaveAClipMask"); clip_image=CloneImage(image->clip_mask,0,0,MagickTrue,&image->exception); if (clip_image == (Image *) NULL) return(MagickFalse); (void) SetImageType(clip_image,TrueColorType); (void) CopyMagickString(clip_image->filename,image->filename,MaxTextExtent); write_info=CloneImageInfo(image_info); (void) SetImageInfo(write_info,MagickTrue,&image->exception); if (LocaleCompare(write_info->magick,"CLIP") == 0) (void) FormatMagickString(clip_image->filename,MaxTextExtent,"miff:%s", write_info->filename); status=WriteImage(write_info,clip_image); clip_image=DestroyImage(clip_image); write_info=DestroyImageInfo(write_info); return(status); }
/* %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % % % % % % C l o n e M a g i c k W a n d % % % % % % % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % CloneMagickWand() makes an exact copy of the specified wand. % % The format of the CloneMagickWand method is: % % MagickWand *CloneMagickWand(const MagickWand *wand) % % A description of each parameter follows: % % o wand: The magick wand. % */ WandExport MagickWand *CloneMagickWand(const MagickWand *wand) { MagickWand *clone_wand; assert(wand != (MagickWand *) NULL); assert(wand->signature == WandSignature); if (wand->debug != MagickFalse) (void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",wand->name); clone_wand=(MagickWand *) AcquireMagickMemory(sizeof(*clone_wand)); if (clone_wand == (MagickWand *) NULL) { char *message; message=GetExceptionMessage(errno); ThrowWandFatalException(ResourceLimitFatalError,"MemoryAllocationFailed", message); message=DestroyString(message); } (void) ResetMagickMemory(clone_wand,0,sizeof(*clone_wand)); clone_wand->id=AcquireWandId(); (void) FormatMagickString(clone_wand->name,MaxTextExtent,"%s-%lu", MagickWandId,clone_wand->id); clone_wand->exception=AcquireExceptionInfo(); InheritException(clone_wand->exception,wand->exception); clone_wand->image_info=CloneImageInfo(wand->image_info); clone_wand->quantize_info=CloneQuantizeInfo(wand->quantize_info); clone_wand->images=CloneImageList(wand->images,clone_wand->exception); clone_wand->debug=IsEventLogging(); if (clone_wand->debug != MagickFalse) (void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",clone_wand->name); clone_wand->signature=WandSignature; return(clone_wand); }
/* %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % % % % % % R e a d D O T I m a g e % % % % % % % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % ReadDOTImage() reads a Graphviz image file and returns it. It allocates % the memory necessary for the new Image structure and returns a pointer to % the new image. % % The format of the ReadDOTImage method is: % % Image *ReadDOTImage(const ImageInfo *image_info,ExceptionInfo *exception) % % A description of each parameter follows: % % o image_info: The image info. % % o exception: return any errors or warnings in this structure. % */ static Image *ReadDOTImage(const ImageInfo *image_info,ExceptionInfo *exception) { char command[MaxTextExtent]; const char *option; graph_t *graph; Image *image; ImageInfo *read_info; MagickBooleanType status; /* Open image file. */ assert(image_info != (const ImageInfo *) NULL); assert(image_info->signature == MagickSignature); if (image_info->debug != MagickFalse) (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s", image_info->filename); assert(exception != (ExceptionInfo *) NULL); assert(exception->signature == MagickSignature); image=AllocateImage(image_info); status=OpenBlob(image_info,image,ReadBinaryBlobMode,exception); if (status == MagickFalse) return((Image *) NULL); read_info=CloneImageInfo(image_info); (void) CopyMagickString(read_info->magick,"PS",MaxTextExtent); (void) AcquireUniqueFilename(read_info->filename); (void) FormatMagickString(command,MaxTextExtent,"-Tps2 -o%s %s", read_info->filename,image_info->filename); graph=agread(GetBlobFileHandle(image)); if (graph == (graph_t *) NULL) return ((Image *) NULL); option=GetImageOption(image_info,"dot:layout-engine"); if (option == (const char *) NULL) gvLayout(graphic_context,graph,"dot"); else gvLayout(graphic_context,graph,(char *) option); gvRenderFilename(graphic_context,graph,"ps2",read_info->filename); gvFreeLayout(graphic_context,graph); /* Read Postscript graph. */ image=ReadImage(read_info,exception); (void) RelinquishUniqueFileResource(read_info->filename); read_info=DestroyImageInfo(read_info); if (image == (Image *) NULL) return((Image *) NULL); return(GetFirstImageInList(image)); }
/* %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % % % % % % G e t L o c a l e O p t i o n s % % % % % % % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % GetLocaleOptions() returns any Magick configuration messages associated % with the specified filename. % % The format of the GetLocaleOptions method is: % % LinkedListInfo *GetLocaleOptions(const char *filename, % ExceptionInfo *exception) % % A description of each parameter follows: % % o filename: the locale file tag. % % o exception: return any errors or warnings in this structure. % */ MagickExport LinkedListInfo *GetLocaleOptions(const char *filename, ExceptionInfo *exception) { char path[MaxTextExtent]; const char *element; LinkedListInfo *messages, *paths; StringInfo *xml; assert(filename != (const char *) NULL); (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",filename); assert(exception != (ExceptionInfo *) NULL); (void) CopyMagickString(path,filename,MaxTextExtent); /* Load XML from configuration files to linked-list. */ messages=NewLinkedList(0); paths=GetConfigurePaths(filename,exception); if (paths != (LinkedListInfo *) NULL) { ResetLinkedListIterator(paths); element=(const char *) GetNextValueInLinkedList(paths); while (element != (const char *) NULL) { (void) FormatMagickString(path,MaxTextExtent,"%s%s",element,filename); (void) LogMagickEvent(LocaleEvent,GetMagickModule(), "Searching for locale file: \"%s\"",path); xml=ConfigureFileToStringInfo(path); if (xml != (StringInfo *) NULL) (void) AppendValueToLinkedList(messages,xml); element=(const char *) GetNextValueInLinkedList(paths); } paths=DestroyLinkedList(paths,RelinquishMagickMemory); } #if defined(MAGICKCORE_WINDOWS_SUPPORT) { char *blob; blob=(char *) NTResourceToBlob(filename); if (blob != (char *) NULL) { xml=StringToStringInfo(blob); (void) AppendValueToLinkedList(messages,xml); blob=DestroyString(blob); } } #endif ResetLinkedListIterator(messages); return(messages); }
/* %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % % % % % % L o a d T y p e L i s t s % % % % % % % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % LoadTypeList() loads one or more type configuration files which provides a % mapping between type attributes and a type name. % % The format of the LoadTypeLists method is: % % MagickBooleanType LoadTypeLists(const char *filename, % ExceptionInfo *exception) % % A description of each parameter follows: % % o filename: the font file name. % % o exception: return any errors or warnings in this structure. % */ static MagickBooleanType LoadTypeLists(const char *filename, ExceptionInfo *exception) { #if defined(MAGICKCORE_EMBEDDABLE_SUPPORT) return(LoadTypeList(TypeMap,"built-in",0,exception)); #else char *font_path, path[MaxTextExtent]; const StringInfo *option; LinkedListInfo *options; MagickStatusType status; status=MagickFalse; *path='\0'; options=GetConfigureOptions(filename,exception); option=(const StringInfo *) GetNextValueInLinkedList(options); while (option != (const StringInfo *) NULL) { (void) CopyMagickString(path,GetStringInfoPath(option),MaxTextExtent); status|=LoadTypeList((const char *) GetStringInfoDatum(option), GetStringInfoPath(option),0,exception); option=(const StringInfo *) GetNextValueInLinkedList(options); } options=DestroyConfigureOptions(options); font_path=GetEnvironmentValue("MAGICK_FONT_PATH"); if (font_path != (char *) NULL) { char *option; /* Search MAGICK_FONT_PATH. */ (void) FormatMagickString(path,MaxTextExtent,"%s%s%s",font_path, DirectorySeparator,filename); option=FileToString(path,~0,exception); if (option != (void *) NULL) { status|=LoadTypeList(option,path,0,exception); option=DestroyString(option); } font_path=DestroyString(font_path); } if ((type_list == (SplayTreeInfo *) NULL) || (GetNumberOfNodesInSplayTree(type_list) == 0)) status|=LoadTypeList(TypeMap,"built-in",0,exception); return(status != 0 ? MagickTrue : MagickFalse); #endif }
static MagickBooleanType GetPathTemplate(char *path) { const char *directory; int status; struct stat file_info; (void) strcpy(path,"magick-XXXXXXXX"); directory=getenv("MAGICK_TMPDIR"); if (directory == (const char *) NULL) directory=getenv("TMPDIR"); #if defined(__WINDOWS__) if (directory == (const char *) NULL) directory=getenv("TMP"); if (directory == (const char *) NULL) directory=getenv("TEMP"); #endif #if defined(__VMS) directory=getenv("MTMPDIR"); #endif #if defined(P_tmpdir) if (directory == (const char *) NULL) directory=P_tmpdir; #endif if (directory == (const char *) NULL) return(MagickTrue); if (strlen(directory) > (MaxTextExtent-15)) return(MagickTrue); status=stat(directory,&file_info); if ((status != 0) || !S_ISDIR(file_info.st_mode)) return(MagickTrue); if (directory[strlen(directory)-1] == *DirectorySeparator) (void) FormatMagickString(path,MaxTextExtent,"%smagick-XXXXXXXX",directory); else (void) FormatMagickString(path,MaxTextExtent,"%s%smagick-XXXXXXXX", directory,DirectorySeparator); return(MagickTrue); }
/* %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % % % % % % V a l i d a t e I d e n t i f y C o m m a n d % % % % % % % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % ValidateIdentifyCommand() validates the ImageMagick identify command line % program and returns the number of validation tests that passed and failed. % % The format of the ValidateIdentifyCommand method is: % % unsigned long ValidateIdentifyCommand(ImageInfo *image_info, % const char *reference_filename,const char *output_filename, % unsigned long *fail,ExceptionInfo *exception) % % A description of each parameter follows: % % o image_info: the image info. % % o reference_filename: the reference image filename. % % o output_filename: the output image filename. % % o fail: return the number of validation tests that pass. % % o exception: return any errors or warnings in this structure. % */ static unsigned long ValidateIdentifyCommand(ImageInfo *image_info, const char *reference_filename,const char *output_filename, unsigned long *fail,ExceptionInfo *exception) { char **arguments, command[MaxTextExtent]; int number_arguments; MagickBooleanType status; register long i, j; unsigned long test; (void) output_filename; test=0; (void) fprintf(stdout,"validate identify command line program:\n"); for (i=0; identify_options[i] != (char *) NULL; i++) { CatchException(exception); (void) fprintf(stdout," test %lu: %s",test++,identify_options[i]); (void) FormatMagickString(command,MaxTextExtent,"%s %s", identify_options[i],reference_filename); arguments=StringToArgv(command,&number_arguments); if (arguments == (char **) NULL) { (void) fprintf(stdout,"... fail @ %s/%s/%lu.\n",GetMagickModule()); (*fail)++; continue; } status=IdentifyImageCommand(image_info,number_arguments,arguments, (char **) NULL,exception); for (j=0; j < number_arguments; j++) arguments[j]=DestroyString(arguments[j]); arguments=(char **) RelinquishMagickMemory(arguments); if (status != MagickFalse) { (void) fprintf(stdout,"... fail @ %s/%s/%lu.\n",GetMagickModule()); (*fail)++; continue; } (void) fprintf(stdout,"... pass.\n"); } (void) fprintf(stdout," summary: %lu subtests; %lu passed; %lu failed.\n", test,test-(*fail),*fail); return(test); }
/* %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % % % % % % N e w P i x e l R e g i o n I t e r a t o r % % % % % % % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % NewPixelRegionIterator() returns a new pixel iterator. % % The format of the NewPixelRegionIterator method is: % % PixelIterator NewPixelRegionIterator(MagickWand *wand,const long x, % const long y,const unsigned long width,const unsigned long height) % % A description of each parameter follows: % % o wand: the magick wand. % % o x,y,columns,rows: These values define the perimeter of a region of % pixels. % */ WandExport PixelIterator *NewPixelRegionIterator(MagickWand *wand,const long x, const long y,const unsigned long width,const unsigned long height) { const char *quantum; Image *image; PixelIterator *iterator; unsigned long depth; CacheView *view; assert(wand != (MagickWand *) NULL); depth=MAGICKCORE_QUANTUM_DEPTH; quantum=GetMagickQuantumDepth(&depth); if (depth != MAGICKCORE_QUANTUM_DEPTH) ThrowWandFatalException(WandError,"QuantumDepthMismatch",quantum); if ((width == 0) || (width == 0)) ThrowWandFatalException(WandError,"ZeroRegionSize",quantum); image=GetImageFromMagickWand(wand); if (image == (Image *) NULL) return((PixelIterator *) NULL); view=AcquireCacheView(image); if (view == (CacheView *) NULL) return((PixelIterator *) NULL); iterator=(PixelIterator *) AcquireMagickMemory(sizeof(*iterator)); if (iterator == (PixelIterator *) NULL) ThrowWandFatalException(ResourceLimitFatalError,"MemoryAllocationFailed", wand->name); (void) ResetMagickMemory(iterator,0,sizeof(*iterator)); iterator->id=AcquireWandId(); (void) FormatMagickString(iterator->name,MaxTextExtent,"%s-%lu", PixelIteratorId,iterator->id); iterator->exception=AcquireExceptionInfo(); iterator->view=view; SetGeometry(image,&iterator->region); iterator->region.width=width; iterator->region.height=height; iterator->region.x=x; iterator->region.y=y; iterator->pixel_wands=NewPixelWands(iterator->region.width); iterator->y=0; iterator->debug=IsEventLogging(); if (iterator->debug != MagickFalse) (void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",iterator->name); iterator->signature=WandSignature; return(iterator); }
void Magick::Options::magick ( const std::string &magick_ ) { ExceptionInfo exception; FormatMagickString( _imageInfo->filename, MaxTextExtent, "%.1024s:", magick_.c_str() ); GetExceptionInfo(&exception); SetImageInfo( _imageInfo, 1, &exception); if ( *_imageInfo->magick == '\0' ) throwExceptionExplicit( OptionWarning, "Unrecognized image format", magick_.c_str() ); (void) DestroyExceptionInfo( &exception ); }
/* %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % % % % % % N e w P i x e l I t e r a t o r % % % % % % % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % NewPixelIterator() returns a new pixel iterator. % % The format of the NewPixelIterator method is: % % PixelIterator *NewPixelIterator(MagickWand *wand) % % A description of each parameter follows: % % o wand: the magick wand. % */ WandExport PixelIterator *NewPixelIterator(MagickWand *wand) { const char *quantum; Image *image; PixelIterator *iterator; size_t depth; CacheView *view; depth=MAGICKCORE_QUANTUM_DEPTH; quantum=GetMagickQuantumDepth(&depth); if (depth != MAGICKCORE_QUANTUM_DEPTH) ThrowWandFatalException(WandError,"QuantumDepthMismatch",quantum); assert(wand != (MagickWand *) NULL); image=GetImageFromMagickWand(wand); if (image == (Image *) NULL) return((PixelIterator *) NULL); view=AcquireCacheView(image); if (view == (CacheView *) NULL) return((PixelIterator *) NULL); iterator=(PixelIterator *) AcquireMagickMemory(sizeof(*iterator)); if (iterator == (PixelIterator *) NULL) ThrowWandFatalException(ResourceLimitFatalError,"MemoryAllocationFailed", GetExceptionMessage(errno)); (void) ResetMagickMemory(iterator,0,sizeof(*iterator)); iterator->id=AcquireWandId(); (void) FormatMagickString(iterator->name,MaxTextExtent,"%s-%.20g", PixelIteratorId,(double) iterator->id); iterator->exception=AcquireExceptionInfo(); iterator->view=view; SetGeometry(image,&iterator->region); iterator->region.width=image->columns; iterator->region.height=image->rows; iterator->region.x=0; iterator->region.y=0; iterator->pixel_wands=NewPixelWands(iterator->region.width); iterator->y=0; iterator->debug=IsEventLogging(); if (iterator->debug != MagickFalse) (void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",iterator->name); iterator->signature=WandSignature; return(iterator); }
MagickExport MagickBooleanType ThrowMagickExceptionList( ExceptionInfo *exception,const char *module,const char *function, const unsigned long line,const ExceptionType severity,const char *tag, const char *format,va_list operands) { char message[MaxTextExtent], path[MaxTextExtent], reason[MaxTextExtent]; const char *locale, *type; int n; MagickBooleanType status; size_t length; assert(exception != (ExceptionInfo *) NULL); assert(exception->signature == MagickSignature); locale=GetLocaleExceptionMessage(severity,tag); (void) CopyMagickString(reason,locale,MaxTextExtent); (void) ConcatenateMagickString(reason," ",MaxTextExtent); length=strlen(reason); #if defined(MAGICKCORE_HAVE_VSNPRINTF) n=vsnprintf(reason+length,MaxTextExtent-length,format,operands); #else n=vsprintf(reason+length,format,operands); #endif if (n < 0) reason[MaxTextExtent-1]='\0'; status=LogMagickEvent(ExceptionEvent,module,function,line,"%s",reason); GetPathComponent(module,TailPath,path); type="undefined"; if ((severity >= WarningException) && (severity < ErrorException)) type="warning"; if ((severity >= ErrorException) && (severity < FatalErrorException)) type="error"; if (severity >= FatalErrorException) type="fatal"; (void) FormatMagickString(message,MaxTextExtent,"%s @ %s/%s/%s/%ld",reason, type,path,function,line); (void) ThrowException(exception,severity,message,(char *) NULL); return(status); }
/* %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % % % % % + M a g i c k T o M i m e % % % % % % % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % MagickToMime() returns the officially registered (or de facto) MIME % media-type corresponding to a magick string. If there is no registered % media-type, then the string "image/x-magick" (all lower case) is returned. % The returned string must be deallocated by the user. % % The format of the MagickToMime method is: % % char *MagickToMime(const char *magick) % % A description of each parameter follows. % % o magick: ImageMagick format specification "magick" tag. % */ MagickExport char *MagickToMime(const char *magick) { char filename[MaxTextExtent], media[MaxTextExtent]; const MimeInfo *mime_info; ExceptionInfo *exception; (void) FormatMagickString(filename,MaxTextExtent,"file.%s",magick); LocaleLower(filename); exception=AcquireExceptionInfo(); mime_info=GetMimeInfo(filename,(unsigned char *) " ",1,exception); exception=DestroyExceptionInfo(exception); if (mime_info != (const MimeInfo *) NULL) return(ConstantString(GetMimeType(mime_info))); (void) FormatMagickString(media,MaxTextExtent,"image/x-%s",magick); LocaleLower(media+8); return(ConstantString(media)); }
/* %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % % % % % % R e a d M P E G I m a g e % % % % % % % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % ReadMPEGImage() reads an binary file in the MPEG video stream format % and returns it. It allocates the memory necessary for the new Image % structure and returns a pointer to the new image. % % The format of the ReadMPEGImage method is: % % Image *ReadMPEGImage(const ImageInfo *image_info, % ExceptionInfo *exception) % % A description of each parameter follows: % % o image_info: the image info. % % o exception: return any errors or warnings in this structure. % */ static Image *ReadMPEGImage(const ImageInfo *image_info, ExceptionInfo *exception) { #define ReadMPEGIntermediateFormat "pam" Image *image, *images; ImageInfo *read_info; MagickBooleanType status; /* Open image file. */ assert(image_info != (const ImageInfo *) NULL); assert(image_info->signature == MagickSignature); if (image_info->debug != MagickFalse) (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s", image_info->filename); assert(exception != (ExceptionInfo *) NULL); assert(exception->signature == MagickSignature); image=AcquireImage(image_info); status=OpenBlob(image_info,image,ReadBinaryBlobMode,exception); if (status == MagickFalse) { image=DestroyImageList(image); return((Image *) NULL); } (void) CloseBlob(image); (void) DestroyImageList(image); /* Convert MPEG to PAM with delegate. */ read_info=CloneImageInfo(image_info); image=AcquireImage(image_info); (void) InvokeDelegate(read_info,image,"mpeg:decode",(char *) NULL,exception); image=DestroyImage(image); (void) FormatMagickString(read_info->filename,MaxTextExtent,"%s.%s", read_info->unique,ReadMPEGIntermediateFormat); images=ReadImage(read_info,exception); (void) RelinquishUniqueFileResource(read_info->filename); read_info=DestroyImageInfo(read_info); return(images); }
MagickExport const char *GetLocaleExceptionMessage(const ExceptionType severity, const char *tag) { char message[MaxTextExtent]; const char *locale_message; assert(tag != (const char *) NULL); (void) FormatMagickString(message,MaxTextExtent,"Exception/%s%s", ExceptionSeverityToTag(severity),tag); locale_message=GetLocaleMessage(message); if (locale_message == (const char *) NULL) return(tag); if (locale_message == message) return(tag); return(locale_message); }
/* %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % % % % % % G e t L o c a l e M e s s a g e % % % % % % % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % GetLocaleMessage() returns a message in the current locale that matches the % supplied tag. % % The format of the GetLocaleMessage method is: % % const char *GetLocaleMessage(const char *tag) % % A description of each parameter follows: % % o tag: Return a message that matches this tag in the current locale. % */ MagickExport const char *GetLocaleMessage(const char *tag) { char name[MaxTextExtent]; const LocaleInfo *locale_info; ExceptionInfo *exception; if ((tag == (const char *) NULL) || (*tag == '\0')) return(tag); exception=AcquireExceptionInfo(); (void) FormatMagickString(name,MaxTextExtent,"%s/",tag); locale_info=GetLocaleInfo_(name,exception); exception=DestroyExceptionInfo(exception); if (locale_info != (const LocaleInfo *) NULL) return(locale_info->message); return(tag); }
/* %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % % % % % % W r i t e V I D I m a g e % % % % % % % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % WriteVIDImage() writes an image to a file in VID X image format. % % The format of the WriteVIDImage method is: % % MagickBooleanType WriteVIDImage(const ImageInfo *image_info,Image *image) % % A description of each parameter follows. % % o image_info: the image info. % % o image: The image. % */ static MagickBooleanType WriteVIDImage(const ImageInfo *image_info,Image *image) { Image *montage_image; ImageInfo *write_info; MagickBooleanType status; MontageInfo *montage_info; register Image *p; /* Create the visual image directory. */ for (p=image; p != (Image *) NULL; p=GetNextImageInList(p)) (void) SetImageProperty(p,"label",DefaultTileLabel); montage_info=CloneMontageInfo(image_info,(MontageInfo *) NULL); montage_image=MontageImageList(image_info,montage_info,image, &image->exception); montage_info=DestroyMontageInfo(montage_info); if (montage_image == (Image *) NULL) ThrowWriterException(CorruptImageError,image->exception.reason); (void) CopyMagickString(montage_image->filename,image_info->filename, MaxTextExtent); write_info=CloneImageInfo(image_info); (void) SetImageInfo(write_info,1,&image->exception); if (LocaleCompare(write_info->magick,"VID") == 0) (void) FormatMagickString(montage_image->filename,MaxTextExtent, "miff:%s",write_info->filename); status=WriteImage(write_info,montage_image); montage_image=DestroyImage(montage_image); write_info=DestroyImageInfo(write_info); return(status); }
/* %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % % % % % % W r i t e P R E V I E W I m a g e % % % % % % % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % WritePreviewImage creates several tiles each with a varying % stength of an image enhancement function (e.g. gamma). The image is written % in the MIFF format. % % The format of the WritePreviewImage method is: % % MagickBooleanType WritePreviewImage(const ImageInfo *image_info, % Image *image) % % A description of each parameter follows. % % o image_info: The image info. % % o image: The image. % % */ static MagickBooleanType WritePreviewImage(const ImageInfo *image_info, Image *image) { Image *preview_image; ImageInfo *write_info; MagickBooleanType status; /* Open output image file. */ assert(image_info != (const ImageInfo *) NULL); assert(image_info->signature == MagickSignature); assert(image != (Image *) NULL); assert(image->signature == MagickSignature); if (image->debug != MagickFalse) (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename); preview_image=PreviewImage(image,image_info->preview_type,&image->exception); if (preview_image == (Image *) NULL) return(MagickFalse); (void) CopyMagickString(preview_image->filename,image_info->filename, MaxTextExtent); write_info=CloneImageInfo(image_info); (void) SetImageInfo(write_info,MagickTrue,&image->exception); if (LocaleCompare(write_info->magick,"PREVIEW") == 0) (void) FormatMagickString(preview_image->filename,MaxTextExtent, "miff:%s",image_info->filename); status=WriteImage(write_info,preview_image); preview_image=DestroyImage(preview_image); write_info=DestroyImageInfo(write_info); return(status); }
/* %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % % % % % % L i s t M a g i c k R e s o u r c e I n f o % % % % % % % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % ListMagickResourceInfo() lists the resource info to a file. % % The format of the ListMagickResourceInfo method is: % % MagickBooleanType ListMagickResourceInfo(FILE *file, % ExceptionInfo *exception) % % A description of each parameter follows. % % o file: An pointer to a FILE. % % o exception: return any errors or warnings in this structure. % */ MagickExport MagickBooleanType ListMagickResourceInfo(FILE *file, ExceptionInfo *magick_unused(exception)) { char area_limit[MaxTextExtent], disk_limit[MaxTextExtent], map_limit[MaxTextExtent], memory_limit[MaxTextExtent], time_limit[MaxTextExtent]; if (file == (const FILE *) NULL) file=stdout; if (resource_semaphore == (SemaphoreInfo *) NULL) AcquireSemaphoreInfo(&resource_semaphore); LockSemaphoreInfo(resource_semaphore); (void) FormatMagickSize(resource_info.area_limit,MagickFalse,area_limit); (void) FormatMagickSize(resource_info.memory_limit,MagickTrue,memory_limit); (void) FormatMagickSize(resource_info.map_limit,MagickTrue,map_limit); (void) CopyMagickString(disk_limit,"unlimited",MaxTextExtent); if (resource_info.disk_limit != MagickResourceInfinity) (void) FormatMagickSize(resource_info.disk_limit,MagickFalse,disk_limit); (void) CopyMagickString(time_limit,"unlimited",MaxTextExtent); if (resource_info.time_limit != MagickResourceInfinity) (void) FormatMagickString(time_limit,MaxTextExtent,"%.20g",(double) resource_info.time_limit); (void) fprintf(file,"File Area Memory Map" " Disk Thread Time\n"); (void) fprintf(file,"--------------------------------------------------------" "-----------------------\n"); (void) fprintf(file,"%4g %10s %10s %10s %10s %6g %11s\n",(double) resource_info.file_limit,area_limit,memory_limit,map_limit,disk_limit, (double) resource_info.thread_limit,time_limit); (void) fflush(file); UnlockSemaphoreInfo(resource_semaphore); return(MagickTrue); }
/* %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % % % % % % W r i t e M A T T E I m a g e % % % % % % % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % Function WriteMATTEImage() writes an image of matte bytes to a file. It % consists of data from the matte component of the image [0..255]. % % The format of the WriteMATTEImage method is: % % MagickBooleanType WriteMATTEImage(const ImageInfo *image_info, % Image *image) % % A description of each parameter follows. % % o image_info: the image info. % % o image: The image. % */ static MagickBooleanType WriteMATTEImage(const ImageInfo *image_info, Image *image) { ExceptionInfo *exception; Image *matte_image; ssize_t y; MagickBooleanType status; register const PixelPacket *p; register ssize_t x; register PixelPacket *q; if (image->matte == MagickFalse) ThrowWriterException(CoderError,"ImageDoesNotHaveAAlphaChannel"); matte_image=CloneImage(image,image->columns,image->rows,MagickTrue, &image->exception); if (matte_image == (Image *) NULL) return(MagickFalse); (void) SetImageType(matte_image,TrueColorMatteType); matte_image->matte=MagickFalse; /* Convert image to matte pixels. */ exception=(&image->exception); for (y=0; y < (ssize_t) image->rows; y++) { p=GetVirtualPixels(image,0,y,image->columns,1,exception); q=QueueAuthenticPixels(matte_image,0,y,matte_image->columns,1,exception); if ((p == (const PixelPacket *) NULL) || (q == (PixelPacket *) NULL)) break; for (x=0; x < (ssize_t) image->columns; x++) { q->red=GetOpacityPixelComponent(p); q->green=GetOpacityPixelComponent(p); q->blue=GetOpacityPixelComponent(p); SetOpacityPixelComponent(q,OpaqueOpacity); p++; q++; } if (SyncAuthenticPixels(matte_image,exception) == MagickFalse) break; status=SetImageProgress(image,SaveImageTag,(MagickOffsetType) y, image->rows); if (status == MagickFalse) break; } (void) FormatMagickString(matte_image->filename,MaxTextExtent, "MIFF:%s",image->filename); status=WriteImage(image_info,matte_image); matte_image=DestroyImage(matte_image); return(status); }
/* %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % % % % % % R e a d D N G I m a g e % % % % % % % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % ReadDNGImage() reads an binary file in the Digital Negative format and % returns it. It allocates the memory necessary for the new Image structure % and returns a pointer to the new image. % % The format of the ReadDNGImage method is: % % Image *ReadDNGImage(const ImageInfo *image_info, % ExceptionInfo *exception) % % A description of each parameter follows: % % o image_info: the image info. % % o exception: return any errors or warnings in this structure. % */ static Image *ReadDNGImage(const ImageInfo *image_info,ExceptionInfo *exception) { ExceptionInfo *sans_exception; Image *image; ImageInfo *read_info; MagickBooleanType status; /* Open image file. */ assert(image_info != (const ImageInfo *) NULL); assert(image_info->signature == MagickSignature); if (image_info->debug != MagickFalse) (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s", image_info->filename); assert(exception != (ExceptionInfo *) NULL); assert(exception->signature == MagickSignature); image=AcquireImage(image_info); status=OpenBlob(image_info,image,ReadBinaryBlobMode,exception); if (status == MagickFalse) { image=DestroyImageList(image); return((Image *) NULL); } (void) CloseBlob(image); (void) DestroyImageList(image); /* Convert DNG to PPM with delegate. */ image=AcquireImage(image_info); read_info=CloneImageInfo(image_info); (void) InvokeDelegate(read_info,image,"dng:decode",(char *) NULL,exception); image=DestroyImage(image); (void) FormatMagickString(read_info->filename,MaxTextExtent,"%s.png", read_info->unique); sans_exception=AcquireExceptionInfo(); image=ReadImage(read_info,sans_exception); sans_exception=DestroyExceptionInfo(sans_exception); if (image == (Image *) NULL) { (void) FormatMagickString(read_info->filename,MaxTextExtent,"%s.ppm", read_info->unique); image=ReadImage(read_info,exception); } (void) RelinquishUniqueFileResource(read_info->filename); if (image != (Image *) NULL) { char filename[MaxTextExtent], *xml; ExceptionInfo *sans; (void) CopyMagickString(image->magick,read_info->magick,MaxTextExtent); (void) FormatMagickString(filename,MaxTextExtent,"%s.ufraw", read_info->unique); sans=AcquireExceptionInfo(); xml=FileToString(filename,MaxTextExtent,sans); (void) RelinquishUniqueFileResource(filename); if (xml != (char *) NULL) { XMLTreeInfo *ufraw; /* Inject */ ufraw=NewXMLTree(xml,sans); if (ufraw != (XMLTreeInfo *) NULL) { char *content, property[MaxTextExtent]; const char *tag; XMLTreeInfo *next; if (image->properties == (void *) NULL) ((Image *) image)->properties=NewSplayTree( CompareSplayTreeString,RelinquishMagickMemory, RelinquishMagickMemory); next=GetXMLTreeChild(ufraw,(const char *) NULL); while (next != (XMLTreeInfo *) NULL) { tag=GetXMLTreeTag(next); if (tag == (char *) NULL) tag="unknown"; (void) FormatMagickString(property,MaxTextExtent,"dng:%s",tag); content=ConstantString(GetXMLTreeContent(next)); StripString(content); if ((LocaleCompare(tag,"log") != 0) && (LocaleCompare(tag,"InputFilename") != 0) && (LocaleCompare(tag,"OutputFilename") != 0) && (LocaleCompare(tag,"OutputType") != 0) && (strlen(content) != 0)) (void) AddValueToSplayTree((SplayTreeInfo *) ((Image *) image)->properties,ConstantString(property), content); next=GetXMLTreeSibling(next); } ufraw=DestroyXMLTree(ufraw); } xml=DestroyString(xml); } sans=DestroyExceptionInfo(sans); } read_info=DestroyImageInfo(read_info); return(image); }