本文整理汇总了C++中CatchException函数的典型用法代码示例。如果您正苦于以下问题:C++ CatchException函数的具体用法?C++ CatchException怎么用?C++ CatchException使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了CatchException函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: magickminify
void* magickminify(void* src, ssize_t src_len, ssize_t* dst_len){
Image *image, *resize;
ImageInfo image_info;
ExceptionInfo *exception;
size_t len;
void *ans;
GetImageInfo(&image_info);
exception = AcquireExceptionInfo();
image = BlobToImage(&image_info, src, src_len, exception);
if (exception->severity != UndefinedException)
CatchException(exception);
if (image == (Image *) NULL)
exit(1);
resize = MinifyImage(image, exception);
if (exception->severity != UndefinedException)
CatchException(exception);
if (image == (Image *) NULL)
exit(1);
ans = ImageToBlob(&image_info, resize, &len, exception);
if(dst_len != NULL)
*dst_len = len;
DestroyImage(image);
DestroyImage(resize);
DestroyExceptionInfo(exception);
return ans;
}
开发者ID:viocost,项目名称:project4,代码行数:35,代码来源:magickminify.c
示例2: GetExceptionInfo
Image *get_image_from_path(char *path)
{
ImageInfo *image_info;
Image *img = NULL;
ExceptionInfo exception;
GetExceptionInfo(&exception);
if ((image_info = CloneImageInfo((ImageInfo *)NULL)) == NULL) {
CatchException(&exception);
DestroyImageInfo(image_info);
DestroyImage(img);
return (NULL);
}
strcpy(image_info->filename, path);
if ((img = ReadImage(image_info, &exception)) == NULL)
{
CatchException(&exception);
DestroyImageInfo(image_info);
DestroyImage(img);
return (NULL);
}
DestroyImageInfo(image_info);
return (img);
}
开发者ID:adamlin,项目名称:TissueReconstruction,代码行数:26,代码来源:max_contrast.c
示例3: lib_writeImages
/*----------------------------------------------------------------------- */
SEXP
lib_writeImages (SEXP x, SEXP files, SEXP quality) {
int nz, nfiles, i;
Image * images, * image;
ImageInfo *image_info;
ExceptionInfo exception;
/* basic checks */
validImage(x,0);
images = sexp2Magick (x);
nz = GetImageListLength(images);
nfiles = LENGTH (files);
if ( nfiles != 1 && nfiles != nz)
error ( "number of files must be 1, or equal to the size of the image stack" );
if ( images == NULL || GetImageListLength (images) < 1 )
error ( "cannot write an empty image" );
GetExceptionInfo (&exception);
image_info = CloneImageInfo ( (ImageInfo *)NULL );
/* set attributes in image_info*/
image_info->compression = images->compression;
image_info->quality = (unsigned int) INTEGER (quality)[0];
if ( nfiles == 1 ) {
/* save into a single file, TIFF, GIF, or automatically add file suffixes */
strcpy (image_info->filename, CHAR(STRING_ELT(files, 0)) );
/* we want to overwrite the feature imported from SEXP image */
strcpy (images->filename, image_info->filename);
WriteImages(image_info, images, CHAR(STRING_ELT(files, 0)), &exception);
CatchException (&exception);
}
else {
/* save each frame into a separate file */
for ( i = 0; i < nz; i++ ) {
image = GetImageFromList (images, i);
if ( image == NULL || GetImageListLength (image) < 1 ) {
warning ( "cannot write an empty image, skipping" );
continue;
}
strcpy (image_info->filename, CHAR(STRING_ELT(files, i)));
/* we want to overwrite the feature imported from SEXP image */
strcpy (image->filename, image_info->filename);
WriteImage (image_info, image);
CatchException (&image->exception);
// WriteImages(image_info, image, CHAR(STRING_ELT(files, i)), &exception);
// CatchException (&exception);
}
}
image_info = DestroyImageInfo (image_info);
images = DestroyImageList (images);
DestroyExceptionInfo(&exception);
return R_NilValue;
}
开发者ID:kevin-keraudren,项目名称:cell-segmentation,代码行数:57,代码来源:io.c
示例4: GetExceptionInfo
Image *get_blue_channe_image(Image *img)
{
unsigned int i = 0;
unsigned int j = 0;
PixelPacket *px_original;
PixelPacket *px_new;
Image *new_img;
ExceptionInfo exception;
ImageInfo *new_img_info;
GetExceptionInfo(&exception);
if ((new_img_info = CloneImageInfo((ImageInfo *)NULL)) == NULL) {
CatchException(&exception);
DestroyImageInfo(new_img_info);
return (NULL);
}
new_img_info->colorspace = RGBColorspace;
new_img = AllocateImage(new_img_info);
new_img->rows = img->rows;
new_img->columns = img->columns;
if ((px_original = GetImagePixelsEx(img, 0, 0, img->columns, img->rows, &exception)) == NULL)
{
DestroyImage(new_img);
CatchException(&exception);
return (NULL);
}
if ((px_new = SetImagePixelsEx(new_img, 0, 0, new_img->columns, new_img->rows, &exception)) == NULL)
{
DestroyImage(new_img);
CatchException(&exception);
return (NULL);
}
while (i < img->rows)
{
j = 0;
while (j < img->columns)
{
px_new[(new_img->columns * i) + j].red = 0;
px_new[(new_img->columns * i) + j].blue = px_original[(img->columns * i) + j].blue;
px_new[(new_img->columns * i) + j].green = 0;
j++;
}
i++;
}
SyncImagePixels(new_img);
DestroyImageInfo(new_img_info);
return (new_img);
}
开发者ID:NIF-au,项目名称:DigitalControlServer,代码行数:54,代码来源:image_crop.c
示例5: malloc
Image *crop_image(Image *img, char *path, int image_width, int image_height, int width_offset, int height_offset)
{
Image *new_img = NULL;
ImageInfo *image_info;
Image *tmp;
RectangleInfo *portion;
ExceptionInfo exception;
portion = malloc(sizeof(*portion));
portion->width = image_width;
portion->height = image_height;
portion->x = width_offset;
portion->y = height_offset;
GetExceptionInfo(&exception);
if ((image_info = CloneImageInfo((ImageInfo *)NULL)) == NULL) {
CatchException(&exception);
DestroyImageInfo(image_info);
free(portion);
return (NULL);
}
strcpy(image_info->filename, path);
if ((new_img = ReadImage(image_info, &exception)) == NULL)
{
CatchException(&exception);
DestroyImage(new_img);
DestroyImageInfo(image_info);
free(portion);
return (NULL);
}
tmp = new_img;
if ((new_img = CropImage(img, portion, &exception)) == NULL) {
CatchException(&exception);
DestroyImage(tmp);
DestroyImageInfo(image_info);
free(portion);
return (NULL);
}
DestroyImage(img);
DestroyImage(tmp);
DestroyImageInfo(image_info);
free(portion);
SyncImagePixels(new_img);
free(path);
return (new_img);
}
开发者ID:adamlin,项目名称:TissueReconstruction,代码行数:52,代码来源:max_contrast.c
示例6: initGraphicsMagick
bool ScImgDataLoader_GMagick::preloadAlphaChannel(const QString& fn, int /*page*/, int res, bool& hasAlpha)
{
initGraphicsMagick();
initialize();
hasAlpha = false;
if (!QFile::exists(fn))
return false;
ExceptionInfo exception;
GetExceptionInfo(&exception);
ImageInfo *image_info = CloneImageInfo(0);
strcpy(image_info->filename, fn.toUtf8().data());
image_info->units = PixelsPerInchResolution;
Image *image = PingImage(image_info, &exception);
if (exception.severity != UndefinedException)
CatchException(&exception);
if (!image) {
qCritical() << "Failed to read image" << fn;
return false;
}
hasAlpha = image->matte;
if (!hasAlpha) return true;
return loadPicture(fn, 0, 0, false);
}
开发者ID:Sheikha443,项目名称:scribus,代码行数:26,代码来源:scimgdataloader_gmagick.cpp
示例7: exmagick_image_load_blob
static
ERL_NIF_TERM exmagick_image_load_blob (ErlNifEnv *env, int argc, const ERL_NIF_TERM argv[])
{
ErlNifBinary blob;
exm_resource_t *resource;
EXM_INIT;
ErlNifResourceType *type = (ErlNifResourceType *) enif_priv_data(env);
if (0 == enif_get_resource(env, argv[0], type, (void **) &resource))
{ EXM_FAIL(ehandler, "invalid handle"); }
if (0 == enif_inspect_binary(env, argv[1], &blob))
{ EXM_FAIL(ehandler, "argv[1]: bad argument"); }
if (resource->image != NULL)
{
DestroyImage(resource->image);
resource->image = NULL;
}
resource->image = BlobToImage(resource->i_info, blob.data, blob.size, &resource->e_info);
if (resource->image == NULL)
{
CatchException(&resource->e_info);
EXM_FAIL(ehandler, resource->e_info.reason);
}
return(enif_make_tuple2(env, enif_make_atom(env, "ok"), argv[0]));
ehandler:
return(enif_make_tuple2(env, enif_make_atom(env, "error"), exmagick_make_utf8str(env, errmsg)));
}
开发者ID:Xerpa,项目名称:exmagick,代码行数:33,代码来源:exmagick.c
示例8: exmagick_image_dump_file
static
ERL_NIF_TERM exmagick_image_dump_file (ErlNifEnv *env, int argc, const ERL_NIF_TERM argv[])
{
char filename[MaxTextExtent];
ErlNifBinary utf8;
exm_resource_t *resource;
EXM_INIT;
ErlNifResourceType *type = (ErlNifResourceType *) enif_priv_data(env);
if (0 == enif_get_resource(env, argv[0], type, (void **) &resource))
{ EXM_FAIL(ehandler, "invalid handle"); }
if (0 == exmagick_get_utf8str(env, argv[1], &utf8))
{ EXM_FAIL(ehandler, "argv[1]: bad argument"); }
exmagick_utf8strcpy (filename, &utf8, MaxTextExtent);
if (0 == WriteImages(resource->i_info, resource->image, filename, &resource->e_info))
{
CatchException(&resource->e_info);
EXM_FAIL(ehandler, resource->e_info.reason);
}
return(enif_make_tuple2(env, enif_make_atom(env, "ok"), argv[0]));
ehandler:
return(enif_make_tuple2(env, enif_make_atom(env, "error"), exmagick_make_utf8str(env, errmsg)));
}
开发者ID:Xerpa,项目名称:exmagick,代码行数:28,代码来源:exmagick.c
示例9: exmagick_image_dump_blob
static
ERL_NIF_TERM exmagick_image_dump_blob (ErlNifEnv *env, int argc, const ERL_NIF_TERM argv[])
{
void *blob;
size_t size;
exm_resource_t *resource;
EXM_INIT;
ErlNifResourceType *type = (ErlNifResourceType *) enif_priv_data(env);
if (0 == enif_get_resource(env, argv[0], type, (void **) &resource))
{ EXM_FAIL(ehandler, "invalid handle"); }
blob = ImageToBlob(resource->i_info, resource->image, &size, &resource->e_info);
if (NULL == blob)
{
CatchException(&resource->e_info);
EXM_FAIL(ehandler, resource->e_info.reason);
}
return(enif_make_tuple2(env,
enif_make_atom(env, "ok"),
enif_make_resource_binary(env, resource, blob, size)));
ehandler:
return(enif_make_tuple2(env, enif_make_atom(env, "error"), exmagick_make_utf8str(env, errmsg)));
}
开发者ID:Xerpa,项目名称:exmagick,代码行数:26,代码来源:exmagick.c
示例10: main
int main ( int argc, char **argv )
{
Image *canvas = (Image *)NULL;
char outfile[MaxTextExtent];
int rows, columns = 0;
char size[MaxTextExtent];
ImageInfo *image_info;
ExceptionInfo exception;
if ( argc != 2 )
{
(void) printf ( "Usage: %s filename\n", argv[0] );
exit( 1 );
}
outfile[MaxTextExtent-1]='\0';
(void) strncpy( outfile, argv[1], MaxTextExtent-1 );
if (LocaleNCompare("drawtest",argv[0],7) == 0)
InitializeMagick((char *) NULL);
else
InitializeMagick(*argv);
/*
* Create canvas image
*/
columns=596;
rows=842;
image_info=CloneImageInfo((ImageInfo*)NULL);
GetExceptionInfo( &exception );
FormatString(size, "%dx%d", columns, rows);
(void) CloneString(&image_info->size, size);
(void) strcpy( image_info->filename, "xc:white");
canvas = ReadImage ( image_info, &exception );
if (exception.severity != UndefinedException)
CatchException(&exception);
if ( canvas == (Image *)NULL )
{
(void) printf ( "Failed to read canvas image %s\n", image_info->filename );
exit(1);
}
/*
* Scribble on image
*/
ScribbleImage( canvas );
/*
* Save image to file
*/
canvas->filename[MaxTextExtent-1]='\0';
(void) strncpy( canvas->filename, outfile, MaxTextExtent-1);
(void) WriteImage ( image_info, canvas );
DestroyExceptionInfo( &exception );
DestroyImage( canvas );
DestroyImageInfo( image_info );
DestroyMagick();
return 0;
}
开发者ID:CliffsDover,项目名称:graphicsmagick,代码行数:60,代码来源:drawtest.c
示例11: GetCyanSample
bool ScImgDataLoader_GMagick::readCMYK(Image *input, RawImage *output, int width, int height)
{
/* Mapping:
red: cyan
green: magenta
blue: yellow
opacity: black
index: alpha
*/
//Copied from GraphicsMagick header and modified
#define GetCyanSample(p) (p.red)
#define GetMagentaSample(p) (p.green)
#define GetYellowSample(p) (p.blue)
#define GetCMYKBlackSample(p) (p.opacity)
#define GetAlphaSample(p) (p)
bool hasAlpha = input->matte;
if (!output->create(width, height, hasAlpha ? 5 : 4)) return false;
ExceptionInfo exception;
GetExceptionInfo(&exception);
const PixelPacket *pixels = AcquireImagePixels(input, 0, 0, width, height, &exception);
if (exception.severity != UndefinedException)
CatchException(&exception);
if (!pixels) {
qCritical() << QObject::tr("Could not get pixel data!");
return false;
}
const IndexPacket *alpha = 0;
if (hasAlpha) {
alpha = AccessImmutableIndexes(input);
if (!alpha) {
qCritical() << QObject::tr("Could not get alpha channel data!");
return false;
}
}
unsigned char *buffer = output->bits();
if (!buffer) {
qCritical() << QObject::tr("Could not allocate output buffer!");
return false;
}
int i;
for (i = 0; i < width*height; i++) {
*buffer++ = ScaleQuantumToChar(GetCyanSample(pixels[i]));
*buffer++ = ScaleQuantumToChar(GetMagentaSample(pixels[i]));
*buffer++ = ScaleQuantumToChar(GetYellowSample(pixels[i]));
*buffer++ = ScaleQuantumToChar(GetCMYKBlackSample(pixels[i]));
if (hasAlpha) {
*buffer++ = 255 - ScaleQuantumToChar(GetAlphaSample(alpha[i]));
}
}
return true;
}
开发者ID:Sheikha443,项目名称:scribus,代码行数:57,代码来源:scimgdataloader_gmagick.cpp
示例12: ValidateIdentifyCommand
/*
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %
% %
% %
% V a l i d a t e I d e n t i f y C o m m a n d %
% %
% %
% %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% ValidateIdentifyCommand() validates the ImageMagick identify command line
% program and returns the number of validation tests that passed and failed.
%
% The format of the ValidateIdentifyCommand method is:
%
% unsigned long ValidateIdentifyCommand(ImageInfo *image_info,
% const char *reference_filename,const char *output_filename,
% unsigned long *fail,ExceptionInfo *exception)
%
% A description of each parameter follows:
%
% o image_info: the image info.
%
% o reference_filename: the reference image filename.
%
% o output_filename: the output image filename.
%
% o fail: return the number of validation tests that pass.
%
% o exception: return any errors or warnings in this structure.
%
*/
static unsigned long ValidateIdentifyCommand(ImageInfo *image_info,
const char *reference_filename,const char *output_filename,
unsigned long *fail,ExceptionInfo *exception)
{
char
**arguments,
command[MaxTextExtent];
int
number_arguments;
MagickBooleanType
status;
register long
i,
j;
unsigned long
test;
(void) output_filename;
test=0;
(void) fprintf(stdout,"validate identify command line program:\n");
for (i=0; identify_options[i] != (char *) NULL; i++)
{
CatchException(exception);
(void) fprintf(stdout," test %lu: %s",test++,identify_options[i]);
(void) FormatMagickString(command,MaxTextExtent,"%s %s",
identify_options[i],reference_filename);
arguments=StringToArgv(command,&number_arguments);
if (arguments == (char **) NULL)
{
(void) fprintf(stdout,"... fail @ %s/%s/%lu.\n",GetMagickModule());
(*fail)++;
continue;
}
status=IdentifyImageCommand(image_info,number_arguments,arguments,
(char **) NULL,exception);
for (j=0; j < number_arguments; j++)
arguments[j]=DestroyString(arguments[j]);
arguments=(char **) RelinquishMagickMemory(arguments);
if (status != MagickFalse)
{
(void) fprintf(stdout,"... fail @ %s/%s/%lu.\n",GetMagickModule());
(*fail)++;
continue;
}
(void) fprintf(stdout,"... pass.\n");
}
(void) fprintf(stdout," summary: %lu subtests; %lu passed; %lu failed.\n",
test,test-(*fail),*fail);
return(test);
}
开发者ID:wrv,项目名称:CircleSquareFuzzing,代码行数:87,代码来源:validate.c
示例13: main
/*
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %
% %
% %
% M a i n %
% %
% %
% %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
%
*/
int main(int argc,char **argv)
{
char
*option,
*text;
ExceptionInfo
*exception;
ImageInfo
*image_info;
MagickBooleanType
regard_warnings,
status;
register long
i;
MagickCoreGenesis(*argv,MagickTrue);
exception=AcquireExceptionInfo();
regard_warnings=MagickFalse;
for (i=1; i < (long) argc; i++)
{
option=argv[i];
if ((strlen(option) == 1) || ((*option != '-') && (*option != '+')))
continue;
if (LocaleCompare("debug",option+1) == 0)
(void) SetLogEventMask(argv[++i]);
if (LocaleCompare("regard-warnings",option+1) == 0)
regard_warnings=MagickTrue;
}
image_info=AcquireImageInfo();
text=(char *) NULL;
status=CompareImageCommand(image_info,argc,argv,&text,exception);
if ((status == MagickFalse) || (exception->severity != UndefinedException))
{
if ((exception->severity < ErrorException) &&
(regard_warnings == MagickFalse))
status=MagickTrue;
CatchException(exception);
}
if (text != (char *) NULL)
{
(void) fputs(text,stdout);
(void) fputc('\n',stdout);
text=DestroyString(text);
}
image_info=DestroyImageInfo(image_info);
exception=DestroyExceptionInfo(exception);
MagickCoreTerminus();
return(status == MagickFalse ? 1 : 0);
}
开发者ID:vazexqi,项目名称:ParsecPipelineParallelism,代码行数:66,代码来源:compare.c
示例14: main
/*
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %
% %
% %
% M a i n %
% %
% %
% %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
%
*/
int main(int argc,char **argv)
{
char
*option,
*text;
ExceptionInfo
exception;
ImageInfo
*image_info;
MagickBooleanType
status;
register long
i;
InitializeMagick(*argv);
GetExceptionInfo(&exception);
for (i=1; i < (long) argc; i++)
{
option=argv[i];
if ((strlen(option) == 1) || ((*option != '-') && (*option != '+')))
continue;
if ((LocaleCompare("debug",option+1) == 0) && (i < (long) (argc-1)))
(void) SetLogEventMask(argv[++i]);
if (LocaleCompare("version",option+1) == 0)
{
(void) fprintf(stdout,"Version: %s\n",
GetMagickVersion((unsigned long *) NULL));
(void) fprintf(stdout,"Copyright: %s\n\n",GetMagickCopyright());
exit(0);
}
}
image_info=CloneImageInfo((ImageInfo *) NULL);
text=(char *) NULL;
status=IdentifyImageCommand(image_info,argc,argv,&text,&exception);
if (exception.severity != UndefinedException)
CatchException(&exception);
if (text != (char *) NULL)
{
(void) fputs(text,stdout);
(void) fputc('\n',stdout);
text=(char *) RelinquishMagickMemory(text);
}
image_info=DestroyImageInfo(image_info);
DestroyExceptionInfo(&exception);
DestroyMagick();
exit(!status);
return(MagickFalse);
}
开发者ID:miettal,项目名称:armadillo420_standard,代码行数:65,代码来源:identify.c
示例15: CatchException
Int ConsoleApplication::Run()
{
auto xc = CatchException( [ this ] { return this->Main(); } );
if ( xc )
{
TraceError( xc.TracingMessage() );
std::cout << std::endl
<< "Program caught an exception and exit abnormally." << std::endl;
std::cin.get();
}
return xc.Result();
}
开发者ID:slimek,项目名称:Caramel,代码行数:13,代码来源:Program.cpp
示例16: ngx_http_graphicsmagick_convert
static unsigned int
ngx_http_graphicsmagick_convert(char **argv, size_t argc)
{
// GraphicsMagick stuff
ngx_uint_t i;
char *option;
ExceptionInfo exception;
ImageInfo *image_info;
MagickBool regard_warnings, status;
// DO GraphicsMagick converting
InitializeMagick((char *) NULL);
GetExceptionInfo(&exception);
regard_warnings = 0;
for (i = 1; i < argc; i++) {
option = argv[i];
if ((ngx_strlen(option) == 1) || ((*option != '-') && (*option != '+'))) {
continue;
}
if (LocaleCompare("debug", option + 1) == 0) {
(void) SetLogEventMask(argv[++i]);
}
if (LocaleCompare("regard-warnings",option+1) == 0) {
regard_warnings = MagickTrue;
}
}
image_info = CloneImageInfo(0);
status = ConvertImageCommand(image_info, argc, argv, NULL, &exception);
if ((status == MagickFalse) || (exception.severity != UndefinedException)) {
if ((exception.severity < ErrorException) && (regard_warnings == MagickFalse)) {
status = MagickTrue;
}
CatchException(&exception);
}
DestroyImageInfo(image_info);
DestroyExceptionInfo(&exception);
return status;
}
开发者ID:jiangzhonghui,项目名称:graphicsmagick_nginx_module,代码行数:44,代码来源:ngx_http_graphicsmagick_module.c
示例17: exmagick_crop
static
ERL_NIF_TERM exmagick_crop (ErlNifEnv *env, int argc, const ERL_NIF_TERM argv[])
{
Image* cropped_image;
RectangleInfo rect;
exm_resource_t *resource;
EXM_INIT;
ErlNifResourceType *type = (ErlNifResourceType *) enif_priv_data(env);
if (0 == enif_get_resource(env, argv[0], type, (void **) &resource))
{ EXM_FAIL(ehandler, "invalid handle"); }
if (resource->image == NULL)
{ EXM_FAIL(ehandler, "image not loaded"); }
/* build rectangle */
if (0 == enif_get_long(env, argv[1], &rect.x))
{ EXM_FAIL(ehandler, "x0: bad argument"); }
if (0 == enif_get_long(env, argv[2], &rect.y))
{ EXM_FAIL(ehandler, "y0: bad argument"); }
if (0 == enif_get_ulong(env, argv[3], &rect.width))
{ EXM_FAIL(ehandler, "width: bad argument"); }
if (0 == enif_get_ulong(env, argv[4], &rect.height))
{ EXM_FAIL(ehandler, "height: bad argument"); }
/* actually crops image */
cropped_image = CropImage(resource->image, &rect, &resource->e_info);
if (cropped_image == NULL)
{
CatchException(&resource->e_info);
EXM_FAIL(ehandler, resource->e_info.reason);
}
DestroyImage(resource->image);
resource->image = cropped_image;
return(enif_make_tuple2(env, enif_make_atom(env, "ok"), argv[0]));
ehandler:
return(enif_make_tuple2(env, enif_make_atom(env, "error"), exmagick_make_utf8str(env, errmsg)));
}
开发者ID:Xerpa,项目名称:exmagick,代码行数:44,代码来源:exmagick.c
示例18: dump_multi_image
int dump_multi_image(Image *img, char *root_path, char *name, char *image_type)
{
char *final_path;
ImageInfo *image_info;
ExceptionInfo exception;
GetExceptionInfo(&exception);
if ((image_info = CloneImageInfo((ImageInfo *)NULL)) == NULL) {
CatchException(&exception);
DestroyImageInfo(image_info);
return -1;
}
asprintf(&final_path, "%s/%s.%s", root_path, name, image_type);
strcpy(img->filename, final_path);
WriteImage(image_info, img);
free(final_path);
return (0);
}
开发者ID:adamlin,项目名称:TissueReconstruction,代码行数:19,代码来源:max_contrast.c
示例19: CLICatchException
/*
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %
% %
% %
+ C L I C a t c h E x c e p t i o n %
% %
% %
% %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% CLICatchException() will report exceptions, either just non-fatal warnings
% only, or all errors, according to 'all_execeptions' boolean argument.
%
% The function returns true if errors are fatal, in which case the caller
% should abort and re-call with an 'all_exceptions' argument of true before
% quitting.
%
% The cut-off level between fatal and non-fatal may be controlled by options
% (FUTURE), but defaults to 'Error' exceptions.
%
% The format of the CLICatchException method is:
%
% MagickBooleanType CLICatchException(MagickCLI *cli_wand,
% const MagickBooleanType all_exceptions );
%
% Arguments are
%
% o cli_wand: The Wand CLI that holds the exception Information
%
% o all_exceptions: Report all exceptions, including the fatal one
%
*/
WandExport MagickBooleanType CLICatchException(MagickCLI *cli_wand,
const MagickBooleanType all_exceptions )
{
MagickBooleanType
status;
assert(cli_wand != (MagickCLI *) NULL);
assert(cli_wand->signature == WandSignature);
assert(cli_wand->wand.signature == WandSignature);
if (IfMagickTrue(cli_wand->wand.debug))
(void) LogMagickEvent(WandEvent,GetMagickModule(),"%s",cli_wand->wand.name);
// FUTURE: '-regard_warning' should make this more sensitive.
// Note pipelined options may like more control over this level
status = IsMagickTrue(cli_wand->wand.exception->severity > ErrorException);
if ( IfMagickFalse(status) || IfMagickTrue(all_exceptions) )
CatchException(cli_wand->wand.exception); /* output and clear exceptions */
return(status);
}
开发者ID:0xPr0xy,项目名称:ImageMagick,代码行数:54,代码来源:wandcli.c
示例20: GetExceptionInfo
bool ScImgDataLoader_GMagick::readRGB(Image *input, QImage *output, int width, int height)
{
bool hasAlpha = input->matte;
ExceptionInfo exception;
GetExceptionInfo(&exception);
const PixelPacket *pixels = AcquireImagePixels(input, 0, 0, width, height, &exception);
if (exception.severity != UndefinedException)
CatchException(&exception);
if (!pixels) {
qCritical() << QObject::tr("Could not get pixel data!");
return false;
}
unsigned char *buffer = output->bits();
if (!buffer) {
qCritical() << QObject::tr("Could not allocate output buffer!");
return false;
}
QRgb *s = (QRgb*)(output->scanLine(0));
int i;
for (i = 0; i < width*height; i++)
{
unsigned char b = ScaleQuantumToChar(pixels[i].blue);
unsigned char g = ScaleQuantumToChar(pixels[i].green);
unsigned char r = ScaleQuantumToChar(pixels[i].red);
unsigned char a;
if (hasAlpha)
a = 255 - ScaleQuantumToChar(pixels[i].opacity);
else
a = 255;
*s = qRgba(r, g, b, a);
s++;
}
return true;
}
开发者ID:Sheikha443,项目名称:scribus,代码行数:37,代码来源:scimgdataloader_gmagick.cpp
注:本文中的CatchException函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论