本文整理匯總了C++中DestroyExceptionInfo函數的典型用法代碼示例。如果您正苦於以下問題:C++ DestroyExceptionInfo函數的具體用法?C++ DestroyExceptionInfo怎麽用?C++ DestroyExceptionInfo使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了DestroyExceptionInfo函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C++代碼示例。
示例1: ImageList_append
/*
Method: ImageList#append(stack)
Purpose: Append all the images by calling ImageAppend
Returns: an Frame object for the result
*/
VALUE
ImageList_append(VALUE self, VALUE stack_arg)
{
Image *images, *new_image;
unsigned int stack;
ExceptionInfo exception;
// Convert the image array to an image sequence.
images = images_from_imagelist(self);
// If stack == true, stack rectangular images top-to-bottom,
// otherwise left-to-right.
stack = RTEST(stack_arg);
GetExceptionInfo(&exception);
new_image = AppendImages(images, stack, &exception);
rm_split(images);
rm_check_exception(&exception, new_image, DestroyOnError);
(void) DestroyExceptionInfo(&exception);
rm_ensure_result(new_image);
return rm_image_new(new_image);
}
示例2: MagickQueryConfigureOption
/*
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %
% %
% %
% M a g i c k Q u e r y C o n f i g u r e O p t i o n %
% %
% %
% %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% MagickQueryConfigureOption() returns the value associated with the specified
% configure option.
%
% The format of the MagickQueryConfigureOption function is:
%
% char *MagickQueryConfigureOption(const char *option)
%
% A description of each parameter follows:
%
% o option: The option name.
%
*/
WandExport char *MagickQueryConfigureOption(const char *option)
{
char
*value;
const ConfigureInfo
**configure_info;
ExceptionInfo
exception;
unsigned long
number_options;
GetExceptionInfo(&exception);
configure_info=GetConfigureInfoList(option,&number_options,&exception);
DestroyExceptionInfo(&exception);
if (configure_info == (const ConfigureInfo **) NULL)
return((char *) NULL);
value=AcquireString(configure_info[0]->value);
configure_info=(const ConfigureInfo **)
RelinquishMagickMemory((void *) configure_info);
return(value);
}
示例3: convert_image
ngx_int_t
convert_image(ngx_http_request_t *r, convert_options_t *option_info,
Image **image)
{
ngx_uint_t i;
ngx_http_gm_convert_option_t *options;
ngx_http_gm_convert_option_t *option;
RectangleInfo geometry;
RectangleInfo geometry_info;
ExceptionInfo exception;
Image *resize_image = NULL;
u_char *resize_geometry = NULL;
u_char *need_crop_resize = NULL;
Image *rotate_image = NULL;
u_char *rotate_degrees = NULL;
ngx_int_t degrees;
ngx_int_t degrees_suffix_len = 0;
dd("entering");
options = option_info->options->elts;
for (i = 0; i < option_info->options->nelts; ++i) {
option = &options[i];
if (option->type == NGX_HTTP_GM_RESIZE_OPTION) {
dd("starting resize");
resize_geometry = ngx_http_gm_get_str_value(r,
option->resize_geometry_cv, &option->resize_geometry);
need_crop_resize = (u_char *)ngx_strchr(resize_geometry, 'c');
if (need_crop_resize != NULL) {
*need_crop_resize = '^';
}
if (resize_geometry == NULL) {
ngx_log_error(NGX_LOG_ERR, r->connection->log, 0,
"gm filter: resize image, get resize geometry failed");
return NGX_ERROR;
}
if (ngx_strncmp(resize_geometry, "no", 2) == 0) {
continue;
}
(void) GetImageGeometry(*image, (char *)resize_geometry, 1,
&geometry);
if ((geometry.width == (*image)->columns) &&
(geometry.height == (*image)->rows))
continue;
ngx_log_debug1(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,
"resize image geometry: \"%s\"", resize_geometry);
GetExceptionInfo(&exception);
resize_image = ResizeImage(*image, geometry.width, geometry.height,
(*image)->filter,(*image)->blur, &exception);
if (resize_image == (Image *) NULL) {
ngx_log_error(NGX_LOG_ERR, r->connection->log, 0,
"gm filter: resize image failed, "
"arg: \"%s\" severity: \"%O\" "
"reason: \"%s\", description: \"%s\"",
resize_geometry, exception.severity,
exception.reason, exception.description);
DestroyExceptionInfo(&exception);
return NGX_ERROR;
}
DestroyImage(*image);
*image = resize_image;
DestroyExceptionInfo(&exception);
if (need_crop_resize != NULL) {
GetGeometry((char *)resize_geometry,
&geometry_info.x, &geometry_info.y,
(unsigned long *)(&geometry_info.width),
(unsigned long *)(&geometry_info.height));
if (geometry_info.width > (*image)->columns ||
geometry_info.height > (*image)->rows) {
continue;
}
geometry_info.x = ((*image)->columns - geometry_info.width) / 2;
geometry_info.y = ((*image)->rows - geometry_info.height) / 2;
GetExceptionInfo(&exception);
resize_image = CropImage(*image, &geometry_info, &exception);
//.........這裏部分代碼省略.........
示例4: magick_loader
CAMLprim value
magick_loader(value input)
{
CAMLparam1(input);
CAMLlocal2(pixel_matrix, res);
Image *image_bloc;
int image_type_code;
int components;
GLenum format;
ExceptionInfo exception;
GetExceptionInfo(&exception);
{
if (IsMagickInstantiated() == MagickFalse) {
InitializeMagick(getenv("PWD"));
}
{
ImageInfo *image_info;
image_info = CloneImageInfo((ImageInfo *) NULL);
switch (Tag_val(input))
{
/* given a filename of an image */
case 0:
(void) strcpy(image_info->filename, String_val(Field(input,0)));
image_bloc = ReadImage(image_info, &exception);
break;
/* given the image data in a buffer */
case 1:
image_bloc = BlobToImage(
image_info,
(void *)String_val(Field(input,0)),
caml_string_length(Field(input,0)),
&exception);
break;
}
DestroyImageInfo(image_info);
}
if (exception.severity != UndefinedException) {
if (image_bloc != (Image *) NULL) {
DestroyImage(image_bloc);
}
DestroyExceptionInfo(&exception);
caml_failwith( exception.reason );
/* @TODO exception.description */
}
if (image_bloc == (Image *) NULL) {
DestroyExceptionInfo(&exception);
caml_failwith("read image failed");
}
}
{
ImageType image_type;
image_type = GetImageType( image_bloc, &exception );
if (exception.severity != UndefinedException)
caml_failwith( exception.reason );
image_type_code = Val_ImageType(image_type, &components);
if ( image_type_code == 11 )
caml_failwith("getting image type failed");
}
{
unsigned long x, y;
unsigned long columns, rows;
PixelPacket pixel;
columns = image_bloc->columns;
rows = image_bloc->rows;
const PixelPacket * pixel_packet_array;
pixel_packet_array =
AcquireImagePixels(
image_bloc,
0, 0, columns, rows,
&exception );
if (exception.severity != UndefinedException) {
caml_failwith(exception.reason);
}
{
unsigned char *image;
long ndx;
long dims[3];
dims[0] = columns;
dims[1] = rows;
dims[2] = components;
pixel_matrix = alloc_bigarray(BIGARRAY_UINT8 | BIGARRAY_C_LAYOUT, 3, NULL, dims);
image = Data_bigarray_val(pixel_matrix);
for (x=0; x < columns; ++x) {
for (y=0; y < rows; ++y) {
pixel = pixel_packet_array[(columns * y) + x];
ndx = (columns * y * components) + (x * components);
//.........這裏部分代碼省略.........
示例5: main
//.........這裏部分代碼省略.........
comment=GetXMLTreeChild(type,"comment");
if (comment != (XMLTreeInfo *) NULL)
description=GetXMLTreeContent(comment);
if (expanded_acronym != (XMLTreeInfo *) NULL)
description=GetXMLTreeContent(expanded_acronym);
magic=GetXMLTreeChild(type,"magic");
priority=(char *) NULL;
match=(XMLTreeInfo *) NULL;
if (magic != (XMLTreeInfo *) NULL)
{
priority=GetXMLTreeAttribute(magic,"priority");
match=GetXMLTreeChild(magic,"match");
}
while (match != (XMLTreeInfo *) NULL)
{
value=(char *) NULL;
match_type=(char *) NULL;
mask=(char *) NULL;
offset=(char *) NULL;
if (match != (XMLTreeInfo *) NULL)
{
value=GetXMLTreeAttribute(match,"value");
match_type=GetXMLTreeAttribute(match,"type");
offset=GetXMLTreeAttribute(match,"offset");
mask=GetXMLTreeAttribute(match,"mask");
}
(void) printf(" <mime");
if (mime_type != (const char *) NULL)
(void) printf(" type=\"%s\"",mime_type);
if (description != (const char *) NULL)
(void) printf(" description=\"%s\"",description);
if (match_type != (const char *) NULL)
{
data_type="string";
endian="undefined";
if (strncmp(match_type,"little",6) == 0)
endian="LSB";
if (strncmp(match_type,"big",3) == 0)
endian="MSB";
if (strcmp(match_type,"byte") == 0)
data_type="byte";
if (strcmp(match_type+strlen(match_type)-2,"16") == 0)
data_type="short";
if (strcmp(match_type+strlen(match_type)-2,"32") == 0)
data_type="ssize_t";
(void) printf(" data-type=\"%s\"",data_type);
if (strcmp(endian,"undefined") != 0)
(void) printf(" endian=\"%s\"",endian);
}
if (offset != (const char *) NULL)
(void) printf(" offset=\"%s\"",offset);
if (mask != (const char *) NULL)
(void) printf(" mask=\"%s\"",mask);
if (value != (const char *) NULL)
{
char
*magic;
magic=AcquireString(value);
SubstituteString(&magic,"<","<");
SubstituteString(&magic,">",">");
SubstituteString(&magic,"\"",""");
(void) printf(" magic=\"%s\"",magic);
magic=(char *) RelinquishWizardMemory(magic);
}
if (priority != (const char *) NULL)
(void) printf(" priority=\"%s\"",priority);
(void) printf(" />\n");
match=GetNextXMLTreeTag(match);
}
glob=GetXMLTreeChild(type,"glob");
while (glob != (XMLTreeInfo *) NULL)
{
pattern=GetXMLTreeAttribute(glob,"pattern");
value=(char *) NULL;
if (match)
value=GetXMLTreeAttribute(match,"value");
(void) printf(" <mime");
if (mime_type != (const char *) NULL)
(void) printf(" type=\"%s\"",mime_type);
if (acronym != (const char *) NULL)
(void) printf(" acronym=\"%s\"",acronym);
if (description != (const char *) NULL)
(void) printf(" description=\"%s\"",description);
(void) printf(" priority=\"100\"");
if (pattern != (const char *) NULL)
(void) printf(" pattern=\"%s\"",pattern);
(void) printf(" />\n");
glob=GetNextXMLTreeTag(glob);
}
type=GetNextXMLTreeTag(type);
}
(void) printf("</mimemap>\n");
xml=XMLTreeInfoToXML(xml_info);
(void) fprintf(stderr,"%s\n",xml);
xml=(char *) RelinquishWizardMemory(xml);
DestroyXMLTree(xml_info);
exception=DestroyExceptionInfo(exception);
return(0);
}
示例6: WriteImage
/*
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %
% %
% %
% W r i t e I m a g e %
% %
% %
% %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% WriteImage() writes an image or an image sequence to a file or file handle.
% If writing to a file is on disk, the name is defined by the filename member
% of the image structure. WriteImage() returns MagickFalse is there is a
% memory shortage or if the image cannot be written. Check the exception
% member of image to determine the cause for any failure.
%
% The format of the WriteImage method is:
%
% MagickBooleanType WriteImage(const ImageInfo *image_info,Image *image,
% ExceptionInfo *exception)
%
% A description of each parameter follows:
%
% o image_info: the image info.
%
% o image: the image.
%
% o exception: return any errors or warnings in this structure.
%
*/
MagickExport MagickBooleanType WriteImage(const ImageInfo *image_info,
Image *image,ExceptionInfo *exception)
{
char
filename[MaxTextExtent];
const char
*option;
const DelegateInfo
*delegate_info;
const MagickInfo
*magick_info;
ExceptionInfo
*sans_exception;
ImageInfo
*write_info;
MagickBooleanType
status,
temporary;
MagickStatusType
thread_support;
PolicyDomain
domain;
PolicyRights
rights;
/*
Determine image type from filename prefix or suffix (e.g. image.jpg).
*/
assert(image_info != (ImageInfo *) NULL);
assert(image_info->signature == MagickSignature);
if (image->debug != MagickFalse)
(void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",
image_info->filename);
assert(image != (Image *) NULL);
assert(image->signature == MagickSignature);
assert(exception != (ExceptionInfo *) NULL);
sans_exception=AcquireExceptionInfo();
write_info=CloneImageInfo(image_info);
(void) CopyMagickString(write_info->filename,image->filename,MaxTextExtent);
if (*write_info->magick == '\0')
(void) CopyMagickString(write_info->magick,image->magick,MaxTextExtent);
(void) SetImageInfo(write_info,1,sans_exception);
if (LocaleCompare(write_info->magick,"clipmask") == 0)
{
if (image->clip_mask == (Image *) NULL)
{
(void) ThrowMagickException(exception,GetMagickModule(),
OptionError,"NoClipPathDefined","`%s'",image->filename);
return(MagickFalse);
}
image=image->clip_mask;
(void) SetImageInfo(write_info,1,sans_exception);
}
(void) CopyMagickString(filename,image->filename,MaxTextExtent);
(void) CopyMagickString(image->filename,write_info->filename,MaxTextExtent);
domain=CoderPolicyDomain;
rights=WritePolicyRights;
if (IsRightsAuthorized(domain,rights,write_info->magick) == MagickFalse)
{
sans_exception=DestroyExceptionInfo(sans_exception);
//.........這裏部分代碼省略.........
示例7: ReadImage
/*
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %
% %
% %
% R e a d I m a g e %
% %
% %
% %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% ReadImage() reads an image or image sequence from a file or file handle.
% The method returns a NULL if there is a memory shortage or if the image
% cannot be read. On failure, a NULL image is returned and exception
% describes the reason for the failure.
%
% The format of the ReadImage method is:
%
% Image *ReadImage(const ImageInfo *image_info,ExceptionInfo *exception)
%
% A description of each parameter follows:
%
% o image_info: Read the image defined by the file or filename members of
% this structure.
%
% o exception: return any errors or warnings in this structure.
%
*/
MagickExport Image *ReadImage(const ImageInfo *image_info,
ExceptionInfo *exception)
{
char
filename[MaxTextExtent],
magick[MaxTextExtent],
magick_filename[MaxTextExtent];
const char
*value;
const DelegateInfo
*delegate_info;
const MagickInfo
*magick_info;
ExceptionInfo
*sans_exception;
GeometryInfo
geometry_info;
Image
*image,
*next;
ImageInfo
*read_info;
MagickStatusType
flags,
thread_support;
PolicyDomain
domain;
PolicyRights
rights;
/*
Determine image type from filename prefix or suffix (e.g. image.jpg).
*/
assert(image_info != (ImageInfo *) NULL);
assert(image_info->signature == MagickSignature);
assert(image_info->filename != (char *) NULL);
if (image_info->debug != MagickFalse)
(void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",
image_info->filename);
assert(exception != (ExceptionInfo *) NULL);
read_info=CloneImageInfo(image_info);
(void) CopyMagickString(magick_filename,read_info->filename,MaxTextExtent);
(void) SetImageInfo(read_info,0,exception);
(void) CopyMagickString(filename,read_info->filename,MaxTextExtent);
(void) CopyMagickString(magick,read_info->magick,MaxTextExtent);
domain=CoderPolicyDomain;
rights=ReadPolicyRights;
if (IsRightsAuthorized(domain,rights,read_info->magick) == MagickFalse)
{
errno=EPERM;
(void) ThrowMagickException(exception,GetMagickModule(),PolicyError,
"NotAuthorized","`%s'",read_info->filename);
return((Image *) NULL);
}
/*
Call appropriate image reader based on image type.
*/
sans_exception=AcquireExceptionInfo();
magick_info=GetMagickInfo(read_info->magick,sans_exception);
sans_exception=DestroyExceptionInfo(sans_exception);
if (magick_info != (const MagickInfo *) NULL)
{
//.........這裏部分代碼省略.........
示例8: GlobExpression
/*
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %
% %
% %
% G l o b E x p r e s s i o n %
% %
% %
% %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% GlobExpression() returns MagickTrue if the expression matches the pattern.
%
% The format of the GlobExpression function is:
%
% MagickBooleanType GlobExpression(const char *expression,
% const char *pattern,const MagickBooleanType case_insensitive)
%
% A description of each parameter follows:
%
% o expression: Specifies a pointer to a text string containing a file name.
%
% o pattern: Specifies a pointer to a text string containing a pattern.
%
% o case_insensitive: set to MagickTrue to ignore the case when matching
% an expression.
%
*/
MagickExport MagickBooleanType GlobExpression(const char *expression,
const char *pattern,const MagickBooleanType case_insensitive)
{
MagickBooleanType
done,
match;
register const char
*p;
/*
Return on empty pattern or '*'.
*/
if (pattern == (char *) NULL)
return(MagickTrue);
if (GetUTFCode(pattern) == 0)
return(MagickTrue);
if (LocaleCompare(pattern,"*") == 0)
return(MagickTrue);
p=pattern+strlen(pattern)-1;
if ((GetUTFCode(p) == ']') && (strchr(pattern,'[') != (char *) NULL))
{
ExceptionInfo
*exception;
ImageInfo
*image_info;
/*
Determine if pattern is a scene, i.e. img0001.pcd[2].
*/
image_info=AcquireImageInfo();
(void) CopyMagickString(image_info->filename,pattern,MaxTextExtent);
exception=AcquireExceptionInfo();
(void) SetImageInfo(image_info,MagickTrue,exception);
exception=DestroyExceptionInfo(exception);
if (LocaleCompare(image_info->filename,pattern) != 0)
{
image_info=DestroyImageInfo(image_info);
return(MagickFalse);
}
image_info=DestroyImageInfo(image_info);
}
/*
Evaluate glob expression.
*/
done=MagickFalse;
while ((GetUTFCode(pattern) != 0) && (done == MagickFalse))
{
if (GetUTFCode(expression) == 0)
if ((GetUTFCode(pattern) != '{') && (GetUTFCode(pattern) != '*'))
break;
switch (GetUTFCode(pattern))
{
case '\\':
{
pattern+=GetUTFOctets(pattern);
if (GetUTFCode(pattern) != 0)
pattern+=GetUTFOctets(pattern);
break;
}
case '*':
{
MagickBooleanType
status;
status=MagickFalse;
pattern+=GetUTFOctets(pattern);
while ((GetUTFCode(expression) != 0) && (status == MagickFalse))
{
status=GlobExpression(expression,pattern,case_insensitive);
expression+=GetUTFOctets(expression);
//.........這裏部分代碼省略.........
示例9: ImageList_quantize
/**
* Call QuantizeImages.
*
* Ruby usage:
* - @verbatim ImageList#quantize @endverbatim
* - @verbatim ImageList#quantize(number_colors) @endverbatim
* - @verbatim ImageList#quantize(number_colors, colorspace) @endverbatim
* - @verbatim ImageList#quantize(number_colors, colorspace, dither) @endverbatim
* - @verbatim ImageList#quantize(number_colors, colorspace, dither, tree_depth) @endverbatim
* - @verbatim ImageList#quantize(number_colors, colorspace, dither, tree_depth, measure_error) @endverbatim
*
* Notes:
* - Default number_colors is 256
* - Default coorspace is Magick::RGBColorsapce
* - Default dither is true
* - Default tree_depth is 0
* - Default measure_error is false
* - Sets \@scene to the same value as self.scene
*
* @param argc number of input arguments
* @param argv array of input arguments
* @param self this object
* @return a new ImageList with quantized images
*/
VALUE
ImageList_quantize(int argc, VALUE *argv, VALUE self)
{
Image *images, *new_images;
Image *new_image;
QuantizeInfo quantize_info;
ExceptionInfo *exception;
VALUE new_imagelist, scene;
GetQuantizeInfo(&quantize_info);
switch (argc)
{
case 5:
quantize_info.measure_error = (MagickBooleanType) RTEST(argv[4]);
case 4:
quantize_info.tree_depth = (unsigned long)NUM2INT(argv[3]);
case 3:
#if defined(HAVE_TYPE_DITHERMETHOD) && defined(HAVE_ENUM_NODITHERMETHOD)
if (rb_obj_is_kind_of(argv[2], Class_DitherMethod))
{
VALUE_TO_ENUM(argv[2], quantize_info.dither_method, DitherMethod);
quantize_info.dither = quantize_info.dither_method != NoDitherMethod;
}
#else
quantize_info.dither = (MagickBooleanType) RTEST(argv[2]);
#endif
case 2:
VALUE_TO_ENUM(argv[1], quantize_info.colorspace, ColorspaceType);
case 1:
quantize_info.number_colors = NUM2ULONG(argv[0]);
case 0:
break;
default:
rb_raise(rb_eArgError, "wrong number of arguments (%d for 0 to 5)", argc);
break;
}
// Convert image array to image sequence, clone image sequence.
exception = AcquireExceptionInfo();
images = images_from_imagelist(self);
new_images = CloneImageList(images, exception);
rm_split(images);
rm_check_exception(exception, new_images, DestroyOnError);
rm_ensure_result(new_images);
(void) QuantizeImages(&quantize_info, new_images);
rm_check_exception(exception, new_images, DestroyOnError);
(void) DestroyExceptionInfo(exception);
// Create new ImageList object, convert mapped image sequence to images,
// append to images array.
new_imagelist = ImageList_new();
while ((new_image = RemoveFirstImageFromList(&new_images)))
{
imagelist_push(new_imagelist, rm_image_new(new_image));
}
// Set @scene in new ImageList object to same value as in self.
scene = rb_iv_get(self, "@scene");
(void) rb_iv_set(new_imagelist, "@scene", scene);
RB_GC_GUARD(new_imagelist);
RB_GC_GUARD(scene);
return new_imagelist;
}
示例10: main
/*
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %
% %
% %
% M a i n %
% %
% %
% %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
%
*/
int main(int argc,char **argv)
{
char
*option;
double
elapsed_time,
user_time;
ExceptionInfo
*exception;
ImageInfo
*image_info;
MagickBooleanType
regard_warnings,
status;
register long
i;
TimerInfo
timer;
unsigned long
iterations;
MagickCoreGenesis(*argv,MagickTrue);
exception=AcquireExceptionInfo();
iterations=1;
status=MagickFalse;
regard_warnings=MagickFalse;
for (i=1; i < (long) (argc-1); i++)
{
option=argv[i];
if ((strlen(option) == 1) || ((*option != '-') && (*option != '+')))
continue;
if (LocaleCompare("bench",option+1) == 0)
iterations=(unsigned long) atol(argv[++i]);
if (LocaleCompare("debug",option+1) == 0)
(void) SetLogEventMask(argv[++i]);
if (LocaleCompare("regard-warnings",option+1) == 0)
regard_warnings=MagickTrue;
}
GetTimerInfo(&timer);
for (i=0; i < (long) iterations; i++)
{
image_info=AcquireImageInfo();
status=ConvertImageCommand(image_info,argc,argv,(char **) NULL,exception);
if (exception->severity != UndefinedException)
{
if ((exception->severity > ErrorException) ||
(regard_warnings != MagickFalse))
status=MagickTrue;
CatchException(exception);
}
image_info=DestroyImageInfo(image_info);
}
if (iterations > 1)
{
elapsed_time=GetElapsedTime(&timer);
user_time=GetUserTime(&timer);
(void) fprintf(stderr,"Performance: %lui %gips %0.3fu %ld:%02ld\n",
iterations,1.0*iterations/elapsed_time,user_time,(long)
(elapsed_time/60.0+0.5),(long) ceil(fmod(elapsed_time,60.0)));
}
exception=DestroyExceptionInfo(exception);
MagickCoreTerminus();
return(status == MagickFalse ? 0 : 1);
}
示例11: lib_readImages
// GP: mode = -1 will be automatically guessed from the file
SEXP
lib_readImages (SEXP files, SEXP mode) {
SEXP res;
int _mode, i, nappends;
Image * image, * images;
ImageInfo * image_info;
ExceptionInfo exception;
const char * file;
ImageType it;
if ( LENGTH(files) < 1 )
error ( "please supply at least one file name or URL" );
_mode = INTEGER (mode)[0];
if ( _mode < -1 || _mode > MODE_MAX)
error ( "requested mode is not supported" );
// Special call for reading Cellomics image
if (LENGTH(files)==1) {
file = CHAR(STRING_ELT(files, 0));
i = strlen(file);
if (i>4 && (strncmp(&file[i-4], ".c01", 4)==0 || strncmp(&file[i-4], ".C01", 4)==0)) {
return (readCellomics(file));
}
}
image_info = (ImageInfo *) NULL;
/* images loaded into image and moved into this list */
images = NewImageList ();
GetExceptionInfo (&exception);
image_info = CloneImageInfo ( (ImageInfo *)NULL );
nappends = 0;
for ( i = 0; i < LENGTH (files); i++ ) {
if ( LENGTH (files) > 1 )
file = CHAR ( STRING_ELT(files, i) );
else
file = CHAR ( asChar(files) );
strcpy (image_info->filename, file);
// Prevent an ImageMagick bug when file is an empty string or NULL
if (file==NULL) image=NULL;
else if (strlen(file)==0) image=NULL;
else {
image = ReadImage (image_info, &exception);
CatchException (&exception);
}
if ( image == (Image *)NULL ) {
warning ("requested image not found or could not be loaded" );
continue;
}
// Automatic color mode guess
if (_mode==-1) {
it = GetImageType(image,&exception);
// Rprintf("it=%d G=%d P=%d PM=%d\n",it, GrayscaleType, PaletteType, PaletteMatteType);
if (it==BilevelType || it==GrayscaleType || it==GrayscaleMatteType) _mode=MODE_GRAYSCALE;
else _mode=MODE_COLOR;
}
/* do not destroy image here */
AppendImageToList (&images, image);
if ( nappends == 0 ) {
/* set all attributes from the first image */
strcpy (images->filename, image->filename);
images->compression = image->compression;
images->x_resolution = image->x_resolution;
images->y_resolution = image->y_resolution;
}
nappends++;
}
/* do not update image properties here because if no image was added to
the list it will cause segfault, or use GetImageListLength first to check size */
image_info = DestroyImageInfo (image_info);
/* convert image list into R object */
res = PROTECT(magick2SEXP (images, _mode));
images = DestroyImageList (images);
DestroyExceptionInfo(&exception);
UNPROTECT(1);
return res;
}
示例12: draw_tiger_map
//.........這裏部分代碼省略.........
image_info=CloneImageInfo((ImageInfo *) NULL);
xastir_snprintf(image_info->filename,
sizeof(image_info->filename),
"%s",
file);
if (debug_level & 512) {
fprintf(stderr,"Copied %s into image info.\n", file);
fprintf(stderr,"image_info got: %s\n", image_info->filename);
fprintf(stderr,"Entered ImageMagick code.\n");
fprintf(stderr,"Attempting to open: %s\n", image_info->filename);
}
// We do a test read first to see if the file exists, so we
// don't kill Xastir in the ReadImage routine.
f = fopen (image_info->filename, "r");
if (f == NULL) {
if (debug_level & 512)
fprintf(stderr,"File could not be read\n");
#ifdef USE_MAP_CACHE
// clear from cache if bad
if (map_cache_del(fileimg)) {
if (debug_level & 512) {
fprintf(stderr,"Couldn't delete unreadable map from cache\n");
}
}
#endif
if (image_info)
DestroyImageInfo(image_info);
DestroyExceptionInfo(&exception);
return;
}
(void)fclose (f);
image = ReadImage(image_info, &exception);
if (image == (Image *) NULL) {
MagickWarning(exception.severity, exception.reason, exception.description);
//fprintf(stderr,"MagickWarning\n");
#ifdef USE_MAP_CACHE
// clear from cache if bad
if (map_cache_del(fileimg)) {
if (debug_level & 512) {
fprintf(stderr,"Couldn't delete map from cache\n");
}
}
#endif
if (image_info)
DestroyImageInfo(image_info);
DestroyExceptionInfo(&exception);
return;
}
if (debug_level & 512)
fprintf(stderr,"Color depth is %i \n", (int)image->depth);
if (image->colorspace != RGBColorspace) {
fprintf(stderr,"TBD: I don't think we can deal with colorspace != RGB");
示例13: IdentifyImage
//.........這裏部分代碼省略.........
if (image->total_colors != 0)
{
(void) FormatMagickSize(image->total_colors,MagickFalse,format);
(void) fprintf(file,"%s ",format);
}
}
else if (image->total_colors <= image->colors)
(void) fprintf(file,"PseudoClass %.20gc ",(double) image->colors);
else
(void) fprintf(file,"PseudoClass %.20g=>%.20gc ",(double)
image->total_colors,(double) image->colors);
if (image->error.mean_error_per_pixel != 0.0)
(void) fprintf(file,"%.20g/%f/%fdb ",(double)
(image->error.mean_error_per_pixel+0.5),
image->error.normalized_mean_error,
image->error.normalized_maximum_error);
if (GetBlobSize(image) != 0)
{
(void) FormatMagickSize(GetBlobSize(image),MagickFalse,format);
(void) fprintf(file,"%sB ",format);
}
(void) fprintf(file,"%0.3fu %lu:%02lu.%03lu",user_time,(unsigned long)
(elapsed_time/60.0),(unsigned long) floor(fmod(elapsed_time,60.0)),
(unsigned long) (1000.0*(elapsed_time-floor(elapsed_time))));
(void) fprintf(file,"\n");
(void) fflush(file);
return(ferror(file) != 0 ? MagickFalse : MagickTrue);
}
/*
Display verbose info about the image.
*/
exception=AcquireExceptionInfo();
pixels=GetVirtualPixels(image,0,0,1,1,exception);
exception=DestroyExceptionInfo(exception);
ping=pixels == (const PixelPacket *) NULL ? MagickTrue : MagickFalse;
type=GetImageType(image,&image->exception);
(void) SignatureImage(image);
(void) fprintf(file,"Image: %s\n",image->filename);
if (*image->magick_filename != '\0')
if (LocaleCompare(image->magick_filename,image->filename) != 0)
{
char
filename[MaxTextExtent];
GetPathComponent(image->magick_filename,TailPath,filename);
(void) fprintf(file," Base filename: %s\n",filename);
}
magick_info=GetMagickInfo(image->magick,&image->exception);
if ((magick_info == (const MagickInfo *) NULL) ||
(*GetMagickDescription(magick_info) == '\0'))
(void) fprintf(file," Format: %s\n",image->magick);
else
(void) fprintf(file," Format: %s (%s)\n",image->magick,
GetMagickDescription(magick_info));
(void) fprintf(file," Class: %s\n",MagickOptionToMnemonic(MagickClassOptions,
(ssize_t) image->storage_class));
(void) fprintf(file," Geometry: %.20gx%.20g%+.20g%+.20g\n",(double)
image->columns,(double) image->rows,(double) image->tile_offset.x,(double)
image->tile_offset.y);
if ((image->magick_columns != 0) || (image->magick_rows != 0))
if ((image->magick_columns != image->columns) ||
(image->magick_rows != image->rows))
(void) fprintf(file," Base geometry: %.20gx%.20g\n",(double)
image->magick_columns,(double) image->magick_rows);
if ((image->x_resolution != 0.0) && (image->y_resolution != 0.0))
{
示例14: SetImageInfoBlob
//.........這裏部分代碼省略.........
(void) ConcatenateMagickString(filename,image_info->filename,MaxTextExtent);
if (LocaleCompare(read_info->magick,"file") == 0)
{
(void) RelinquishUniqueFileResource(read_info->filename);
unique_file=(-1);
(void) CopyMagickString(read_info->filename,image_info->filename+2,
MaxTextExtent);
}
#if defined(MAGICKCORE_WINDOWS_SUPPORT) && \
!(defined(__MINGW32__) || defined(__MINGW64__))
(void) fclose(file);
if (URLDownloadToFile(NULL,filename,read_info->filename,0,NULL) != S_OK)
{
ThrowFileException(exception,FileOpenError,"UnableToOpenFile",
filename);
(void) RelinquishUniqueFileResource(read_info->filename);
read_info=DestroyImageInfo(read_info);
return((Image *) NULL);
}
#else
#if defined(MAGICKCORE_XML_DELEGATE) && defined(LIBXML_FTP_ENABLED)
if (LocaleCompare(read_info->magick,"ftp") == 0)
{
void
*context;
xmlNanoFTPInit();
context=xmlNanoFTPNewCtxt(filename);
if (context != (void *) NULL)
{
if (xmlNanoFTPConnect(context) >= 0)
(void) xmlNanoFTPGet(context,GetFTPData,(void *) file,
(char *) NULL);
(void) xmlNanoFTPClose(context);
}
}
#endif
#if defined(MAGICKCORE_XML_DELEGATE) && defined(LIBXML_HTTP_ENABLED)
if (LocaleCompare(read_info->magick,"http") == 0)
{
char
buffer[MaxBufferExtent],
*type;
int
bytes;
void
*context;
type=(char *) NULL;
context=xmlNanoHTTPMethod(filename,(const char *) NULL,
(const char *) NULL,&type,(const char *) NULL,0);
if (context != (void *) NULL)
{
ssize_t
count;
while ((bytes=xmlNanoHTTPRead(context,buffer,MaxBufferExtent)) > 0)
count=(ssize_t) fwrite(buffer,bytes,1,file);
(void) count;
xmlNanoHTTPClose(context);
xmlFree(type);
xmlNanoHTTPCleanup();
}
}
#endif
(void) fclose(file);
#endif
{
ExceptionInfo
*sans;
ImageInfo
*clone_info;
/*
Guess image format from URL.
*/
clone_info=CloneImageInfo(image_info);
sans=AcquireExceptionInfo();
(void) SetImageInfo(clone_info,0,sans);
(void) CopyMagickString(read_info->magick,clone_info->magick,MaxTextExtent);
clone_info=DestroyImageInfo(clone_info);
sans=DestroyExceptionInfo(sans);
}
image=ReadImage(read_info,exception);
if (unique_file != -1)
(void) RelinquishUniqueFileResource(read_info->filename);
read_info=DestroyImageInfo(read_info);
if (image != (Image *) NULL)
GetPathComponent(image_info->filename,TailPath,image->filename);
else
{
(void) ThrowMagickException(exception,GetMagickModule(),CoderError,
"NoDataReturned","`%s'",filename);
return((Image *) NULL);
}
return(GetFirstImageInList(image));
}
示例15: search_quality
//.........這裏部分代碼省略.........
size_t width = MagickGetImageWidth(mw);
size_t height = MagickGetImageHeight(mw);
dssim_info *dssim = dssim_init(1);
void *convert_data = convert_row_start(mw);
dssim_set_original_float_callback(dssim, width, height, convert_row_callback, convert_data);
convert_row_finish(convert_data);
{
ExceptionInfo *exception = AcquireExceptionInfo();
const double original_density = color_density(mw);
unsigned qmax = min(quality(mw), opt->quality_out_max);
unsigned qmin = opt->quality_out_min;
unsigned steps = 0;
/*
* binary search of quality space for optimally lowest quality that
* produces an acceptable level of distortion
*/
while (qmax > qmin + 1 && steps < opt->max_steps)
{
double density_ratio;
unsigned q;
steps++;
q = (qmax + qmin) / 2;
/* change quality */
tmp = CloneMagickWand(mw);
MagickSetImageCompressionQuality(tmp, q);
/* apply quality change */
MagickWriteImages(tmp, tmpfile, MagickTrue);
DestroyMagickWand(tmp);
tmp = NewMagickWand();
MagickReadImage(tmp, tmpfile);
void *convert_data = convert_row_start(tmp);
dssim_set_modified_float_callback(dssim, width, height, convert_row_callback, convert_data);
convert_row_finish(convert_data);
double error = 20.0 * dssim_compare(dssim, NULL); // scaled to threshold of previous implementation
density_ratio = fabs(color_density(tmp) - original_density) / original_density;
/* color density ratio threshold is an alternative quality measure.
If it's exceeded, pretend MSE was higher to increase quality */
if (density_ratio > opt->color_density_ratio) {
error *= 1.25 + density_ratio; // fudge factor
}
/* eliminate half search space based on whether distortion within thresholds */
if (error > opt->error_threshold)
{
qmin = q;
} else {
qmax = q;
}
if (opt->show_progress)
{
fprintf(stdout, "%.2f/%[email protected]%u ", error, density_ratio, q);
}
/* Stop searching if close enough to the target */
if (fabs(error - opt->error_threshold) < opt->error_threshold * ERROR_THRESHOLD_INACCURACY) {
qmax = q;
break;
}
}
if (opt->show_progress)
{
putc('\n', stdout);
}
MagickSetImageCompressionQuality(mw, qmax);
/* "Chroma sub-sampling works because human vision is relatively insensitive to
* small areas of colour. It gives a significant reduction in file sizes, with
* little loss of perceived quality." [3]
*/
#if MagickLibVersion >= 0x630 /* FIXME: available in 0x660, not available in 0x628, not sure which version it was introduced in */
(void) MagickSetImageProperty(mw, "jpeg:sampling-factor", "2x2");
#endif
/* strip an image of all profiles and comments */
(void) MagickStripImage(mw);
MagickWriteImages(mw, tmpfile, MagickTrue);
(void) DestroyMagickWand(tmp);
tmp = NewMagickWand();
MagickReadImage(tmp, tmpfile);
exception = DestroyExceptionInfo(exception);
}
return tmp;
}