Magick::Options::Options(void) : _imageInfo(static_cast<ImageInfo*>(AcquireMagickMemory( sizeof(ImageInfo)))), _quantizeInfo(static_cast<QuantizeInfo*>(AcquireMagickMemory( sizeof(QuantizeInfo)))), _drawInfo(static_cast<DrawInfo*>(AcquireMagickMemory(sizeof(DrawInfo)))), _quiet(false) { // Initialize image info with defaults GetImageInfo(_imageInfo); // Initialize quantization info GetQuantizeInfo(_quantizeInfo); // Initialize drawing info GetDrawInfo(_imageInfo,_drawInfo); }
/* %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % % % % % % 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 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 region of % pixels. % */ WandExport PixelIterator *NewPixelRegionIterator(MagickWand *wand, const ssize_t x,const ssize_t y,const size_t width,const size_t height) { CacheView *view; const char *quantum; ExceptionInfo *exception; Image *image; PixelIterator *iterator; size_t depth; 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); exception=AcquireExceptionInfo(); view=AcquireVirtualCacheView(image,exception); 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) FormatLocaleString(iterator->name,MaxTextExtent,"%s-%.20g", PixelIteratorId,(double) iterator->id); iterator->exception=exception; 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); }
MAGICK_NET_EXPORT unsigned short *PixelCollection_ToShortArray(const CacheView *instance, const size_t x, const size_t y, const size_t width, const size_t height, const char *mapping, ExceptionInfo **exception) { ExportStart(unsigned short); result = AcquireMagickMemory(length); MAGICK_NET_GET_EXCEPTION; ExportImagePixels(GetCacheViewImage(instance), x, y, width, height, mapping, ShortPixel, result, exceptionInfo); MAGICK_NET_SET_EXCEPTION; return result; }
/* %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % % % % % % A c q u i r e Q u a n t u m M e m o r y % % % % % % % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % AcquireQuantumMemory() returns a pointer to a block of memory at least % count * quantum bytes suitably aligned for any use. % % The format of the AcquireQuantumMemory method is: % % void *AcquireQuantumMemory(const size_t count,const size_t quantum) % % A description of each parameter follows: % % o count: the number of quantum elements to allocate. % % o quantum: the number of bytes in each quantum. % */ MagickExport void *AcquireQuantumMemory(const size_t count,const size_t quantum) { size_t extent; if (CheckMemoryOverflow(count,quantum) != MagickFalse) return((void *) NULL); extent=count*quantum; return(AcquireMagickMemory(extent)); }
/* %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % % % % % % A c q u i r e V i r t u a l M e m o r y % % % % % % % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % AcquireVirtualMemory() allocates a pointer to a block of memory at least size % bytes suitably aligned for any use. % % The format of the AcquireVirtualMemory method is: % % MemoryInfo *AcquireVirtualMemory(const size_t count,const size_t quantum) % % A description of each parameter follows: % % o count: the number of quantum elements to allocate. % % o quantum: the number of bytes in each quantum. % */ MagickExport MemoryInfo *AcquireVirtualMemory(const size_t count, const size_t quantum) { MemoryInfo *memory_info; size_t length; length=count*quantum; if ((count == 0) || (quantum != (length/count))) { errno=ENOMEM; return((void *) NULL); } memory_info=(MemoryInfo *) MagickAssumeAligned(AcquireAlignedMemory(1, sizeof(*memory_info))); if (memory_info == (MemoryInfo *) NULL) ThrowFatalException(ResourceLimitFatalError,"MemoryAllocationFailed"); (void) ResetMagickMemory(memory_info,0,sizeof(*memory_info)); memory_info->length=length; memory_info->signature=MagickSignature; memory_info->blob=AcquireMagickMemory(length); if (memory_info->blob == NULL) { /* Heap memory failed, try anonymous memory mapping. */ memory_info->mapped=MagickTrue; memory_info->blob=MapBlob(-1,IOMode,0,length); } if (memory_info->blob == NULL) { int file; /* Anonymous memory mapping failed, try file-backed memory mapping. */ file=AcquireUniqueFileResource(memory_info->filename); file=open_utf8(memory_info->filename,O_RDWR | O_CREAT | O_BINARY | O_EXCL, S_MODE); if (file == -1) file=open_utf8(memory_info->filename,O_RDWR | O_BINARY,S_MODE); if (file != -1) { if ((lseek(file,length-1,SEEK_SET) >= 0) && (write(file,"",1) == 1)) memory_info->blob=MapBlob(file,IOMode,0,length); (void) close(file); } } if (memory_info->blob == NULL) return(RelinquishVirtualMemory(memory_info)); return(memory_info); }
/* %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % % % % % % A c q u i r e T o k e n I n f o % % % % % % % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % AcquireTokenInfo() allocates the TokenInfo structure. % % The format of the AcquireTokenInfo method is: % % TokenInfo *AcquireTokenInfo() % */ MagickExport TokenInfo *AcquireTokenInfo(void) { TokenInfo *token_info; token_info=(TokenInfo *) AcquireMagickMemory(sizeof(*token_info)); if (token_info == (TokenInfo *) NULL) ThrowFatalException(ResourceLimitFatalError,"MemoryAllocationFailed"); token_info->signature=MagickCoreSignature; return(token_info); }
MAGICK_NET_EXPORT GeometryInfo *MagickGeometry_Create(void) { GeometryInfo *geometry_info; geometry_info = (GeometryInfo *)AcquireMagickMemory(sizeof(*geometry_info)); if (geometry_info == (GeometryInfo *)NULL) return (GeometryInfo *)NULL; ResetMagickMemory(geometry_info, 0, sizeof(*geometry_info)); return geometry_info; }
/* %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % % % % % % 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 columns,const unsigned long rows, % const MagickBooleanType modify) % % 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 columns,const unsigned long rows) { const char *quantum; Image *image; PixelIterator *iterator; unsigned long depth; ViewInfo *view; assert(wand != (MagickWand *) NULL); depth=MAGICKCORE_QUANTUM_DEPTH; quantum=GetMagickQuantumDepth(&depth); if (depth != MAGICKCORE_QUANTUM_DEPTH) ThrowWandFatalException(WandError,"QuantumDepthMismatch",quantum); if ((columns == 0) || (rows == 0)) ThrowWandFatalException(WandError,"ZeroRegionSize",quantum); image=GetImageFromMagickWand(wand); if (image == (Image *) NULL) return((PixelIterator *) NULL); view=OpenCacheView(image); if (view == (ViewInfo *) 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=columns; iterator->region.height=rows; 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); }
/* %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % % % % % % M a g i c k Q u e r y M u l t i l i n e F o n t M e t r i c s % % % % % % % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % MagickQueryMultilineFontMetrics() returns a 7 element array representing the % following font metrics: % % Element Description % ------------------------------------------------- % 0 character width % 1 character height % 2 ascender % 3 descender % 4 text width % 5 text height % 6 maximum horizontal advance % % This method is like MagickQueryFontMetrics() but it returns the maximum text % width and height for multiple lines of text. % % The format of the MagickQueryFontMetrics method is: % % double *MagickQueryMultilineFontMetrics(MagickWand *wand, % const DrawingWand *drawing_wand,const char *text) % % A description of each parameter follows: % % o wand: The Magick wand. % % o drawing_wand: The drawing wand. % % o text: The text. % */ WandExport double *MagickQueryMultilineFontMetrics(MagickWand *wand, const DrawingWand *drawing_wand,const char *text) { double *font_metrics; DrawInfo *draw_info; MagickBooleanType status; TypeMetric metrics; assert(wand != (MagickWand *) NULL); assert(wand->signature == MagickSignature); if (wand->debug != MagickFalse) (void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",wand->name); assert(drawing_wand != (const DrawingWand *) NULL); if (wand->images == (Image *) NULL) { (void) ThrowMagickException(&wand->exception,GetMagickModule(),WandError, "ContainsNoImages","`%s'",wand->name); return((double *) NULL); } font_metrics=(double *) AcquireMagickMemory(7*sizeof(*font_metrics)); if (font_metrics == (double *) NULL) return((double *) NULL); draw_info=PeekDrawingWand(drawing_wand); if (draw_info == (DrawInfo *) NULL) { font_metrics=(double *) RelinquishMagickMemory(font_metrics); return((double *) NULL); } (void) CloneString(&draw_info->text,text); (void) ResetMagickMemory(&metrics,0,sizeof(metrics)); status=GetMultilineTypeMetrics(wand->images,draw_info,&metrics); draw_info=DestroyDrawInfo(draw_info); if (status == MagickFalse) { InheritException(&wand->exception,&wand->images->exception); font_metrics=(double *) RelinquishMagickMemory(font_metrics); return((double *) NULL); } font_metrics[0]=metrics.pixels_per_em.x; font_metrics[1]=metrics.pixels_per_em.y; font_metrics[2]=metrics.ascent; font_metrics[3]=metrics.descent; font_metrics[4]=metrics.width; font_metrics[5]=metrics.height; font_metrics[6]=metrics.max_advance; return(font_metrics); }
void * magick_malloc(const size_t size) { void *ptr; ptr = AcquireMagickMemory(size); if (!ptr) { rb_raise(rb_eNoMemError, "not enough memory to continue"); } return ptr; }
/* %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % % % % % % M a g i c k C r e a t e T h r e a d K e y % % % % % % % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % MagickCreateThreadKey() creates a thread key and returns it. % % The format of the MagickCreateThreadKey method is: % % MagickThreadKey MagickCreateThreadKey(MagickThreadKey *key) % */ MagickExport MagickBooleanType MagickCreateThreadKey(MagickThreadKey *key) { #if defined(MAGICKCORE_THREAD_SUPPORT) return(pthread_key_create(key,NULL) == 0 ? MagickTrue : MagickFalse); #elif defined(MAGICKCORE_HAVE_WINTHREADS) *key=TlsAlloc(); return(*key != TLS_OUT_OF_INDEXES ? MagickTrue : MagickFalse); #else *key=AcquireMagickMemory(sizeof(key)); return(*key != (void *) NULL ? MagickTrue : MagickFalse); #endif }
/* %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % % % % % % R e s i z e M a g i c k M e m o r y % % % % % % % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % ResizeMagickMemory() changes the size of the memory and returns a pointer to % the (possibly moved) block. The contents will be unchanged up to the % lesser of the new and old sizes. % % The format of the ResizeMagickMemory method is: % % void *ResizeMagickMemory(void *memory,const size_t size) % % A description of each parameter follows: % % o memory: A pointer to a memory allocation. On return the pointer % may change but the contents of the original allocation will not. % % o size: The new size of the allocated memory. % % */ WandExport void *ResizeMagickMemory(void *memory,const size_t size) { void *allocation; if (memory == (void *) NULL) return(AcquireMagickMemory(size)); allocation=realloc(memory,size); if (allocation == (void *) NULL) (void) RelinquishMagickMemory(memory); return(allocation); }
/* %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % % % % % % A c q u i r e E x c e p t i o n I n f o % % % % % % % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % AcquireExceptionInfo() allocates the ExceptionInfo structure. % % The format of the AcquireExceptionInfo method is: % % ExceptionInfo *AcquireExceptionInfo(void) % */ MagickExport ExceptionInfo *AcquireExceptionInfo(void) { ExceptionInfo *exception; exception=(ExceptionInfo *) AcquireMagickMemory(sizeof(*exception)); if (exception == (ExceptionInfo *) NULL) ThrowFatalException(ResourceLimitFatalError,"MemoryAllocationFailed"); GetExceptionInfo(exception); exception->relinquish=MagickTrue; return(exception); }
void Magick::PixelData::init(Magick::Image &image_,const ::ssize_t x_, const ::ssize_t y_,const size_t width_,const size_t height_, std::string map_,const StorageType type_) { size_t size; _data=(void *) NULL; _length=0; _size=0; if ((x_ < 0) || (width_ == 0) || (y_ < 0) || (height_ == 0) || (x_ > image_.columns()) || ((width_ + x_) > image_.columns()) || (y_ > image_.rows()) || ((height_ + y_) > image_.rows()) || (map_.length() == 0)) return; switch(type_) { case CharPixel: size=sizeof(unsigned char); break; case DoublePixel: size=sizeof(double); break; case FloatPixel: size=sizeof(float); break; case IntegerPixel: case LongPixel: size=sizeof(unsigned int); break; case QuantumPixel: size=sizeof(Quantum); break; case ShortPixel: size=sizeof(unsigned short); break; default: throwExceptionExplicit(OptionError,"Invalid type"); return; } _length=width_*height_*map_.length(); _size=_length*size; _data=AcquireMagickMemory(_size); GetPPException; MagickCore::ExportImagePixels(image_.constImage(),x_,y_,width_,height_, map_.c_str(),type_,_data,exceptionInfo); if (exceptionInfo->severity != UndefinedException) relinquish(); ThrowPPException(image_.quiet()); }
/* %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % % % % % % A c q u i r e Q u a n t u m M e m o r y % % % % % % % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % AcquireQuantumMemory() returns a pointer to a block of memory at least % count * quantum bytes suitably aligned for any use. % % The format of the AcquireQuantumMemory method is: % % void *AcquireQuantumMemory(const size_t count,const size_t quantum) % % A description of each parameter follows: % % o count: the number of quantum elements to allocate. % % o quantum: the number of bytes in each quantum. % */ MagickExport void *AcquireQuantumMemory(const size_t count,const size_t quantum) { size_t size; size=count*quantum; if ((count == 0) || (quantum != (size/count))) { errno=ENOMEM; return((void *) NULL); } return(AcquireMagickMemory(size)); }
/* %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % % % % % % C l o n e E x c e p t i o n I n f o % % % % % % % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % CloneExceptionInfo() clones the ExceptionInfo structure. % % The format of the CloneExceptionInfo method is: % % ExceptionInfo *CloneException(ExceptionInfo *exception) % % A description of each parameter follows: % % o exception: the exception info. % */ MagickExport ExceptionInfo *CloneExceptionInfo(ExceptionInfo *exception) { ExceptionInfo *clone_exception; clone_exception=(ExceptionInfo *) AcquireMagickMemory(sizeof(*exception)); if (clone_exception == (ExceptionInfo *) NULL) ThrowFatalException(ResourceLimitFatalError,"MemoryAllocationFailed"); GetExceptionInfo(clone_exception); InheritException(clone_exception,exception); exception->relinquish=MagickTrue; return(exception); }
/* %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % % % % % % A c q u i r e T i m e r I n f o % % % % % % % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % AcquireTimerInfo() initializes the TimerInfo structure. It effectively % creates a stopwatch and starts it. % % The format of the AcquireTimerInfo method is: % % TimerInfo *AcquireTimerInfo(void) % */ MagickExport TimerInfo *AcquireTimerInfo(void) { TimerInfo *timer_info; timer_info=(TimerInfo *) AcquireMagickMemory(sizeof(*timer_info)); if (timer_info == (TimerInfo *) NULL) ThrowFatalException(ResourceLimitFatalError,"UnableToAcquireString"); (void) ResetMagickMemory(timer_info,0,sizeof(*timer_info)); timer_info->signature=MagickSignature; GetTimerInfo(timer_info); return(timer_info); }
/* %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % % % % % % 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); }
/* %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % % % % % % A c q u i r e S c r i p t T o k e n I n f o % % % % % % % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % AcquireScriptTokenInfo() allocated, initializes and opens the given % file stream from which tokens are to be extracted. % % The format of the AcquireScriptTokenInfo method is: % % ScriptTokenInfo *AcquireScriptTokenInfo(char *filename) % % A description of each parameter follows: % % o filename the filename to open ("-" means stdin) % */ WandExport ScriptTokenInfo *AcquireScriptTokenInfo(char *filename) { ScriptTokenInfo *token_info; token_info=(ScriptTokenInfo *) AcquireMagickMemory(sizeof(*token_info)); if (token_info == (ScriptTokenInfo *) NULL) return token_info; (void) ResetMagickMemory(token_info,0,sizeof(*token_info)); token_info->opened=MagickFalse; if ( LocaleCompare(filename,"-") == 0 ) { token_info->stream=stdin; token_info->opened=MagickFalse; } else if ( LocaleNCompare(filename,"fd:",3) == 0 ) { token_info->stream=fdopen(StringToLong(filename+3),"r"); token_info->opened=MagickFalse; } else { token_info->stream=fopen_utf8(filename, "r"); } if ( token_info->stream == (FILE *)NULL ) { token_info=(ScriptTokenInfo *) RelinquishMagickMemory(token_info); return(token_info); } token_info->curr_line=1; token_info->length=INITAL_TOKEN_LENGTH; token_info->token=(char *) AcquireMagickMemory(token_info->length); token_info->status=(token_info->token != (char *)NULL) ? TokenStatusOK : TokenStatusMemoryFailed; token_info->signature=WandSignature; return token_info; }
void Magick::Options::strokeDashArray(const double *strokeDashArray_) { _drawInfo->dash_pattern=(double *) RelinquishMagickMemory( _drawInfo->dash_pattern); if(strokeDashArray_) { size_t x; // Count elements in dash array for (x=0; strokeDashArray_[x]; x++) ; // Allocate elements _drawInfo->dash_pattern=static_cast<double*>(AcquireMagickMemory((x+1)* sizeof(double))); // Copy elements memcpy(_drawInfo->dash_pattern,strokeDashArray_,(x+1)*sizeof(double)); } }
/* %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % % % % % % C l o n e I m a g e V i e w % % % % % % % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % CloneImageView() makes a copy of the specified image view. % % The format of the CloneImageView method is: % % ImageView *CloneImageView(const ImageView *image_view) % % A description of each parameter follows: % % o image_view: the image view. % */ MagickExport ImageView *CloneImageView(const ImageView *image_view) { ImageView *clone_view; assert(image_view != (ImageView *) NULL); assert(image_view->signature == MagickSignature); clone_view=(ImageView *) AcquireMagickMemory(sizeof(*clone_view)); if (clone_view == (ImageView *) NULL) ThrowFatalException(ResourceLimitFatalError,"MemoryAllocationFailed"); (void) ResetMagickMemory(clone_view,0,sizeof(*clone_view)); clone_view->description=ConstantString(image_view->description); clone_view->extent=image_view->extent; clone_view->view=CloneCacheView(image_view->view); clone_view->exception=AcquireExceptionInfo(); InheritException(clone_view->exception,image_view->exception); clone_view->debug=image_view->debug; clone_view->signature=MagickSignature; return(clone_view); }
/* %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % % % % % % T h r o w E x c e p t i o n % % % % % % % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % ThrowException() throws an exception with the specified severity code, % reason, and optional description. % % The format of the ThrowException method is: % % MagickBooleanType ThrowException(ExceptionInfo *exception, % const ExceptionType severity,const char *reason, % const char *description) % % A description of each parameter follows: % % o exception: the exception info. % % o severity: the severity of the exception. % % o reason: the reason for the exception. % % o description: the exception description. % */ MagickExport MagickBooleanType ThrowException(ExceptionInfo *exception, const ExceptionType severity,const char *reason,const char *description) { register ExceptionInfo *p; assert(exception != (ExceptionInfo *) NULL); assert(exception->signature == MagickSignature); LockSemaphoreInfo(exception->semaphore); p=(ExceptionInfo *) GetLastValueInLinkedList((LinkedListInfo *) exception->exceptions); if ((p != (ExceptionInfo *) NULL) && (p->severity == severity) && (LocaleCompare(exception->reason,reason) == 0) && (LocaleCompare(exception->description,description) == 0)) { UnlockSemaphoreInfo(exception->semaphore); return(MagickTrue); } p=(ExceptionInfo *) AcquireMagickMemory(sizeof(*p)); if (p == (ExceptionInfo *) NULL) { UnlockSemaphoreInfo(exception->semaphore); ThrowFatalException(ResourceLimitFatalError,"MemoryAllocationFailed"); } (void) ResetMagickMemory(p,0,sizeof(*p)); p->severity=severity; if (reason != (const char *) NULL) p->reason=ConstantString(reason); if (description != (const char *) NULL) p->description=ConstantString(description); p->signature=MagickSignature; (void) AppendValueToLinkedList((LinkedListInfo *) exception->exceptions,p); if (p->severity >= exception->severity) { exception->severity=p->severity; exception->reason=p->reason; exception->description=p->description; } UnlockSemaphoreInfo(exception->semaphore); return(MagickTrue); }
MagickExport QuantumInfo *AcquireQuantumInfo(const ImageInfo *image_info, Image *image) { MagickBooleanType status; QuantumInfo *quantum_info; quantum_info=(QuantumInfo *) AcquireMagickMemory(sizeof(*quantum_info)); if (quantum_info == (QuantumInfo *) NULL) ThrowFatalException(ResourceLimitFatalError,"MemoryAllocationFailed"); quantum_info->signature=MagickSignature; GetQuantumInfo(image_info,quantum_info); if (image == (const Image *) NULL) return(quantum_info); status=SetQuantumDepth(image,quantum_info,image->depth); if (status == MagickFalse) quantum_info=DestroyQuantumInfo(quantum_info); return(quantum_info); }
/* %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % % % % % % 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) { char *message; message=GetExceptionMessage(errno); ThrowWandFatalException(ResourceLimitFatalError,"MemoryAllocationFailed", message); message=DestroyString(message); } (void) ResetMagickMemory(wand,0,sizeof(*wand)); wand->id=AcquireWandId(); (void) FormatMagickString(wand->name,MaxTextExtent,"%s-%lu",MagickWandId, 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); }
/* %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % % % % % % C l o n e C a c h e V i e w % % % % % % % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % CloneCacheView() makes an exact copy of the specified cache view. % % The format of the CloneCacheView method is: % % CacheView *CloneCacheView(const CacheView *cache_view) % % A description of each parameter follows: % % o cache_view: the cache view. % */ MagickExport CacheView *CloneCacheView(const CacheView *cache_view) { CacheView *clone_view; assert(cache_view != (CacheView *) NULL); assert(cache_view->signature == MagickSignature); if (cache_view->debug != MagickFalse) (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s", cache_view->image->filename); clone_view=(CacheView *) AcquireMagickMemory(sizeof(*clone_view)); if (clone_view == (CacheView *) NULL) ThrowFatalException(ResourceLimitFatalError,"MemoryAllocationFailed"); (void) ResetMagickMemory(clone_view,0,sizeof(*clone_view)); clone_view->image=ReferenceImage(cache_view->image); clone_view->number_threads=cache_view->number_threads; clone_view->nexus_info=AcquirePixelCacheNexus(cache_view->number_threads); clone_view->virtual_pixel_method=cache_view->virtual_pixel_method; clone_view->debug=cache_view->debug; clone_view->signature=MagickSignature; return(clone_view); }
void Magick::Options::strokeDashArray(const double *strokeDashArray_) { _drawInfo->dash_pattern=(double *) RelinquishMagickMemory( _drawInfo->dash_pattern); if(strokeDashArray_) { size_t x; // Count elements in dash array for (x=0; strokeDashArray_[x]; x++) ; // Allocate elements _drawInfo->dash_pattern=static_cast<double*>(AcquireMagickMemory((x+1)* sizeof(double))); if (!_drawInfo->dash_pattern) throwExceptionExplicit(MagickCore::ResourceLimitError, "Unable to allocate dash-pattern memory"); // Copy elements memcpy(_drawInfo->dash_pattern,strokeDashArray_,(x+1)*sizeof(double)); _drawInfo->dash_pattern[x]=0.0; } }
/* %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % % % % % % C l o n e M o n t a g e I n f o % % % % % % % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % CloneMontageInfo() makes a copy of the given montage info structure. If % NULL is specified, a new image info structure is created initialized to % default values. % % The format of the CloneMontageInfo method is: % % MontageInfo *CloneMontageInfo(const ImageInfo *image_info, % const MontageInfo *montage_info) % % A description of each parameter follows: % % o image_info: the image info. % % o montage_info: the montage info. % */ MagickExport MontageInfo *CloneMontageInfo(const ImageInfo *image_info, const MontageInfo *montage_info) { MontageInfo *clone_info; clone_info=(MontageInfo *) AcquireMagickMemory(sizeof(*clone_info)); if (clone_info == (MontageInfo *) NULL) ThrowFatalException(ResourceLimitFatalError,"MemoryAllocationFailed"); GetMontageInfo(image_info,clone_info); if (montage_info == (MontageInfo *) NULL) return(clone_info); if (montage_info->geometry != (char *) NULL) clone_info->geometry=AcquireString(montage_info->geometry); if (montage_info->tile != (char *) NULL) clone_info->tile=AcquireString(montage_info->tile); if (montage_info->title != (char *) NULL) clone_info->title=AcquireString(montage_info->title); if (montage_info->frame != (char *) NULL) clone_info->frame=AcquireString(montage_info->frame); if (montage_info->texture != (char *) NULL) clone_info->texture=AcquireString(montage_info->texture); if (montage_info->font != (char *) NULL) clone_info->font=AcquireString(montage_info->font); clone_info->pointsize=montage_info->pointsize; clone_info->border_width=montage_info->border_width; clone_info->shadow=montage_info->shadow; clone_info->fill=montage_info->fill; clone_info->stroke=montage_info->stroke; clone_info->background_color=montage_info->background_color; clone_info->border_color=montage_info->border_color; clone_info->matte_color=montage_info->matte_color; clone_info->gravity=montage_info->gravity; (void) CopyMagickString(clone_info->filename,montage_info->filename, MagickPathExtent); clone_info->debug=IsEventLogging(); return(clone_info); }
/* %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % % % % % % N e w I m a g e V i e w % % % % % % % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % NewImageView() returns a image view required for all other methods in the % Image View API. % % The format of the NewImageView method is: % % ImageView *NewImageView(MagickCore *wand,ExceptionInfo *exception) % % A description of each parameter follows: % % o image: the image. % % o exception: return any errors or warnings in this structure. % */ MagickExport ImageView *NewImageView(Image *image,ExceptionInfo *exception) { ImageView *image_view; assert(image != (Image *) NULL); assert(image->signature == MagickSignature); image_view=(ImageView *) AcquireMagickMemory(sizeof(*image_view)); if (image_view == (ImageView *) NULL) ThrowFatalException(ResourceLimitFatalError,"MemoryAllocationFailed"); (void) ResetMagickMemory(image_view,0,sizeof(*image_view)); image_view->description=ConstantString("ImageView"); image_view->image=image; image_view->view=AcquireVirtualCacheView(image_view->image,exception); image_view->extent.width=image->columns; image_view->extent.height=image->rows; image_view->extent.x=0; image_view->extent.y=0; image_view->exception=AcquireExceptionInfo(); image_view->debug=IsEventLogging(); image_view->signature=MagickSignature; return(image_view); }
/* %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % % % % % % % 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) { ExceptionInfo *exception; 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) FormatLocaleString(wand_view->name,MaxTextExtent,"%s-%.20g", WandViewId,(double) wand_view->id); wand_view->description=ConstantString("WandView"); exception=AcquireExceptionInfo(); wand_view->view=AcquireVirtualCacheView(wand_view->wand->images,exception); 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->exception=exception; wand_view->pixel_wands=AcquirePixelsThreadSet(wand_view->extent.width); 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 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) FormatLocaleString(clone_view->name,MaxTextExtent,"%s-%.20g", WandViewId,(double) clone_view->id); clone_view->description=ConstantString(wand_view->description); clone_view->image=CloneImage(wand_view->image,0,0,MagickTrue, wand_view->exception); clone_view->view=CloneCacheView(wand_view->view); clone_view->extent=wand_view->extent; clone_view->exception=AcquireExceptionInfo(); InheritException(clone_view->exception,wand_view->exception); for (i=0; i < (ssize_t) GetMagickResourceLimit(ThreadResource); 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); }