本文整理汇总了C++中DestroyString函数的典型用法代码示例。如果您正苦于以下问题:C++ DestroyString函数的具体用法?C++ DestroyString怎么用?C++ DestroyString使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了DestroyString函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: IdentifyImageCommand
WandExport MagickBooleanType IdentifyImageCommand(ImageInfo *image_info,
int argc,char **argv,char **metadata,ExceptionInfo *exception)
{
#define DestroyIdentify() \
{ \
DestroyImageStack(); \
for (i=0; i < (ssize_t) argc; i++) \
argv[i]=DestroyString(argv[i]); \
argv=(char **) RelinquishMagickMemory(argv); \
}
#define ThrowIdentifyException(asperity,tag,option) \
{ \
(void) ThrowMagickException(exception,GetMagickModule(),asperity,tag,"`%s'", \
option); \
DestroyIdentify(); \
return(MagickFalse); \
}
#define ThrowIdentifyInvalidArgumentException(option,argument) \
{ \
(void) ThrowMagickException(exception,GetMagickModule(),OptionError, \
"InvalidArgument","`%s': %s",option,argument); \
DestroyIdentify(); \
return(MagickFalse); \
}
const char
*format,
*option;
Image
*image;
ImageStack
image_stack[MaxImageStackDepth+1];
MagickBooleanType
fire,
pend,
respect_parenthesis;
MagickStatusType
status;
register ssize_t
i;
size_t
count;
ssize_t
j,
k;
/*
Set defaults.
*/
assert(image_info != (ImageInfo *) NULL);
assert(image_info->signature == MagickSignature);
if (image_info->debug != MagickFalse)
(void) LogMagickEvent(TraceEvent,GetMagickModule(),"...");
assert(exception != (ExceptionInfo *) NULL);
if (argc == 2)
{
option=argv[1];
if ((LocaleCompare("version",option+1) == 0) ||
(LocaleCompare("-version",option+1) == 0))
{
(void) FormatLocaleFile(stdout,"Version: %s\n",
GetMagickVersion((size_t *) NULL));
(void) FormatLocaleFile(stdout,"Copyright: %s\n",
GetMagickCopyright());
(void) FormatLocaleFile(stdout,"Features: %s\n\n",
GetMagickFeatures());
return(MagickFalse);
}
}
if (argc < 2)
return(IdentifyUsage());
count=0;
format=NULL;
j=1;
k=0;
NewImageStack();
option=(char *) NULL;
pend=MagickFalse;
respect_parenthesis=MagickFalse;
status=MagickTrue;
/*
Identify an image.
*/
ReadCommandlLine(argc,&argv);
status=ExpandFilenames(&argc,&argv);
if (status == MagickFalse)
ThrowIdentifyException(ResourceLimitError,"MemoryAllocationFailed",
GetExceptionMessage(errno));
image_info->ping=MagickTrue;
for (i=1; i < (ssize_t) argc; i++)
{
option=argv[i];
if (LocaleCompare(option,"(") == 0)
//.........这里部分代码省略.........
示例2: assert
//.........这里部分代码省略.........
if ((*p == '}') && (*(p+1) == ';'))
break;
p+=strlen(p);
if ((size_t) (p-xpm_buffer+MaxTextExtent) < length)
continue;
length<<=1;
xpm_buffer=(char *) ResizeQuantumMemory(xpm_buffer,length+MaxTextExtent,
sizeof(*xpm_buffer));
if (xpm_buffer == (char *) NULL)
break;
p=xpm_buffer+strlen(xpm_buffer);
}
if (xpm_buffer == (char *) NULL)
ThrowReaderException(ResourceLimitError,"MemoryAllocationFailed");
/*
Remove comments.
*/
count=0;
width=0;
for (p=xpm_buffer; *p != '\0'; p++)
{
if (*p != '"')
continue;
count=(ssize_t) sscanf(p+1,"%lu %lu %lu %lu",&columns,&rows,&colors,&width);
image->columns=columns;
image->rows=rows;
image->colors=colors;
if (count == 4)
break;
}
if ((count != 4) || (width > 10) || (image->columns == 0) ||
(image->rows == 0) || (image->colors == 0))
{
xpm_buffer=DestroyString(xpm_buffer);
ThrowReaderException(CorruptImageError,"ImproperImageHeader");
}
/*
Remove unquoted characters.
*/
active=MagickFalse;
q=xpm_buffer;
while (*p != '\0')
{
if (*p++ == '"')
{
if (active != MagickFalse)
*q++='\n';
active=active != MagickFalse ? MagickFalse : MagickTrue;
}
if (active != MagickFalse)
*q++=(*p);
}
*q='\0';
/*
Initialize image structure.
*/
xpm_colors=NewSplayTree(CompareXPMColor,RelinquishMagickMemory,
(void *(*)(void *)) NULL);
if (AcquireImageColormap(image,image->colors) == MagickFalse)
{
xpm_buffer=DestroyString(xpm_buffer);
ThrowReaderException(ResourceLimitError,"MemoryAllocationFailed");
}
/*
Read image colormap.
*/
示例3: ReadLABELImage
/*
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %
% %
% %
% R e a d L A B E L I m a g e %
% %
% %
% %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% ReadLABELImage() reads a LABEL 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 ReadLABELImage method is:
%
% Image *ReadLABELImage(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 *ReadLABELImage(const ImageInfo *image_info,
ExceptionInfo *exception)
{
char
geometry[MaxTextExtent],
*property;
const char
*label;
DrawInfo
*draw_info;
Image
*image;
MagickBooleanType
status;
TypeMetric
metrics;
size_t
height,
width;
/*
Initialize Image structure.
*/
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,exception);
(void) ResetImagePage(image,"0x0+0+0");
property=InterpretImageProperties((ImageInfo *) image_info,image,
image_info->filename,exception);
(void) SetImageProperty(image,"label",property,exception);
property=DestroyString(property);
label=GetImageProperty(image,"label",exception);
draw_info=CloneDrawInfo(image_info,(DrawInfo *) NULL);
draw_info->text=ConstantString(label);
status=GetMultilineTypeMetrics(image,draw_info,&metrics,exception);
if ((image->columns == 0) && (image->rows == 0))
{
image->columns=(size_t) (metrics.width+draw_info->stroke_width+0.5);
image->rows=(size_t) floor(metrics.height+draw_info->stroke_width+0.5);
}
else
if (((image->columns == 0) || (image->rows == 0)) ||
(fabs(image_info->pointsize) < MagickEpsilon))
{
double
high,
low;
/*
Auto fit text into bounding box.
*/
for ( ; ; draw_info->pointsize*=2.0)
{
(void) FormatLocaleString(geometry,MaxTextExtent,"%+g%+g",
-metrics.bounds.x1,metrics.ascent);
if (draw_info->gravity == UndefinedGravity)
(void) CloneString(&draw_info->geometry,geometry);
status=GetMultilineTypeMetrics(image,draw_info,&metrics,exception);
width=(size_t) floor(metrics.width+draw_info->stroke_width+0.5);
height=(size_t) floor(metrics.height+draw_info->stroke_width+0.5);
if ((image->columns != 0) && (image->rows != 0))
{
//.........这里部分代码省略.........
示例4: LoadMimeList
/*
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %
% %
% %
+ L o a d M i m e L i s t %
% %
% %
% %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% LoadMimeList() loads the magic configuration file which provides a mapping
% between magic attributes and a magic name.
%
% The format of the LoadMimeList method is:
%
% MagickBooleanType LoadMimeList(const char *xml,const char *filename,
% const size_t depth,ExceptionInfo *exception)
%
% A description of each parameter follows:
%
% o xml: The mime list in XML format.
%
% o filename: The mime list filename.
%
% o depth: depth of <include /> statements.
%
% o exception: return any errors or warnings in this structure.
%
*/
static MagickBooleanType LoadMimeList(const char *xml,const char *filename,
const size_t depth,ExceptionInfo *exception)
{
const char
*attribute;
MimeInfo
*mime_info = (MimeInfo *) NULL;
MagickBooleanType
status;
XMLTreeInfo
*mime,
*mime_map,
*include;
/*
Load the mime map file.
*/
(void) LogMagickEvent(ConfigureEvent,GetMagickModule(),
"Loading mime map \"%s\" ...",filename);
if (xml == (const char *) NULL)
return(MagickFalse);
if (mime_list == (LinkedListInfo *) NULL)
{
mime_list=NewLinkedList(0);
if (mime_list == (LinkedListInfo *) NULL)
{
ThrowFileException(exception,ResourceLimitError,
"MemoryAllocationFailed",filename);
return(MagickFalse);
}
}
mime_map=NewXMLTree(xml,exception);
if (mime_map == (XMLTreeInfo *) NULL)
return(MagickFalse);
status=MagickTrue;
include=GetXMLTreeChild(mime_map,"include");
while (include != (XMLTreeInfo *) NULL)
{
/*
Process include element.
*/
attribute=GetXMLTreeAttribute(include,"file");
if (attribute != (const char *) NULL)
{
if (depth > 200)
(void) ThrowMagickException(exception,GetMagickModule(),
ConfigureError,"IncludeElementNestedTooDeeply","'%s'",filename);
else
{
char
path[MaxTextExtent],
*xml;
GetPathComponent(filename,HeadPath,path);
if (*path != '\0')
(void) ConcatenateMagickString(path,DirectorySeparator,
MaxTextExtent);
if (*attribute == *DirectorySeparator)
(void) CopyMagickString(path,attribute,MaxTextExtent);
else
(void) ConcatenateMagickString(path,attribute,MaxTextExtent);
xml=FileToString(path,~0,exception);
if (xml != (char *) NULL)
{
status=LoadMimeList(xml,path,depth+1,exception);
xml=DestroyString(xml);
}
//.........这里部分代码省略.........
示例5: ResourceComponentGenesis
MagickExport MagickBooleanType ResourceComponentGenesis(void)
{
char
*limit;
ssize_t
files,
pages,
pagesize;
MagickSizeType
memory;
/*
Set Magick resource limits.
*/
AcquireSemaphoreInfo(&resource_semaphore);
pagesize=GetMagickPageSize();
pages=(-1);
#if defined(MAGICKCORE_HAVE_SYSCONF) && defined(_SC_PHYS_PAGES)
pages=(ssize_t) sysconf(_SC_PHYS_PAGES);
#endif
memory=(MagickSizeType) pages*pagesize;
if ((pagesize <= 0) || (pages <= 0))
memory=2048UL*1024UL*1024UL;
#if defined(PixelCacheThreshold)
memory=PixelCacheThreshold;
#endif
(void) SetMagickResourceLimit(AreaResource,2*memory/sizeof(PixelPacket));
(void) SetMagickResourceLimit(MemoryResource,memory);
(void) SetMagickResourceLimit(MapResource,2*memory);
limit=GetEnvironmentValue("MAGICK_AREA_LIMIT");
if (limit == (char *) NULL)
limit=GetPolicyValue("area");
if (limit != (char *) NULL)
{
(void) SetMagickResourceLimit(AreaResource,StringToSizeType(limit,100.0));
limit=DestroyString(limit);
}
limit=GetEnvironmentValue("MAGICK_MEMORY_LIMIT");
if (limit == (char *) NULL)
limit=GetPolicyValue("memory");
if (limit != (char *) NULL)
{
(void) SetMagickResourceLimit(MemoryResource,
StringToSizeType(limit,100.0));
limit=DestroyString(limit);
}
limit=GetEnvironmentValue("MAGICK_MAP_LIMIT");
if (limit == (char *) NULL)
limit=GetPolicyValue("map");
if (limit != (char *) NULL)
{
(void) SetMagickResourceLimit(MapResource,StringToSizeType(limit,100.0));
limit=DestroyString(limit);
}
limit=GetEnvironmentValue("MAGICK_DISK_LIMIT");
if (limit == (char *) NULL)
limit=GetPolicyValue("disk");
if (limit != (char *) NULL)
{
(void) SetMagickResourceLimit(DiskResource,StringToSizeType(limit,100.0));
limit=DestroyString(limit);
}
files=(-1);
#if defined(MAGICKCORE_HAVE_SYSCONF) && defined(_SC_OPEN_MAX)
files=(ssize_t) sysconf(_SC_OPEN_MAX);
#endif
#if defined(MAGICKCORE_HAVE_GETRLIMIT) && defined(RLIMIT_NOFILE)
if (files < 0)
{
struct rlimit
resources;
if (getrlimit(RLIMIT_NOFILE,&resources) != -1)
files=(ssize_t) resources.rlim_cur;
}
#endif
#if defined(MAGICKCORE_HAVE_GETDTABLESIZE) && defined(MAGICKCORE_POSIX_SUPPORT)
if (files < 0)
files=(ssize_t) getdtablesize();
#endif
if (files < 0)
files=64;
(void) SetMagickResourceLimit(FileResource,MagickMax((size_t)
(3*files/4),64));
limit=GetEnvironmentValue("MAGICK_FILE_LIMIT");
if (limit == (char *) NULL)
limit=GetPolicyValue("file");
if (limit != (char *) NULL)
{
(void) SetMagickResourceLimit(FileResource,StringToSizeType(limit,100.0));
limit=DestroyString(limit);
}
(void) SetMagickResourceLimit(ThreadResource,GetOpenMPMaximumThreads());
limit=GetEnvironmentValue("MAGICK_THREAD_LIMIT");
if (limit == (char *) NULL)
limit=GetPolicyValue("thread");
if (limit != (char *) NULL)
{
//.........这里部分代码省略.........
示例6: InitTTY
//.........这里部分代码省略.........
Tempstr=FormatStr(Tempstr,"%d",tty);
if (! TTYAttribs) TTYAttribs=ListCreate();
Curr=ListFindNamedItem(TTYAttribs,Tempstr);
if (! Curr)
{
old_tty_data=(struct termios *) calloc(1,sizeof(struct termios));
ListAddNamedItem(TTYAttribs,Tempstr,old_tty_data);
}
else old_tty_data=(struct termios *) Curr->Item;
tcgetattr(tty,old_tty_data);
//tcgetattr(tty,&tty_data);
memset(&tty_data,0,sizeof(tty_data));
//ignore break characters and parity errors
tty_data.c_iflag=IGNBRK | IGNPAR;
//Enable Special Characters
if (Flags & TTYFLAG_CANON) tty_data.c_iflag|= ICANON;
//else tty_data.c_iflag &= ~ICANON;
/*
if (! (Flags & TTYFLAG_CRLF_KEEP))
{
//translate carriage-return to newline
if (Flags & TTYFLAG_CRLF) tty_data.c_iflag |= ICRNL;
else tty_data.c_iflag &= ~ICRNL;
//translate newline to carriage return
if (Flags & TTYFLAG_LFCR)
{
tty_data.c_iflag |= INLCR;
}
else tty_data.c_iflag &= ~INLCR;
//output flags
tty_data.c_oflag=0;
//postprocess and translate newline to cr-nl
if (Flags & TTYFLAG_LFCR) tty_data.c_oflag |= ONLCR | OPOST;
}
*/
tty_data.c_cflag=CREAD | CS8 | HUPCL | CLOCAL;
if (Flags & TTYFLAG_SOFTWARE_FLOW)
{
tty_data.c_iflag |= IXON | IXOFF;
}
if (Flags & TTYFLAG_HARDWARE_FLOW) tty_data.c_cflag |=CRTSCTS;
if (Flags & TTYFLAG_ECHO) tty_data.c_cflag |= ECHO;
tty_data.c_lflag=0;
if (Flags & TTYFLAG_ISIG) tty_data.c_lflag=ISIG;
tty_data.c_cc[VMIN]=1;
tty_data.c_cc[VTIME]=0;
if (LineSpeed > 0)
{
switch (LineSpeed)
{
case 2400: val=B2400; break;
case 4800: val=B4800; break;
case 9600: val=B9600; break;
case 19200: val=B19200; break;
case 38400: val=B38400; break;
case 57600: val=B57600; break;
case 115200: val=B115200; break;
case 230400: val=B230400; break;
#ifdef B460800
case 460800: val=B460800; break;
#endif
#ifdef B500000
case 500000: val=B500000; break;
#endif
#ifdef B1000000
case 10000000: val=B1000000; break;
#endif
#ifdef B1152000
case 1152000: val=B1152000; break;
#endif
#ifdef B2000000
case 2000000: val=B2000000; break;
#endif
#ifdef B4000000
case 4000000: val=B4000000; break;
#endif
default: val=B115200; break;
}
cfsetispeed(&tty_data,val);
cfsetospeed(&tty_data,val);
}
tcflush(tty,TCIFLUSH);
result=tcsetattr(tty,TCSANOW,&tty_data);
DestroyString(Tempstr);
}
示例7: WriteFITSImage
//.........这里部分代码省略.........
GrayQuantum,pixels,exception);
if (image->depth == 16)
SetFITSUnsignedPixels(image->columns,image->depth,image->endian,
pixels);
if (((image->depth == 32) || (image->depth == 64)) &&
(quantum_info->format != FloatingPointQuantumFormat))
SetFITSUnsignedPixels(image->columns,image->depth,image->endian,
pixels);
count=WriteBlob(image,length,pixels);
if (count != (ssize_t) length)
break;
status=SetImageProgress(image,SaveImageTag,(MagickOffsetType) y,
image->rows);
if (status == MagickFalse)
break;
}
}
else
{
length=GetQuantumExtent(image,quantum_info,RedQuantum);
for (y=(ssize_t) image->rows-1; y >= 0; y--)
{
p=GetVirtualPixels(image,0,y,image->columns,1,exception);
if (p == (const Quantum *) NULL)
break;
length=ExportQuantumPixels(image,(CacheView *) NULL,quantum_info,
RedQuantum,pixels,exception);
if (image->depth == 16)
SetFITSUnsignedPixels(image->columns,image->depth,image->endian,
pixels);
if (((image->depth == 32) || (image->depth == 64)) &&
(quantum_info->format != FloatingPointQuantumFormat))
SetFITSUnsignedPixels(image->columns,image->depth,image->endian,
pixels);
count=WriteBlob(image,length,pixels);
if (count != (ssize_t) length)
break;
status=SetImageProgress(image,SaveImageTag,(MagickOffsetType) y,
image->rows);
if (status == MagickFalse)
break;
}
length=GetQuantumExtent(image,quantum_info,GreenQuantum);
for (y=(ssize_t) image->rows-1; y >= 0; y--)
{
p=GetVirtualPixels(image,0,y,image->columns,1,exception);
if (p == (const Quantum *) NULL)
break;
length=ExportQuantumPixels(image,(CacheView *) NULL,quantum_info,
GreenQuantum,pixels,exception);
if (image->depth == 16)
SetFITSUnsignedPixels(image->columns,image->depth,image->endian,
pixels);
if (((image->depth == 32) || (image->depth == 64)) &&
(quantum_info->format != FloatingPointQuantumFormat))
SetFITSUnsignedPixels(image->columns,image->depth,image->endian,
pixels);
count=WriteBlob(image,length,pixels);
if (count != (ssize_t) length)
break;
status=SetImageProgress(image,SaveImageTag,(MagickOffsetType) y,
image->rows);
if (status == MagickFalse)
break;
}
length=GetQuantumExtent(image,quantum_info,BlueQuantum);
for (y=(ssize_t) image->rows-1; y >= 0; y--)
{
p=GetVirtualPixels(image,0,y,image->columns,1,exception);
if (p == (const Quantum *) NULL)
break;
length=ExportQuantumPixels(image,(CacheView *) NULL,quantum_info,
BlueQuantum,pixels,exception);
if (image->depth == 16)
SetFITSUnsignedPixels(image->columns,image->depth,image->endian,
pixels);
if (((image->depth == 32) || (image->depth == 64)) &&
(quantum_info->format != FloatingPointQuantumFormat))
SetFITSUnsignedPixels(image->columns,image->depth,image->endian,
pixels);
count=WriteBlob(image,length,pixels);
if (count != (ssize_t) length)
break;
status=SetImageProgress(image,SaveImageTag,(MagickOffsetType) y,
image->rows);
if (status == MagickFalse)
break;
}
}
quantum_info=DestroyQuantumInfo(quantum_info);
length=(size_t) (FITSBlocksize-TellBlob(image) % FITSBlocksize);
if (length != 0)
{
(void) ResetMagickMemory(fits_info,0,length*sizeof(*fits_info));
(void) WriteBlob(image,length,(unsigned char *) fits_info);
}
fits_info=DestroyString(fits_info);
(void) CloseBlob(image);
return(MagickTrue);
}
示例8: ConjureImageCommand
WandExport MagickBooleanType ConjureImageCommand(ImageInfo *image_info,
int argc,char **argv,char **wand_unused(metadata),ExceptionInfo *exception)
{
#define DestroyConjure() \
{ \
image=DestroyImageList(image); \
for (i=0; i < (ssize_t) argc; i++) \
argv[i]=DestroyString(argv[i]); \
argv=(char **) RelinquishMagickMemory(argv); \
}
#define ThrowConjureException(asperity,tag,option) \
{ \
(void) ThrowMagickException(exception,GetMagickModule(),asperity,tag,"`%s'", \
option); \
DestroyConjure(); \
return(MagickFalse); \
}
#define ThrowConjureInvalidArgumentException(option,argument) \
{ \
(void) ThrowMagickException(exception,GetMagickModule(),OptionError, \
"InvalidArgument","'%s': %s",option,argument); \
DestroyConjure(); \
return(MagickFalse); \
}
char
filename[MaxTextExtent],
*option;
Image
*image;
MagickStatusType
status;
register ssize_t
i;
ssize_t
number_images;
/*
Set defaults.
*/
assert(image_info != (ImageInfo *) NULL);
assert(image_info->signature == MagickSignature);
if (image_info->debug != MagickFalse)
(void) LogMagickEvent(TraceEvent,GetMagickModule(),"...");
assert(exception != (ExceptionInfo *) NULL);
if (argc < 2)
return(ConjureUsage());
image=NewImageList();
number_images=0;
option=(char *) NULL;
/*
Conjure an image.
*/
ReadCommandlLine(argc,&argv);
status=ExpandFilenames(&argc,&argv);
if (status == MagickFalse)
ThrowConjureException(ResourceLimitError,"MemoryAllocationFailed",
GetExceptionMessage(errno));
for (i=1; i < (ssize_t) argc; i++)
{
option=argv[i];
if (IsCommandOption(option) != MagickFalse)
{
if (LocaleCompare("concurrent",option+1) == 0)
break;
if (LocaleCompare("debug",option+1) == 0)
{
ssize_t
event;
if (*option == '+')
break;
i++;
if (i == (ssize_t) argc)
ThrowConjureException(OptionError,"MissingArgument",option);
event=ParseCommandOption(MagickLogEventOptions,MagickFalse,argv[i]);
if (event < 0)
ThrowConjureException(OptionError,"UnrecognizedEventType",
argv[i]);
(void) SetLogEventMask(argv[i]);
continue;
}
if (LocaleCompare("duration",option+1) == 0)
{
if (*option == '+')
break;
i++;
if (i == (ssize_t) (argc-1))
ThrowConjureException(OptionError,"MissingArgument",option);
if (IsGeometry(argv[i]) == MagickFalse)
ThrowConjureInvalidArgumentException(option,argv[i]);
continue;
}
if ((LocaleCompare("help",option+1) == 0) ||
(LocaleCompare("-help",option+1) == 0))
{
//.........这里部分代码省略.........
示例9: LoadTypeList
//.........这里部分代码省略.........
type_info->format=ConstantString(token);
break;
}
if (LocaleCompare((char *) keyword,"foundry") == 0)
{
type_info->foundry=ConstantString(token);
break;
}
if (LocaleCompare((char *) keyword,"fullname") == 0)
{
type_info->description=ConstantString(token);
break;
}
break;
}
case 'G':
case 'g':
{
if (LocaleCompare((char *) keyword,"glyphs") == 0)
{
char
*path;
path=ConstantString(token);
#if defined(MAGICKCORE_WINDOWS_SUPPORT)
if (strchr(path,'@') != (char *) NULL)
SubstituteString(&path,"@[email protected]",font_path);
#endif
if (IsPathAccessible(path) == MagickFalse)
{
/*
Relative path.
*/
path=DestroyString(path);
GetPathComponent(filename,HeadPath,font_path);
(void) ConcatenateMagickString(font_path,DirectorySeparator,
MaxTextExtent);
(void) ConcatenateMagickString(font_path,token,MaxTextExtent);
path=ConstantString(font_path);
}
type_info->glyphs=path;
break;
}
break;
}
case 'M':
case 'm':
{
if (LocaleCompare((char *) keyword,"metrics") == 0)
{
char
*path;
path=ConstantString(token);
#if defined(MAGICKCORE_WINDOWS_SUPPORT)
if (strchr(path,'@') != (char *) NULL)
SubstituteString(&path,"@[email protected]",font_path);
#endif
if (IsPathAccessible(path) == MagickFalse)
{
/*
Relative path.
*/
path=DestroyString(path);
GetPathComponent(filename,HeadPath,font_path);
(void) ConcatenateMagickString(font_path,DirectorySeparator,
示例10: ngx_http_small_light_imagemagick_process
ngx_int_t ngx_http_small_light_imagemagick_process(ngx_http_request_t *r, ngx_http_small_light_ctx_t *ctx)
{
ngx_http_small_light_imagemagick_ctx_t *ictx;
ngx_http_small_light_image_size_t sz;
MagickBooleanType status;
int rmprof_flg, progressive_flg, cmyk2rgb_flg;
double iw, ih, q;
char *unsharp, *sharpen, *blur, *of, *of_orig;
MagickWand *trans_wand, *canvas_wand;
DrawingWand *border_wand;
PixelWand *bg_color, *canvas_color, *border_color;
GeometryInfo geo;
ngx_fd_t fd;
MagickWand *icon_wand;
u_char *p, *embedicon;
size_t embedicon_path_len, embedicon_len, sled_image_size;
ngx_int_t type;
u_char jpeg_size_opt[32], crop_geo[128], size_geo[128], embedicon_path[256];
ColorspaceType color_space;
#if MagickLibVersion >= 0x690
int autoorient_flg;
#endif
status = MagickFalse;
ictx = (ngx_http_small_light_imagemagick_ctx_t *)ctx->ictx;
/* adjust image size */
ngx_http_small_light_calc_image_size(r, ctx, &sz, 10000.0, 10000.0);
/* prepare */
if (sz.jpeghint_flg != 0) {
p = ngx_snprintf((u_char *)jpeg_size_opt, sizeof(jpeg_size_opt) - 1, "%dx%d", (ngx_int_t)sz.dw, (ngx_int_t)sz.dh);
*p = '\0';
ngx_log_error(NGX_LOG_DEBUG, r->connection->log, 0, "jpeg_size_opt:%s", jpeg_size_opt);
MagickSetOption(ictx->wand, "jpeg:size", (char *)jpeg_size_opt);
}
/* load image. */
status = MagickReadImageBlob(ictx->wand, (void *)ictx->image, ictx->image_len);
if (status == MagickFalse) {
ngx_log_error(NGX_LOG_ERR, r->connection->log, 0,
"couldn't read image %s:%d",
__FUNCTION__,
__LINE__);
return NGX_ERROR;
}
MagickSetFirstIterator(ictx->wand);
color_space = MagickGetImageColorspace(ictx->wand);
/* remove all profiles */
rmprof_flg = ngx_http_small_light_parse_flag(NGX_HTTP_SMALL_LIGHT_PARAM_GET_LIT(&ctx->hash, "rmprof"));
if (rmprof_flg != 0) {
status = MagickProfileImage(ictx->wand, "*", NULL, 0);
if (status == MagickFalse) {
ngx_log_error(NGX_LOG_ERR, r->connection->log, 0,
"couldn't profiling image %s:%d",
__FUNCTION__,
__LINE__);
}
}
of_orig = MagickGetImageFormat(ictx->wand);
status = MagickTrue;
#if MagickLibVersion >= 0x690
/* auto-orient */
autoorient_flg = ngx_http_small_light_parse_flag(NGX_HTTP_SMALL_LIGHT_PARAM_GET_LIT(&ctx->hash, "autoorient"));
if (autoorient_flg != 0) {
status = MagickAutoOrientImage(ictx->wand);
if (status == MagickFalse) {
r->err_status = NGX_HTTP_INTERNAL_SERVER_ERROR;
DestroyString(of_orig);
return NGX_ERROR;
}
}
#endif
/* rotate. */
if (sz.angle) {
bg_color = NewPixelWand();
PixelSetRed(bg_color, sz.cc.r / 255.0);
PixelSetGreen(bg_color, sz.cc.g / 255.0);
PixelSetBlue(bg_color, sz.cc.b / 255.0);
PixelSetAlpha(bg_color, sz.cc.a / 255.0);
switch (sz.angle) {
case 90:
case 180:
case 270:
MagickRotateImage(ictx->wand, bg_color, sz.angle);
break;
default:
ngx_log_error(NGX_LOG_ERR, r->connection->log, 0,
"image not rotated. 'angle'(%ui) must be 90 or 180 or 270. %s:%d",
sz.angle,
__FUNCTION__,
__LINE__);
//.........这里部分代码省略.........
示例11: ReadImage
//.........这里部分代码省略.........
flags=ParseGeometry(value,&geometry_info);
if (geometry_info.sigma != 0)
next->x_resolution=geometry_info.rho/geometry_info.sigma;
(void) DeleteImageProperty(next,"exif:XResolution");
}
value=GetImageProperty(next,"exif:YResolution");
if (value != (char *) NULL)
{
geometry_info.rho=next->y_resolution;
geometry_info.sigma=1.0;
flags=ParseGeometry(value,&geometry_info);
if (geometry_info.sigma != 0)
next->y_resolution=geometry_info.rho/geometry_info.sigma;
(void) DeleteImageProperty(next,"exif:YResolution");
}
value=GetImageProperty(next,"tiff:ResolutionUnit");
if (value == (char *) NULL)
value=GetImageProperty(next,"exif:ResolutionUnit");
if (value != (char *) NULL)
{
next->units=(ResolutionType) (StringToLong(value)-1);
(void) DeleteImageProperty(next,"exif:ResolutionUnit");
(void) DeleteImageProperty(next,"tiff:ResolutionUnit");
}
if (next->page.width == 0)
next->page.width=next->columns;
if (next->page.height == 0)
next->page.height=next->rows;
option=GetImageOption(read_info,"caption");
if (option != (const char *) NULL)
{
property=InterpretImageProperties(read_info,next,option);
(void) SetImageProperty(next,"caption",property);
property=DestroyString(property);
}
option=GetImageOption(read_info,"comment");
if (option != (const char *) NULL)
{
property=InterpretImageProperties(read_info,next,option);
(void) SetImageProperty(next,"comment",property);
property=DestroyString(property);
}
option=GetImageOption(read_info,"label");
if (option != (const char *) NULL)
{
property=InterpretImageProperties(read_info,next,option);
(void) SetImageProperty(next,"label",property);
property=DestroyString(property);
}
if (LocaleCompare(next->magick,"TEXT") == 0)
(void) ParseAbsoluteGeometry("0x0+0+0",&next->page);
if ((read_info->extract != (char *) NULL) &&
(read_info->stream == (StreamHandler) NULL))
{
RectangleInfo
geometry;
flags=ParseAbsoluteGeometry(read_info->extract,&geometry);
if ((next->columns != geometry.width) ||
(next->rows != geometry.height))
{
if (((flags & XValue) != 0) || ((flags & YValue) != 0))
{
Image
*crop_image;
示例12: assert
/*
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %
% %
% %
% R e a d V I D I m a g e %
% %
% %
% %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% ReadVIDImage reads one of more images and creates a Visual Image
% Directory file. It allocates the memory necessary for the new Image
% structure and returns a pointer to the new image.
%
% The format of the ReadVIDImage method is:
%
% Image *ReadVIDImage(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 *ReadVIDImage(const ImageInfo *image_info,ExceptionInfo *exception)
{
#define ClientName "montage"
char
**filelist,
*label;
Image
*image,
*images,
*montage_image,
*next_image,
*thumbnail_image;
ImageInfo
*read_info;
int
number_files;
MagickBooleanType
status;
MontageInfo
*montage_info;
RectangleInfo
geometry;
register ssize_t
i;
/*
Expand the filename.
*/
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);
filelist=(char **) AcquireMagickMemory(sizeof(*filelist));
if (filelist == (char **) NULL)
ThrowReaderException(ResourceLimitError,"MemoryAllocationFailed");
filelist[0]=ConstantString(image_info->filename);
number_files=1;
status=ExpandFilenames(&number_files,&filelist);
if ((status == MagickFalse) || (number_files == 0))
ThrowReaderException(ResourceLimitError,"MemoryAllocationFailed");
image=DestroyImage(image);
/*
Read each image and convert them to a tile.
*/
images=NewImageList();
read_info=CloneImageInfo(image_info);
SetImageInfoBlob(read_info,(void *) NULL,0);
(void) SetImageInfoProgressMonitor(read_info,(MagickProgressMonitor) NULL,
(void *) NULL);
if (read_info->size == (char *) NULL)
(void) CloneString(&read_info->size,DefaultTileGeometry);
for (i=0; i < (ssize_t) number_files; i++)
{
if (image_info->debug != MagickFalse)
(void) LogMagickEvent(CoderEvent,GetMagickModule(),"name: %s",
filelist[i]);
(void) CopyMagickString(read_info->filename,filelist[i],MaxTextExtent);
filelist[i]=DestroyString(filelist[i]);
*read_info->magick='\0';
next_image=ReadImage(read_info,exception);
CatchException(exception);
if (next_image == (Image *) NULL)
//.........这里部分代码省略.........
示例13: WriteHISTOGRAMImage
//.........这里部分代码省略.........
scale=(MagickRealType) histogram_image->rows/maximum;
/*
Initialize histogram image.
*/
exception=(&image->exception);
(void) QueryColorDatabase("#000000",&histogram_image->background_color,
&image->exception);
(void) SetImageBackgroundColor(histogram_image);
for (x=0; x < (long) histogram_image->columns; x++)
{
q=GetAuthenticPixels(histogram_image,x,0,1,histogram_image->rows,exception);
if (q == (PixelPacket *) NULL)
break;
if ((channel & RedChannel) != 0)
{
y=(long) ceil(histogram_image->rows-scale*histogram[x].red-0.5);
r=q+y;
for ( ; y < (long) histogram_image->rows; y++)
{
r->red=(Quantum) QuantumRange;
r++;
}
}
if ((channel & GreenChannel) != 0)
{
y=(long) ceil(histogram_image->rows-scale*histogram[x].green-0.5);
r=q+y;
for ( ; y < (long) histogram_image->rows; y++)
{
r->green=(Quantum) QuantumRange;
r++;
}
}
if ((channel & BlueChannel) != 0)
{
y=(long) ceil(histogram_image->rows-scale*histogram[x].blue-0.5);
r=q+y;
for ( ; y < (long) histogram_image->rows; y++)
{
r->blue=(Quantum) QuantumRange;
r++;
}
}
if (SyncAuthenticPixels(histogram_image,exception) == MagickFalse)
break;
status=SetImageProgress(image,SaveImageTag,y,histogram_image->rows);
if (status == MagickFalse)
break;
}
/*
Relinquish resources.
*/
histogram=(MagickPixelPacket *) RelinquishMagickMemory(histogram);
option=GetImageOption(image_info,"histogram:unique-colors");
if ((option == (const char *) NULL) || (IsMagickTrue(option) != MagickFalse))
{
FILE
*file;
int
unique_file;
/*
Add a unique colors as an image comment.
*/
file=(FILE *) NULL;
unique_file=AcquireUniqueFileResource(filename);
if (unique_file != -1)
file=fdopen(unique_file,"wb");
if ((unique_file != -1) && (file != (FILE *) NULL))
{
char
*property;
(void) GetNumberColors(image,file,&image->exception);
(void) fclose(file);
property=FileToString(filename,~0UL,&image->exception);
if (property != (char *) NULL)
{
(void) SetImageProperty(histogram_image,"comment",property);
property=DestroyString(property);
}
}
(void) RelinquishUniqueFileResource(filename);
}
/*
Write Histogram image.
*/
(void) CopyMagickString(histogram_image->filename,image_info->filename,
MaxTextExtent);
write_info=CloneImageInfo(image_info);
(void) SetImageInfo(write_info,1,&image->exception);
if (LocaleCompare(write_info->magick,"HISTOGRAM") == 0)
(void) FormatMagickString(histogram_image->filename,MaxTextExtent,
"miff:%s",write_info->filename);
status=WriteImage(write_info,histogram_image);
histogram_image=DestroyImage(histogram_image);
write_info=DestroyImageInfo(write_info);
return(status);
}
示例14: ReadHDRImage
//.........这里部分代码省略.........
register char
*p;
size_t
length;
/*
Read comment-- any text between # and end-of-line.
*/
length=MaxTextExtent;
comment=AcquireString((char *) NULL);
for (p=comment; comment != (char *) NULL; p++)
{
c=ReadBlobByte(image);
if ((c == EOF) || (c == (int) '\n'))
break;
if ((size_t) (p-comment+1) >= length)
{
*p='\0';
length<<=1;
comment=(char *) ResizeQuantumMemory(comment,length+
MaxTextExtent,sizeof(*comment));
if (comment == (char *) NULL)
break;
p=comment+strlen(comment);
}
*p=(char) c;
}
if (comment == (char *) NULL)
ThrowReaderException(ResourceLimitError,"MemoryAllocationFailed");
*p='\0';
(void) SetImageProperty(image,"comment",comment,exception);
comment=DestroyString(comment);
c=ReadBlobByte(image);
}
else
if (isalnum(c) == MagickFalse)
c=ReadBlobByte(image);
else
{
register char
*p;
/*
Determine a keyword and its value.
*/
p=keyword;
do
{
if ((size_t) (p-keyword) < (MaxTextExtent-1))
*p++=c;
c=ReadBlobByte(image);
} while (isalnum(c) || (c == '_'));
*p='\0';
value_expected=MagickFalse;
while ((isspace((int) ((unsigned char) c)) != 0) || (c == '='))
{
if (c == '=')
value_expected=MagickTrue;
c=ReadBlobByte(image);
}
if (LocaleCompare(keyword,"Y") == 0)
value_expected=MagickTrue;
if (value_expected == MagickFalse)
continue;
示例15: LoadCoderCache
//.........这里部分代码省略.........
Include element.
*/
while (((*token != '/') && (*(token+1) != '>')) && (*q != '\0'))
{
(void) CopyMagickString(keyword,token,MagickPathExtent);
GetMagickToken(q,&q,token);
if (*token != '=')
continue;
GetMagickToken(q,&q,token);
if (LocaleCompare(keyword,"file") == 0)
{
if (depth > 200)
(void) ThrowMagickException(exception,GetMagickModule(),
ConfigureError,"IncludeNodeNestedTooDeeply","`%s'",token);
else
{
char
path[MagickPathExtent],
*file_xml;
GetPathComponent(filename,HeadPath,path);
if (*path != '\0')
(void) ConcatenateMagickString(path,DirectorySeparator,
MagickPathExtent);
if (*token == *DirectorySeparator)
(void) CopyMagickString(path,token,MagickPathExtent);
else
(void) ConcatenateMagickString(path,token,MagickPathExtent);
file_xml=FileToXML(path,~0UL);
if (file_xml != (char *) NULL)
{
status&=LoadCoderCache(coder_cache,file_xml,path,depth+1,
exception);
file_xml=DestroyString(file_xml);
}
}
}
}
continue;
}
if (LocaleCompare(keyword,"<coder") == 0)
{
/*
Coder element.
*/
coder_info=(CoderInfo *) AcquireMagickMemory(sizeof(*coder_info));
if (coder_info == (CoderInfo *) NULL)
ThrowFatalException(ResourceLimitFatalError,"MemoryAllocationFailed");
(void) ResetMagickMemory(coder_info,0,sizeof(*coder_info));
coder_info->path=ConstantString(filename);
coder_info->exempt=MagickFalse;
coder_info->signature=MagickCoreSignature;
continue;
}
if (coder_info == (CoderInfo *) NULL)
continue;
if (LocaleCompare(keyword,"/>") == 0)
{
status=AddValueToSplayTree(coder_cache,ConstantString(
coder_info->magick),coder_info);
if (status == MagickFalse)
(void) ThrowMagickException(exception,GetMagickModule(),
ResourceLimitError,"MemoryAllocationFailed","`%s'",
coder_info->magick);
coder_info=(CoderInfo *) NULL;
continue;