本文整理汇总了C++中ThrowReaderException函数的典型用法代码示例。如果您正苦于以下问题:C++ ThrowReaderException函数的具体用法?C++ ThrowReaderException怎么用?C++ ThrowReaderException使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了ThrowReaderException函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ReadYUVImage
/*
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %
% %
% %
% R e a d Y U V I m a g e %
% %
% %
% %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% ReadYUVImage() reads an image with digital YUV (CCIR 601 4:1:1, plane
% or partition interlaced, or 4:2:2 plane, partition interlaced or
% noninterlaced) bytes 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 ReadYUVImage method is:
%
% Image *ReadYUVImage(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 *ReadYUVImage(const ImageInfo *image_info,ExceptionInfo *exception)
{
Image
*chroma_image,
*image,
*resize_image;
InterlaceType
interlace;
MagickBooleanType
status;
register const PixelPacket
*chroma_pixels;
register ssize_t
x;
register PixelPacket
*q;
register unsigned char
*p;
ssize_t
count,
horizontal_factor,
vertical_factor,
y;
size_t
quantum;
unsigned char
*scanline;
/*
Allocate 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);
if ((image->columns == 0) || (image->rows == 0))
ThrowReaderException(OptionError,"MustSpecifyImageSize");
status=SetImageExtent(image,image->columns,image->rows);
if (status == MagickFalse)
{
InheritException(exception,&image->exception);
return(DestroyImageList(image));
}
quantum=(size_t) (image->depth <= 8 ? 1 : 2);
interlace=image_info->interlace;
horizontal_factor=2;
vertical_factor=2;
if (image_info->sampling_factor != (char *) NULL)
{
GeometryInfo
geometry_info;
MagickStatusType
flags;
flags=ParseGeometry(image_info->sampling_factor,&geometry_info);
horizontal_factor=(ssize_t) geometry_info.rho;
vertical_factor=(ssize_t) geometry_info.sigma;
if ((flags & SigmaValue) == 0)
vertical_factor=horizontal_factor;
//.........这里部分代码省略.........
示例2: ReadVIFFImage
//.........这里部分代码省略.........
max_packets,
quantum;
ViffInfo
viff_info;
/*
Open image file.
*/
assert(image_info != (const ImageInfo *) NULL);
assert(image_info->signature == MagickSignature);
if (image_info->debug != MagickFalse)
(void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",
image_info->filename);
assert(exception != (ExceptionInfo *) NULL);
assert(exception->signature == MagickSignature);
image=AcquireImage(image_info);
status=OpenBlob(image_info,image,ReadBinaryBlobMode,exception);
if (status == MagickFalse)
{
image=DestroyImageList(image);
return((Image *) NULL);
}
/*
Read VIFF header (1024 bytes).
*/
count=ReadBlob(image,1,&viff_info.identifier);
do
{
/*
Verify VIFF identifier.
*/
if ((count == 0) || ((unsigned char) viff_info.identifier != 0xab))
ThrowReaderException(CorruptImageError,"NotAVIFFImage");
/*
Initialize VIFF image.
*/
count=ReadBlob(image,7,buffer);
viff_info.file_type=buffer[0];
viff_info.release=buffer[1];
viff_info.version=buffer[2];
viff_info.machine_dependency=buffer[3];
count=ReadBlob(image,512,(unsigned char *) viff_info.comment);
viff_info.comment[511]='\0';
if (strlen(viff_info.comment) > 4)
(void) SetImageProperty(image,"comment",viff_info.comment);
if ((viff_info.machine_dependency == VFF_DEP_DECORDER) ||
(viff_info.machine_dependency == VFF_DEP_NSORDER))
{
viff_info.rows=ReadBlobLSBLong(image);
viff_info.columns=ReadBlobLSBLong(image);
viff_info.subrows=ReadBlobLSBLong(image);
viff_info.x_offset=(int) ReadBlobLSBLong(image);
viff_info.y_offset=(int) ReadBlobLSBLong(image);
viff_info.x_bits_per_pixel=(float) ReadBlobLSBLong(image);
viff_info.y_bits_per_pixel=(float) ReadBlobLSBLong(image);
viff_info.location_type=ReadBlobLSBLong(image);
viff_info.location_dimension=ReadBlobLSBLong(image);
viff_info.number_of_images=ReadBlobLSBLong(image);
viff_info.number_data_bands=ReadBlobLSBLong(image);
viff_info.data_storage_type=ReadBlobLSBLong(image);
viff_info.data_encode_scheme=ReadBlobLSBLong(image);
viff_info.map_scheme=ReadBlobLSBLong(image);
viff_info.map_storage_type=ReadBlobLSBLong(image);
viff_info.map_rows=ReadBlobLSBLong(image);
viff_info.map_columns=ReadBlobLSBLong(image);
示例3: ReadSIXELImage
//.........这里部分代码省略.........
assert(exception != (ExceptionInfo *) NULL);
assert(exception->signature == MagickSignature);
image=AcquireImage(image_info);
status=OpenBlob(image_info,image,ReadBinaryBlobMode,exception);
if (status == MagickFalse)
{
image=DestroyImageList(image);
return((Image *) NULL);
}
/*
Read SIXEL file.
*/
length=MaxTextExtent;
sixel_buffer=(char *) AcquireQuantumMemory((size_t) length,sizeof(*sixel_buffer));
p=sixel_buffer;
if (sixel_buffer != (char *) NULL)
while (ReadBlobString(image,p) != (char *) NULL)
{
if ((*p == '#') && ((p == sixel_buffer) || (*(p-1) == '\n')))
continue;
if ((*p == '}') && (*(p+1) == ';'))
break;
p+=strlen(p);
if ((size_t) (p-sixel_buffer+MaxTextExtent) < length)
continue;
length<<=1;
sixel_buffer=(char *) ResizeQuantumMemory(sixel_buffer,length+MaxTextExtent,
sizeof(*sixel_buffer));
if (sixel_buffer == (char *) NULL)
break;
p=sixel_buffer+strlen(sixel_buffer);
}
if (sixel_buffer == (char *) NULL)
ThrowReaderException(ResourceLimitError,"MemoryAllocationFailed");
/*
Decode SIXEL
*/
if (sixel_decode((unsigned char *)sixel_buffer, &sixel_pixels, &image->columns, &image->rows, &sixel_palette, &image->colors) == MagickFalse)
{
sixel_buffer=(char *) RelinquishMagickMemory(sixel_buffer);
ThrowReaderException(CorruptImageError,"CorruptImage");
}
sixel_buffer=(char *) RelinquishMagickMemory(sixel_buffer);
image->depth=24;
image->storage_class=PseudoClass;
status=SetImageExtent(image,image->columns,image->rows);
if (status == MagickFalse)
{
InheritException(exception,&image->exception);
return(DestroyImageList(image));
}
if (AcquireImageColormap(image,image->colors) == MagickFalse)
{
sixel_pixels=(unsigned char *) RelinquishMagickMemory(sixel_pixels);
sixel_palette=(unsigned char *) RelinquishMagickMemory(sixel_palette);
ThrowReaderException(ResourceLimitError,"MemoryAllocationFailed");
}
for (i = 0; i < (ssize_t) image->colors; ++i) {
image->colormap[i].red = ScaleCharToQuantum(sixel_palette[i * 4 + 0]);
image->colormap[i].green = ScaleCharToQuantum(sixel_palette[i * 4 + 1]);
image->colormap[i].blue = ScaleCharToQuantum(sixel_palette[i * 4 + 2]);
}
j=0;
if (image_info->ping == MagickFalse)
示例4: ReadPIXImage
/*
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %
% %
% %
% R e a d P I X I m a g e %
% %
% %
% %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% ReadPIXImage() reads a Alias/Wavefront RLE 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 ReadPIXImage method is:
%
% Image *ReadPIXImage(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 *ReadPIXImage(const ImageInfo *image_info,ExceptionInfo *exception)
{
Image
*image;
MagickBooleanType
status;
Quantum
blue,
green,
index,
red;
register ssize_t
x;
register Quantum
*q;
size_t
bits_per_pixel,
height,
length,
width;
ssize_t
y;
/*
Open image file.
*/
assert(image_info != (const ImageInfo *) NULL);
assert(image_info->signature == MagickCoreSignature);
if (image_info->debug != MagickFalse)
(void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",
image_info->filename);
assert(exception != (ExceptionInfo *) NULL);
assert(exception->signature == MagickCoreSignature);
image=AcquireImage(image_info,exception);
status=OpenBlob(image_info,image,ReadBinaryBlobMode,exception);
if (status == MagickFalse)
{
image=DestroyImageList(image);
return((Image *) NULL);
}
/*
Read PIX image.
*/
width=ReadBlobMSBShort(image);
height=ReadBlobMSBShort(image);
(void) ReadBlobMSBShort(image); /* x-offset */
(void) ReadBlobMSBShort(image); /* y-offset */
bits_per_pixel=ReadBlobMSBShort(image);
if ((width == 0UL) || (height == 0UL) || ((bits_per_pixel != 8) &&
(bits_per_pixel != 24)))
ThrowReaderException(CorruptImageError,"ImproperImageHeader");
do
{
/*
Initialize image structure.
*/
image->columns=width;
image->rows=height;
if (bits_per_pixel == 8)
if (AcquireImageColormap(image,256,exception) == MagickFalse)
ThrowReaderException(ResourceLimitError,"MemoryAllocationFailed");
if ((image_info->ping != MagickFalse) && (image_info->number_scenes != 0))
if (image->scene >= (image_info->scene+image_info->number_scenes-1))
break;
status=SetImageExtent(image,image->columns,image->rows,exception);
if (status == MagickFalse)
return(DestroyImageList(image));
//.........这里部分代码省略.........
示例5: 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,exception);
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],MagickPathExtent);
filelist[i]=DestroyString(filelist[i]);
*read_info->magick='\0';
next_image=ReadImage(read_info,exception);
CatchException(exception);
if (next_image == (Image *) NULL)
//.........这里部分代码省略.........
示例6: ReadRLAImage
//.........这里部分代码省略.........
rla_info.number_matte_channels=(short) ReadBlobMSBShort(image);
if (rla_info.number_channels == 0)
rla_info.number_channels=3;
rla_info.number_channels+=rla_info.number_matte_channels;
rla_info.number_auxiliary_channels=(short) ReadBlobMSBShort(image);
rla_info.revision=(short) ReadBlobMSBShort(image);
count=ReadBlob(image,16,(unsigned char *) rla_info.gamma);
count=ReadBlob(image,24,(unsigned char *) rla_info.red_primary);
count=ReadBlob(image,24,(unsigned char *) rla_info.green_primary);
count=ReadBlob(image,24,(unsigned char *) rla_info.blue_primary);
count=ReadBlob(image,24,(unsigned char *) rla_info.white_point);
rla_info.job_number=ReadBlobMSBSignedLong(image);
count=ReadBlob(image,128,(unsigned char *) rla_info.name);
count=ReadBlob(image,128,(unsigned char *) rla_info.description);
rla_info.description[127]='\0';
count=ReadBlob(image,64,(unsigned char *) rla_info.program);
count=ReadBlob(image,32,(unsigned char *) rla_info.machine);
count=ReadBlob(image,32,(unsigned char *) rla_info.user);
count=ReadBlob(image,20,(unsigned char *) rla_info.date);
count=ReadBlob(image,24,(unsigned char *) rla_info.aspect);
count=ReadBlob(image,8,(unsigned char *) rla_info.aspect_ratio);
count=ReadBlob(image,32,(unsigned char *) rla_info.chan);
rla_info.field=(short) ReadBlobMSBShort(image);
count=ReadBlob(image,12,(unsigned char *) rla_info.time);
count=ReadBlob(image,32,(unsigned char *) rla_info.filter);
rla_info.bits_per_channel=(short) ReadBlobMSBShort(image);
rla_info.matte_type=(short) ReadBlobMSBShort(image);
rla_info.matte_bits=(short) ReadBlobMSBShort(image);
rla_info.auxiliary_type=(short) ReadBlobMSBShort(image);
rla_info.auxiliary_bits=(short) ReadBlobMSBShort(image);
count=ReadBlob(image,32,(unsigned char *) rla_info.auxiliary);
count=ReadBlob(image,36,(unsigned char *) rla_info.space);
if ((size_t) count != 36)
ThrowReaderException(CorruptImageError,"UnableToReadImageData");
rla_info.next=ReadBlobMSBSignedLong(image);
/*
Initialize image structure.
*/
image->alpha_trait=rla_info.number_matte_channels != 0 ? BlendPixelTrait :
UndefinedPixelTrait;
image->columns=(size_t) (rla_info.active_window.right-
rla_info.active_window.left+1);
image->rows=(size_t) (rla_info.active_window.top-
rla_info.active_window.bottom+1);
if (image_info->ping != MagickFalse)
{
(void) CloseBlob(image);
return(GetFirstImageInList(image));
}
status=SetImageExtent(image,image->columns,image->rows,exception);
if (status == MagickFalse)
return(DestroyImageList(image));
scanlines=(MagickOffsetType *) AcquireQuantumMemory(image->rows,
sizeof(*scanlines));
if (scanlines == (MagickOffsetType *) NULL)
ThrowReaderException(ResourceLimitError,"MemoryAllocationFailed");
if (*rla_info.description != '\0')
(void) SetImageProperty(image,"comment",rla_info.description,exception);
/*
Read offsets to each scanline data.
*/
for (i=0; i < (ssize_t) image->rows; i++)
scanlines[i]=(MagickOffsetType) ReadBlobMSBSignedLong(image);
/*
Read image data.
*/
示例7: assert
/*
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %
% %
% %
% R e a d G R A D I E N T I m a g e %
% %
% %
% %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% ReadGRADIENTImage creates a gradient image and initializes it to
% the color range as specified by the filename. It allocates the memory
% necessary for the new Image structure and returns a pointer to the new
% image.
%
% The format of the ReadGRADIENTImage method is:
%
% Image *ReadGRADIENTImage(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 *ReadGRADIENTImage(const ImageInfo *image_info,
ExceptionInfo *exception)
{
char
colorname[MaxTextExtent];
MagickBooleanType
status;
MagickPixelPacket
start_pixel,
stop_pixel;
PixelPacket
start_color,
stop_color;
Image
*image;
/*
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);
if ((image->columns == 0) || (image->rows == 0))
ThrowReaderException(OptionError,"MustSpecifyImageSize");
(void) SetImageOpacity(image,(Quantum) TransparentOpacity);
(void) CopyMagickString(image->filename,image_info->filename,MaxTextExtent);
(void) CopyMagickString(colorname,image_info->filename,MaxTextExtent);
(void) sscanf(image_info->filename,"%[^-]",colorname);
if (QueryColorDatabase(colorname,&start_color,exception) == MagickFalse)
{
image=DestroyImage(image);
return((Image *) NULL);
}
(void) QueryMagickColor(colorname,&start_pixel,exception);
(void) CopyMagickString(colorname,"white",MaxTextExtent);
if (PixelIntensityToQuantum(image,&start_color) > (Quantum) (QuantumRange/2))
(void) CopyMagickString(colorname,"black",MaxTextExtent);
(void) sscanf(image_info->filename,"%*[^-]-%s",colorname);
if (QueryColorDatabase(colorname,&stop_color,exception) == MagickFalse)
{
image=DestroyImage(image);
return((Image *) NULL);
}
(void) QueryMagickColor(colorname,&stop_pixel,exception);
if (IssRGBColorspace(start_pixel.colorspace) != MagickFalse)
{
start_color.red=ClampToQuantum(QuantumRange*DecompandsRGB(QuantumScale*
start_color.red));
start_color.green=ClampToQuantum(QuantumRange*DecompandsRGB(QuantumScale*
start_color.green));
start_color.blue=ClampToQuantum(QuantumRange*DecompandsRGB(QuantumScale*
start_color.blue));
}
if (IssRGBColorspace(stop_pixel.colorspace) != MagickFalse)
{
stop_color.red=ClampToQuantum(QuantumRange*DecompandsRGB(QuantumScale*
stop_color.red));
stop_color.green=ClampToQuantum(QuantumRange*DecompandsRGB(QuantumScale*
stop_color.green));
stop_color.blue=ClampToQuantum(QuantumRange*DecompandsRGB(QuantumScale*
stop_color.blue));
}
status=GradientImage(image,LocaleCompare(image_info->magick,"GRADIENT") == 0 ?
//.........这里部分代码省略.........
示例8: ThrowReaderException
static Image *ReadEMFImage(const ImageInfo *image_info,
ExceptionInfo *exception)
{
BITMAPINFO
DIBinfo;
HBITMAP
hBitmap,
hOldBitmap;
HDC
hDC;
HENHMETAFILE
hemf;
Image
*image;
long
height,
width,
y;
RECT
rect;
register long
x;
register PixelPacket
*q;
RGBQUAD
*pBits,
*ppBits;
image=AcquireImage(image_info);
hemf=ReadEnhMetaFile(image_info->filename,&width,&height);
if (hemf == (HENHMETAFILE) NULL)
ThrowReaderException(CorruptImageError,"ImproperImageHeader");
if ((image->columns == 0) || (image->rows == 0))
{
double
y_resolution,
x_resolution;
y_resolution=DefaultResolution;
x_resolution=DefaultResolution;
if (image->y_resolution > 0)
{
y_resolution=image->y_resolution;
if (image->units == PixelsPerCentimeterResolution)
y_resolution*=CENTIMETERS_INCH;
}
if (image->x_resolution > 0)
{
x_resolution=image->x_resolution;
if (image->units == PixelsPerCentimeterResolution)
x_resolution*=CENTIMETERS_INCH;
}
image->rows=(unsigned long) ((height/1000.0/CENTIMETERS_INCH)*
y_resolution+0.5);
image->columns=(unsigned long) ((width/1000.0/CENTIMETERS_INCH)*
x_resolution+0.5);
}
if (image_info->size != (char *) NULL)
{
long
x;
image->columns=width;
image->rows=height;
x=0;
y=0;
(void) GetGeometry(image_info->size,&x,&y,&image->columns,&image->rows);
}
if (image_info->page != (char *) NULL)
{
char
*geometry;
long
sans;
register char
*p;
MagickStatusType
flags;
geometry=GetPageGeometry(image_info->page);
p=strchr(geometry,'>');
if (p == (char *) NULL)
{
flags=ParseMetaGeometry(geometry,&sans,&sans,&image->columns,
&image->rows);
if (image->x_resolution != 0.0)
image->columns=(unsigned long) ((image->columns*
image->x_resolution)+0.5);
//.........这里部分代码省略.........
示例9: ReadTEXTImage
//.........这里部分代码省略.........
image->columns=(size_t) floor((((double) page.width*image->resolution.x)/
delta.x)+0.5);
image->rows=(size_t) floor((((double) page.height*image->resolution.y)/
delta.y)+0.5);
status=SetImageExtent(image,image->columns,image->rows,exception);
if (status == MagickFalse)
return(DestroyImageList(image));
image->page.x=0;
image->page.y=0;
texture=(Image *) NULL;
if (image_info->texture != (char *) NULL)
{
ImageInfo
*read_info;
read_info=CloneImageInfo(image_info);
SetImageInfoBlob(read_info,(void *) NULL,0);
(void) CopyMagickString(read_info->filename,image_info->texture,
MagickPathExtent);
texture=ReadImage(read_info,exception);
read_info=DestroyImageInfo(read_info);
}
/*
Annotate the text image.
*/
(void) SetImageBackgroundColor(image,exception);
draw_info=CloneDrawInfo(image_info,(DrawInfo *) NULL);
(void) CloneString(&draw_info->text,image_info->filename);
(void) FormatLocaleString(geometry,MagickPathExtent,"%gx%g%+g%+g",(double)
image->columns,(double) image->rows,(double) page.x,(double) page.y);
(void) CloneString(&draw_info->geometry,geometry);
status=GetTypeMetrics(image,draw_info,&metrics,exception);
if (status == MagickFalse)
ThrowReaderException(TypeError,"UnableToGetTypeMetrics");
page.y=(ssize_t) ceil((double) page.y+metrics.ascent-0.5);
(void) FormatLocaleString(geometry,MagickPathExtent,"%gx%g%+g%+g",(double)
image->columns,(double) image->rows,(double) page.x,(double) page.y);
(void) CloneString(&draw_info->geometry,geometry);
(void) CopyMagickString(filename,image_info->filename,MagickPathExtent);
if (*draw_info->text != '\0')
*draw_info->text='\0';
p=text;
for (offset=2*page.y; p != (char *) NULL; )
{
/*
Annotate image with text.
*/
(void) ConcatenateString(&draw_info->text,text);
(void) ConcatenateString(&draw_info->text,"\n");
offset+=(ssize_t) (metrics.ascent-metrics.descent);
if (image->previous == (Image *) NULL)
{
status=SetImageProgress(image,LoadImageTag,(MagickOffsetType) offset,
image->rows);
if (status == MagickFalse)
break;
}
p=ReadBlobString(image,text);
if ((offset < (ssize_t) image->rows) && (p != (char *) NULL))
continue;
if (texture != (Image *) NULL)
{
MagickProgressMonitor
progress_monitor;
progress_monitor=SetImageProgressMonitor(image,
示例10: assert
static Image *ReadEMFImage(const ImageInfo *image_info,
ExceptionInfo *exception)
{
Gdiplus::Bitmap
*bitmap;
Gdiplus::BitmapData
bitmap_data;
Gdiplus::GdiplusStartupInput
startup_input;
Gdiplus::Graphics
*graphics;
Gdiplus::Image
*source;
Gdiplus::Rect
rect;
GeometryInfo
geometry_info;
Image
*image;
MagickStatusType
flags;
register Quantum
*q;
register ssize_t
x;
ssize_t
y;
ULONG_PTR
token;
unsigned char
*p;
wchar_t
fileName[MagickPathExtent];
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);
image=AcquireImage(image_info,exception);
if (Gdiplus::GdiplusStartup(&token,&startup_input,NULL) !=
Gdiplus::Status::Ok)
ThrowReaderException(CoderError, "GdiplusStartupFailed");
MultiByteToWideChar(CP_UTF8,0,image->filename,-1,fileName,MagickPathExtent);
source=Gdiplus::Image::FromFile(fileName);
if (source == (Gdiplus::Image *) NULL)
{
Gdiplus::GdiplusShutdown(token);
ThrowReaderException(FileOpenError,"UnableToOpenFile");
}
image->resolution.x=source->GetHorizontalResolution();
image->resolution.y=source->GetVerticalResolution();
image->columns=(size_t) source->GetWidth();
image->rows=(size_t) source->GetHeight();
if (image_info->density != (char *) NULL)
{
flags=ParseGeometry(image_info->density,&geometry_info);
image->resolution.x=geometry_info.rho;
image->resolution.y=geometry_info.sigma;
if ((flags & SigmaValue) == 0)
image->resolution.y=image->resolution.x;
if ((image->resolution.x > 0.0) && (image->resolution.y > 0.0))
{
image->columns=(size_t) floor((Gdiplus::REAL) source->GetWidth() /
source->GetHorizontalResolution() * image->resolution.x + 0.5);
image->rows=(size_t)floor((Gdiplus::REAL) source->GetHeight() /
source->GetVerticalResolution() * image->resolution.y + 0.5);
}
}
bitmap=new Gdiplus::Bitmap((INT) image->columns,(INT) image->rows,
PixelFormat32bppARGB);
graphics=Gdiplus::Graphics::FromImage(bitmap);
graphics->SetInterpolationMode(Gdiplus::InterpolationModeHighQualityBicubic);
graphics->SetSmoothingMode(Gdiplus::SmoothingModeHighQuality);
graphics->SetTextRenderingHint(Gdiplus::TextRenderingHintClearTypeGridFit);
graphics->Clear(Gdiplus::Color((BYTE) ScaleQuantumToChar(
image->background_color.alpha),(BYTE) ScaleQuantumToChar(
image->background_color.red),(BYTE) ScaleQuantumToChar(
image->background_color.green),(BYTE) ScaleQuantumToChar(
image->background_color.blue)));
graphics->DrawImage(source,0,0,(INT) image->columns,(INT) image->rows);
delete graphics;
//.........这里部分代码省略.........
示例11: assert
static Image *ReadCLIPBOARDImage(const ImageInfo *image_info,
ExceptionInfo *exception)
{
Image
*image;
register ssize_t
x;
register Quantum
*q;
ssize_t
y;
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);
{
HBITMAP
bitmapH;
HPALETTE
hPal;
OpenClipboard(NULL);
bitmapH=(HBITMAP) GetClipboardData(CF_BITMAP);
hPal=(HPALETTE) GetClipboardData(CF_PALETTE);
CloseClipboard();
if ( bitmapH == NULL )
ThrowReaderException(CoderError,"NoBitmapOnClipboard");
{
BITMAPINFO
DIBinfo;
BITMAP
bitmap;
HBITMAP
hBitmap,
hOldBitmap;
HDC
hDC,
hMemDC;
RGBQUAD
*pBits,
*ppBits;
/* create an offscreen DC for the source */
hMemDC=CreateCompatibleDC(NULL);
hOldBitmap=(HBITMAP) SelectObject(hMemDC,bitmapH);
GetObject(bitmapH,sizeof(BITMAP),(LPSTR) &bitmap);
if ((image->columns == 0) || (image->rows == 0))
{
image->rows=bitmap.bmHeight;
image->columns=bitmap.bmWidth;
}
/*
Initialize the bitmap header info.
*/
(void) ResetMagickMemory(&DIBinfo,0,sizeof(BITMAPINFO));
DIBinfo.bmiHeader.biSize=sizeof(BITMAPINFOHEADER);
DIBinfo.bmiHeader.biWidth=(LONG) image->columns;
DIBinfo.bmiHeader.biHeight=(-1)*(LONG) image->rows;
DIBinfo.bmiHeader.biPlanes=1;
DIBinfo.bmiHeader.biBitCount=32;
DIBinfo.bmiHeader.biCompression=BI_RGB;
hDC=GetDC(NULL);
if (hDC == 0)
ThrowReaderException(CoderError,"UnableToCreateADC");
hBitmap=CreateDIBSection(hDC,&DIBinfo,DIB_RGB_COLORS,(void **) &ppBits,
NULL,0);
ReleaseDC(NULL,hDC);
if (hBitmap == 0)
ThrowReaderException(CoderError,"UnableToCreateBitmap");
/* create an offscreen DC */
hDC=CreateCompatibleDC(NULL);
if (hDC == 0)
{
DeleteObject(hBitmap);
ThrowReaderException(CoderError,"UnableToCreateADC");
}
hOldBitmap=(HBITMAP) SelectObject(hDC,hBitmap);
if (hOldBitmap == 0)
{
DeleteDC(hDC);
DeleteObject(hBitmap);
ThrowReaderException(CoderError,"UnableToCreateBitmap");
}
if (hPal != NULL)
{
/* Kenichi Masuko says this needed */
SelectPalette(hDC, hPal, FALSE);
//.........这里部分代码省略.........
示例12: assert
static Image *ReadSFWImage(const ImageInfo *image_info,ExceptionInfo *exception)
{
static unsigned char
HuffmanTable[] =
{
0xFF, 0xC4, 0x01, 0xA2, 0x00, 0x00, 0x01, 0x05, 0x01, 0x01, 0x01,
0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B,
0x01, 0x00, 0x03, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x02, 0x03, 0x04,
0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x10, 0x00, 0x02, 0x01,
0x03, 0x03, 0x02, 0x04, 0x03, 0x05, 0x05, 0x04, 0x04, 0x00, 0x00,
0x01, 0x7D, 0x01, 0x02, 0x03, 0x00, 0x04, 0x11, 0x05, 0x12, 0x21,
0x31, 0x41, 0x06, 0x13, 0x51, 0x61, 0x07, 0x22, 0x71, 0x14, 0x32,
0x81, 0x91, 0xA1, 0x08, 0x23, 0x42, 0xB1, 0xC1, 0x15, 0x52, 0xD1,
0xF0, 0x24, 0x33, 0x62, 0x72, 0x82, 0x09, 0x0A, 0x16, 0x17, 0x18,
0x19, 0x1A, 0x25, 0x26, 0x27, 0x28, 0x29, 0x2A, 0x34, 0x35, 0x36,
0x37, 0x38, 0x39, 0x3A, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, 0x49,
0x4A, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58, 0x59, 0x5A, 0x63, 0x64,
0x65, 0x66, 0x67, 0x68, 0x69, 0x6A, 0x73, 0x74, 0x75, 0x76, 0x77,
0x78, 0x79, 0x7A, 0x83, 0x84, 0x85, 0x86, 0x87, 0x88, 0x89, 0x8A,
0x92, 0x93, 0x94, 0x95, 0x96, 0x97, 0x98, 0x99, 0x9A, 0xA2, 0xA3,
0xA4, 0xA5, 0xA6, 0xA7, 0xA8, 0xA9, 0xAA, 0xB2, 0xB3, 0xB4, 0xB5,
0xB6, 0xB7, 0xB8, 0xB9, 0xBA, 0xC2, 0xC3, 0xC4, 0xC5, 0xC6, 0xC7,
0xC8, 0xC9, 0xCA, 0xD2, 0xD3, 0xD4, 0xD5, 0xD6, 0xD7, 0xD8, 0xD9,
0xDA, 0xE1, 0xE2, 0xE3, 0xE4, 0xE5, 0xE6, 0xE7, 0xE8, 0xE9, 0xEA,
0xF1, 0xF2, 0xF3, 0xF4, 0xF5, 0xF6, 0xF7, 0xF8, 0xF9, 0xFA, 0x11,
0x00, 0x02, 0x01, 0x02, 0x04, 0x04, 0x03, 0x04, 0x07, 0x05, 0x04,
0x04, 0x00, 0x01, 0x02, 0x77, 0x00, 0x01, 0x02, 0x03, 0x11, 0x04,
0x05, 0x21, 0x31, 0x06, 0x12, 0x41, 0x51, 0x07, 0x61, 0x71, 0x13,
0x22, 0x32, 0x81, 0x08, 0x14, 0x42, 0x91, 0xA1, 0xB1, 0xC1, 0x09,
0x23, 0x33, 0x52, 0xF0, 0x15, 0x62, 0x72, 0xD1, 0x0A, 0x16, 0x24,
0x34, 0xE1, 0x25, 0xF1, 0x17, 0x18, 0x19, 0x1A, 0x26, 0x27, 0x28,
0x29, 0x2A, 0x35, 0x36, 0x37, 0x38, 0x39, 0x3A, 0x43, 0x44, 0x45,
0x46, 0x47, 0x48, 0x49, 0x4A, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58,
0x59, 0x5A, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69, 0x6A, 0x73,
0x74, 0x75, 0x76, 0x77, 0x78, 0x79, 0x7A, 0x82, 0x83, 0x84, 0x85,
0x86, 0x87, 0x88, 0x89, 0x8A, 0x92, 0x93, 0x94, 0x95, 0x96, 0x97,
0x98, 0x99, 0x9A, 0xA2, 0xA3, 0xA4, 0xA5, 0xA6, 0xA7, 0xA8, 0xA9,
0xAA, 0xB2, 0xB3, 0xB4, 0xB5, 0xB6, 0xB7, 0xB8, 0xB9, 0xBA, 0xC2,
0xC3, 0xC4, 0xC5, 0xC6, 0xC7, 0xC8, 0xC9, 0xCA, 0xD2, 0xD3, 0xD4,
0xD5, 0xD6, 0xD7, 0xD8, 0xD9, 0xDA, 0xE2, 0xE3, 0xE4, 0xE5, 0xE6,
0xE7, 0xE8, 0xE9, 0xEA, 0xF2, 0xF3, 0xF4, 0xF5, 0xF6, 0xF7, 0xF8,
0xF9, 0xFA
};
FILE
*file;
Image
*flipped_image,
*image;
ImageInfo
*read_info;
int
unique_file;
MagickBooleanType
status;
register unsigned char
*header,
*data;
size_t
extent;
ssize_t
count;
unsigned char
*buffer,
*offset;
/*
Open image file.
*/
assert(image_info != (const ImageInfo *) NULL);
assert(image_info->signature == MagickSignature);
if (image_info->debug != MagickFalse)
(void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",
image_info->filename);
assert(exception != (ExceptionInfo *) NULL);
assert(exception->signature == MagickSignature);
image=AcquireImage(image_info);
status=OpenBlob(image_info,image,ReadBinaryBlobMode,exception);
if (status == MagickFalse)
{
image=DestroyImageList(image);
return((Image *) NULL);
}
/*
Read image into a buffer.
*/
buffer=(unsigned char *) AcquireQuantumMemory((size_t) GetBlobSize(image),
sizeof(*buffer));
if (buffer == (unsigned char *) NULL)
ThrowReaderException(ResourceLimitError,"MemoryAllocationFailed");
//.........这里部分代码省略.........
示例13: assert
/*
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %
% %
% %
% R e a d G R A D I E N T I m a g e %
% %
% %
% %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% ReadGRADIENTImage creates a gradient image and initializes it to
% the color range as specified by the filename. It allocates the memory
% necessary for the new Image structure and returns a pointer to the new
% image.
%
% The format of the ReadGRADIENTImage method is:
%
% Image *ReadGRADIENTImage(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 *ReadGRADIENTImage(const ImageInfo *image_info,
ExceptionInfo *exception)
{
char
colorname[MaxTextExtent];
Image
*image;
MagickBooleanType
icc_color,
status;
PixelInfo
start_color,
stop_color;
/*
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);
if ((image->columns == 0) || (image->rows == 0))
ThrowReaderException(OptionError,"MustSpecifyImageSize");
(void) SetImageAlpha(image,(Quantum) TransparentAlpha,exception);
(void) CopyMagickString(image->filename,image_info->filename,MaxTextExtent);
(void) CopyMagickString(colorname,image_info->filename,MaxTextExtent);
(void) sscanf(image_info->filename,"%[^-]",colorname);
icc_color=MagickFalse;
if (LocaleCompare(colorname,"icc") == 0)
{
(void) ConcatenateMagickString(colorname,"-",MaxTextExtent);
(void) sscanf(image_info->filename,"%*[^-]-%[^-]",colorname+4);
icc_color=MagickTrue;
}
status=QueryColorCompliance(colorname,AllCompliance,&start_color,exception);
if (status == MagickFalse)
{
image=DestroyImage(image);
return((Image *) NULL);
}
(void) CopyMagickString(colorname,"white",MaxTextExtent);
if (GetPixelInfoIntensity(&start_color) > (Quantum) (QuantumRange/2))
(void) CopyMagickString(colorname,"black",MaxTextExtent);
if (icc_color == MagickFalse)
(void) sscanf(image_info->filename,"%*[^-]-%s",colorname);
else
(void) sscanf(image_info->filename,"%*[^-]-%*[^-]-%s",colorname);
status=QueryColorCompliance(colorname,AllCompliance,&stop_color,exception);
if (status == MagickFalse)
{
image=DestroyImage(image);
return((Image *) NULL);
}
status=GradientImage(image,LocaleCompare(image_info->magick,"GRADIENT") == 0 ?
LinearGradient : RadialGradient,PadSpread,&start_color,&stop_color,
exception);
if (status == MagickFalse)
{
image=DestroyImageList(image);
return((Image *) NULL);
}
if ((start_color.alpha_trait != BlendPixelTrait) &&
(stop_color.alpha_trait != BlendPixelTrait))
(void) SetImageAlphaChannel(image,DeactivateAlphaChannel,exception);
return(GetFirstImageInList(image));
//.........这里部分代码省略.........
示例14: ReadDPSImage
//.........这里部分代码省略.........
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);
display=XOpenDisplay(image_info->server_name);
if (display == (Display *) NULL)
return((Image *) NULL);
/*
Set our forgiving exception handler.
*/
(void) XSetErrorHandler(XError);
/*
Open image file.
*/
image=AcquireImage(image_info,exception);
status=OpenBlob(image_info,image,ReadBinaryBlobMode,exception);
if (status == MagickFalse)
return((Image *) NULL);
/*
Get user defaults from X resource database.
*/
client_name=GetClientName();
resource_database=XGetResourceDatabase(display,client_name);
XGetResourceInfo(image_info,resource_database,client_name,&resource_info);
/*
Allocate standard colormap.
*/
map_info=XAllocStandardColormap();
visual_info=(XVisualInfo *) NULL;
if (map_info == (XStandardColormap *) NULL)
ThrowReaderException(ResourceLimitError,"UnableToCreateStandardColormap")
else
{
/*
Initialize visual info.
*/
(void) CloneString(&resource_info.visual_type,"default");
visual_info=XBestVisualInfo(display,map_info,&resource_info);
map_info->colormap=(Colormap) NULL;
}
if ((map_info == (XStandardColormap *) NULL) ||
(visual_info == (XVisualInfo *) NULL))
{
image=DestroyImage(image);
XFreeResources(display,visual_info,map_info,(XPixelInfo *) NULL,
(XFontStruct *) NULL,&resource_info,(XWindowInfo *) NULL);
return((Image *) NULL);
}
/*
Create a pixmap the appropriate size for the image.
*/
screen=ScreenOfDisplay(display,visual_info->screen);
pixels_per_point=XDPSPixelsPerPoint(screen);
if ((image->resolution.x != 0.0) && (image->resolution.y != 0.0))
pixels_per_point=MagickMin(image->resolution.x,image->resolution.y)/
DefaultResolution;
status=XDPSCreatePixmapForEPSF((DPSContext) NULL,screen,
GetBlobFileHandle(image),visual_info->depth,pixels_per_point,&pixmap,
&bits_per_pixel,&page);
if ((status == dps_status_failure) || (status == dps_status_no_extension))
{
image=DestroyImage(image);
XFreeResources(display,visual_info,map_info,(XPixelInfo *) NULL,
示例15: ReadTXTImage
/*
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %
% %
% %
% R e a d T X T I m a g e %
% %
% %
% %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% ReadTXTImage() reads a text file and returns it as an image. It allocates
% the memory necessary for the new Image structure and returns a pointer to
% the new image.
%
% The format of the ReadTXTImage method is:
%
% Image *ReadTXTImage(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 *ReadTXTImage(const ImageInfo *image_info,ExceptionInfo *exception)
{
char
colorspace[MagickPathExtent],
text[MagickPathExtent];
Image
*image;
long
x_offset,
y_offset;
PixelInfo
pixel;
MagickBooleanType
status;
QuantumAny
range;
register ssize_t
i,
x;
register Quantum
*q;
ssize_t
count,
type,
y;
unsigned long
depth,
height,
max_value,
width;
/*
Open image file.
*/
assert(image_info != (const ImageInfo *) NULL);
assert(image_info->signature == MagickCoreSignature);
if (image_info->debug != MagickFalse)
(void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",
image_info->filename);
assert(exception != (ExceptionInfo *) NULL);
assert(exception->signature == MagickCoreSignature);
image=AcquireImage(image_info,exception);
status=OpenBlob(image_info,image,ReadBinaryBlobMode,exception);
if (status == MagickFalse)
{
image=DestroyImageList(image);
return((Image *) NULL);
}
(void) ResetMagickMemory(text,0,sizeof(text));
(void) ReadBlobString(image,text);
if (LocaleNCompare((char *) text,MagickID,strlen(MagickID)) != 0)
ThrowReaderException(CorruptImageError,"ImproperImageHeader");
do
{
width=0;
height=0;
max_value=0;
*colorspace='\0';
count=(ssize_t) sscanf(text+32,"%lu,%lu,%lu,%s",&width,&height,&max_value,
colorspace);
if ((count != 4) || (width == 0) || (height == 0) || (max_value == 0))
ThrowReaderException(CorruptImageError,"ImproperImageHeader");
image->columns=width;
image->rows=height;
for (depth=1; (GetQuantumRange(depth)+1) < max_value; depth++) ;
//.........这里部分代码省略.........