本文整理汇总了C++中DestroyImage函数的典型用法代码示例。如果您正苦于以下问题:C++ DestroyImage函数的具体用法?C++ DestroyImage怎么用?C++ DestroyImage使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了DestroyImage函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ReadCALSImage
/*
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %
% %
% %
% R e a d C A L S I m a g e %
% %
% %
% %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% ReadCALSImage() reads an CALS Raster Group 1 image format 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 ReadCALSImage method is:
%
% Image *ReadCALSImage(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 *ReadCALSImage(const ImageInfo *image_info,
ExceptionInfo *exception)
{
char
filename[MaxTextExtent],
header[129],
message[MaxTextExtent];
FILE
*file;
Image
*image;
ImageInfo
*read_info;
int
c,
unique_file;
MagickBooleanType
status;
register ssize_t
i;
unsigned long
density,
direction,
height,
orientation,
pel_path,
type,
width;
/*
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 CALS header.
*/
(void) ResetMagickMemory(header,0,sizeof(header));
density=0;
direction=0;
orientation=1;
pel_path=0;
type=1;
width=0;
height=0;
for (i=0; i < 16; i++)
{
if (ReadBlob(image,128,(unsigned char *) header) != 128)
break;
switch (*header)
{
case 'R':
case 'r':
{
//.........这里部分代码省略.........
示例2: WriteMPEGImage
static MagickBooleanType WriteMPEGImage(const ImageInfo *image_info,
Image *image)
{
#define WriteMPEGIntermediateFormat "jpg"
char
basename[MaxTextExtent],
filename[MaxTextExtent];
double
delay;
Image
*coalesce_image;
ImageInfo
*write_info;
int
file;
MagickBooleanType
status;
register Image
*p;
register ssize_t
i;
size_t
count,
length,
scene;
unsigned char
*blob;
/*
Open output image file.
*/
assert(image_info != (const ImageInfo *) NULL);
assert(image_info->signature == MagickSignature);
assert(image != (Image *) NULL);
assert(image->signature == MagickSignature);
if (image->debug != MagickFalse)
(void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
status=OpenBlob(image_info,image,WriteBinaryBlobMode,&image->exception);
if (status == MagickFalse)
return(status);
(void) CloseBlob(image);
/*
Write intermediate files.
*/
coalesce_image=CoalesceImages(image,&image->exception);
if (coalesce_image == (Image *) NULL)
return(MagickFalse);
file=AcquireUniqueFileResource(basename);
if (file != -1)
file=close(file)-1;
(void) FormatLocaleString(coalesce_image->filename,MaxTextExtent,"%s",
basename);
count=0;
write_info=CloneImageInfo(image_info);
*write_info->magick='\0';
for (p=coalesce_image; p != (Image *) NULL; p=GetNextImageInList(p))
{
char
previous_image[MaxTextExtent];
blob=(unsigned char *) NULL;
length=0;
scene=p->scene;
delay=100.0*p->delay/MagickMax(1.0*p->ticks_per_second,1.0);
for (i=0; i < (ssize_t) MagickMax((1.0*delay+1.0)/3.0,1.0); i++)
{
p->scene=count;
count++;
status=MagickFalse;
switch (i)
{
case 0:
{
Image
*frame;
(void) FormatLocaleString(p->filename,MaxTextExtent,"%s%.20g.%s",
basename,(double) p->scene,WriteMPEGIntermediateFormat);
(void) FormatLocaleString(filename,MaxTextExtent,"%s%.20g.%s",
basename,(double) p->scene,WriteMPEGIntermediateFormat);
(void) FormatLocaleString(previous_image,MaxTextExtent,
"%s%.20g.%s",basename,(double) p->scene,
WriteMPEGIntermediateFormat);
frame=CloneImage(p,0,0,MagickTrue,&p->exception);
if (frame == (Image *) NULL)
break;
status=WriteImage(write_info,frame);
frame=DestroyImage(frame);
break;
}
//.........这里部分代码省略.........
示例3: WndProc
//
// FUNCTION: WndProc(HWND, unsigniert, WORD, LONG)
//
// PUPOSE: handling of messages from main window
//
// WM_COMMAND - Processes message coming from the menu and the controls (e.g. button)
// WM_PAINT - Re/Drawing of main window
// WM_DESTROY - Ends application
//
//
LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
int wmId, wmEvent;
PAINTSTRUCT ps;
HDC hdc;
switch (message)
{
case WM_COMMAND:
wmId = LOWORD(wParam);
wmEvent = HIWORD(wParam);
// handling commands from menu and controls (e.g. buttons)
switch (wmId)
{
case IDM_ABOUT:
DialogBox(hInst, (LPCTSTR)IDD_ABOUTBOX, hWnd, (DLGPROC)About);
break;
case IDC_CHECK_BOX_BASE:
if (videofolderPath.compare("") == 0 && showVideoConfigWarning){
MessageBox(hWnd, "You haven't configure the video directory, which may lead to an error when trying to play video.", "WARNNING", MB_OK);
showVideoConfigWarning = false;
}
DestroyImage(MATCH_TYPE);
HandleMovement(0);
//need to first disable, then enable, otherwise same button will be disabled by mistake
EnableMatchImageInteractions(false);
EnableVideoInteractions(true);
EnableNavigator(true);
EnableBaseImageInteractions(true);
break;
case IDC_CHECK_BOX_MATCH:
HandleMovement(0);
//need to first disable, then enable, otherwise same button will be disabled by mistake
EnableBaseImageInteractions(false);
EnableMatchImageInteractions(true);
EnableNavigator(true);
break;
case IDC_BUTTON_LEFT:
HandleMovement(-1);
break;
case IDC_BUTTON_RIGHT:
HandleMovement(+1);
break;
case IDC_BUTTON_SAVE:
{
if (BST_CHECKED == SendMessage(check_box_handles[0], BM_GETCHECK, 0, 0)){
int trackID = Get_Number(trackId_handle);
int type = UNKNOW;
if (BST_CHECKED == SendMessage(check_box_handles[2], BM_GETCHECK, 0, 0)){
type = PARK;
}
else if (BST_CHECKED == SendMessage(check_box_handles[3], BM_GETCHECK, 0, 0)){
type = LEAVE;
}
int spotNum = Get_Number(spot_handle);
if (spotNum < 0 || type == UNKNOW){
MessageBox(hWnd, "Either SpotNum or Park/Leave type is not set yet, please check and save again!", "WARNING", MB_OK);
}
else{
if (saveSpotConfig(type, trackID, spotNum)){
Set_Text(spot_handle, "");
PostMessage(type == PARK ? check_box_handles[2] : check_box_handles[3], BM_SETCHECK, BST_UNCHECKED, 0);
}
}
}
else if (BST_CHECKED == SendMessage(check_box_handles[1], BM_GETCHECK, 0, 0)){
if (BST_CHECKED == SendMessage(merge_checkbox_handle, BM_GETCHECK, 0, 0)){
if (saveMerge(curBaseImageInfo->trackNum, curMatchImageInfo->trackNum)){
PostMessage(merge_checkbox_handle, BM_SETCHECK, BST_UNCHECKED, 0);
}
}
else{
MessageBox(hWnd, "The merge radio button is not set yet, please check and save again!", "WARNING", MB_OK);
}
}
else{
MessageBox(hWnd, "This should never be shown!", "ERROR", MB_OK);
}
}
break;
case IDC_BUTTON_DO_IT:
//.........这里部分代码省略.........
示例4: assert
/*
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %
% %
% %
% R e a d V I D I m a g e %
% %
% %
% %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% ReadVIDImage reads one of more images and creates a Visual Image
% Directory file. It allocates the memory necessary for the new Image
% structure and returns a pointer to the new image.
%
% The format of the ReadVIDImage method is:
%
% Image *ReadVIDImage(const ImageInfo *image_info,ExceptionInfo *exception)
%
% A description of each parameter follows:
%
% o image_info: the image info.
%
% o exception: return any errors or warnings in this structure.
%
*/
static Image *ReadVIDImage(const ImageInfo *image_info,ExceptionInfo *exception)
{
#define ClientName "montage"
char
**filelist,
*label;
Image
*image,
*images,
*montage_image,
*next_image,
*thumbnail_image;
ImageInfo
*read_info;
int
number_files;
MagickBooleanType
status;
MontageInfo
*montage_info;
RectangleInfo
geometry;
register ssize_t
i;
/*
Expand the filename.
*/
assert(image_info != (const ImageInfo *) NULL);
assert(image_info->signature == MagickSignature);
if (image_info->debug != MagickFalse)
(void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",
image_info->filename);
assert(exception != (ExceptionInfo *) NULL);
assert(exception->signature == MagickSignature);
image=AcquireImage(image_info);
filelist=(char **) AcquireAlignedMemory(1,sizeof(*filelist));
if (filelist == (char **) NULL)
ThrowReaderException(ResourceLimitError,"MemoryAllocationFailed");
filelist[0]=ConstantString(image_info->filename);
number_files=1;
status=ExpandFilenames(&number_files,&filelist);
if ((status == MagickFalse) || (number_files == 0))
ThrowReaderException(ResourceLimitError,"MemoryAllocationFailed");
image=DestroyImage(image);
/*
Read each image and convert them to a tile.
*/
images=NewImageList();
read_info=CloneImageInfo(image_info);
SetImageInfoBlob(read_info,(void *) NULL,0);
(void) SetImageInfoProgressMonitor(read_info,(MagickProgressMonitor) NULL,
(void *) NULL);
if (read_info->size == (char *) NULL)
(void) CloneString(&read_info->size,DefaultTileGeometry);
for (i=0; i < (ssize_t) number_files; i++)
{
if (image_info->debug != MagickFalse)
(void) LogMagickEvent(CoderEvent,GetMagickModule(),"name: %s",
filelist[i]);
(void) CopyMagickString(read_info->filename,filelist[i],MaxTextExtent);
filelist[i]=DestroyString(filelist[i]);
*read_info->magick='\0';
next_image=ReadImage(read_info,exception);
CatchException(exception);
if (next_image == (Image *) NULL)
//.........这里部分代码省略.........
示例5: CropToFitImage
/*
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %
% %
% %
+ C r o p T o F i t I m a g e %
% %
% %
% %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% CropToFitImage() crops the sheared image as determined by the bounding box
% as defined by width and height and shearing angles.
%
% The format of the CropToFitImage method is:
%
% Image *CropToFitImage(Image **image,const MagickRealType x_shear,
% const MagickRealType x_shear,const MagickRealType width,
% const MagickRealType height,const MagickBooleanType rotate,
% ExceptionInfo *exception)
%
% A description of each parameter follows.
%
% o image: The image.
%
% o x_shear, y_shear, width, height: Defines a region of the image to crop.
%
% o exception: Return any errors or warnings in this structure.
%
%
*/
static inline void CropToFitImage(Image **image,const MagickRealType x_shear,
const MagickRealType y_shear,const MagickRealType width,
const MagickRealType height,const MagickBooleanType rotate,
ExceptionInfo *exception)
{
Image
*crop_image;
PointInfo
extent[4],
min,
max;
RectangleInfo
geometry,
page;
register long
i;
/*
Calculate the rotated image size.
*/
extent[0].x=(double) (-width/2.0);
extent[0].y=(double) (-height/2.0);
extent[1].x=(double) width/2.0;
extent[1].y=(double) (-height/2.0);
extent[2].x=(double) (-width/2.0);
extent[2].y=(double) height/2.0;
extent[3].x=(double) width/2.0;
extent[3].y=(double) height/2.0;
for (i=0; i < 4; i++)
{
extent[i].x+=x_shear*extent[i].y;
extent[i].y+=y_shear*extent[i].x;
if (rotate != MagickFalse)
extent[i].x+=x_shear*extent[i].y;
extent[i].x+=(double) (*image)->columns/2.0;
extent[i].y+=(double) (*image)->rows/2.0;
}
min=extent[0];
max=extent[0];
for (i=1; i < 4; i++)
{
if (min.x > extent[i].x)
min.x=extent[i].x;
if (min.y > extent[i].y)
min.y=extent[i].y;
if (max.x < extent[i].x)
max.x=extent[i].x;
if (max.y < extent[i].y)
max.y=extent[i].y;
}
geometry.x=(long) (min.x+0.5);
geometry.y=(long) (min.y+0.5);
geometry.width=(unsigned long) (max.x-min.x+0.5);
geometry.height=(unsigned long) (max.y-min.y+0.5);
page=(*image)->page;
(void) ParseAbsoluteGeometry("0x0+0+0",&(*image)->page);
crop_image=CropImage(*image,&geometry,exception);
(*image)->page=page;
if (crop_image != (Image *) NULL)
{
crop_image->page=page;
*image=DestroyImage(*image);
*image=crop_image;
}
}
示例6: ReadXCFImage
/*
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %
% %
% %
% R e a d X C F I m a g e %
% %
% %
% %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% ReadXCFImage() reads a GIMP (GNU Image Manipulation Program) 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 ReadXCFImage method is:
%
% image=ReadXCFImage(image_info)
%
% A description of each parameter follows:
%
% o image_info: the image info.
%
% o exception: return any errors or warnings in this structure.
%
%
*/
static Image *ReadXCFImage(const ImageInfo *image_info,ExceptionInfo *exception)
{
char
magick[14];
Image
*image;
int
foundPropEnd = 0;
MagickBooleanType
status;
MagickOffsetType
offset;
register ssize_t
i;
size_t
length;
ssize_t
count;
size_t
image_type;
XCFDocInfo
doc_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);
}
count=ReadBlob(image,14,(unsigned char *) magick);
if ((count == 0) ||
(LocaleNCompare((char *) magick,"gimp xcf",8) != 0))
ThrowReaderException(CorruptImageError,"ImproperImageHeader");
(void) ResetMagickMemory(&doc_info,0,sizeof(XCFDocInfo));
doc_info.exception=exception;
doc_info.width=ReadBlobMSBLong(image);
doc_info.height=ReadBlobMSBLong(image);
if ((doc_info.width > 262144) || (doc_info.height > 262144))
ThrowReaderException(CorruptImageError,"ImproperImageHeader");
doc_info.image_type=ReadBlobMSBLong(image);
/*
Initialize image attributes.
*/
image->columns=doc_info.width;
image->rows=doc_info.height;
image_type=doc_info.image_type;
doc_info.file_size=GetBlobSize(image);
image->compression=NoCompression;
image->depth=8;
if (image_type == GIMP_RGB)
image->colorspace=RGBColorspace;
else
if (image_type == GIMP_GRAY)
//.........这里部分代码省略.........
示例7: ReadTEXTImage
//.........这里部分代码省略.........
flags;
flags=ParseGeometry(PSDensityGeometry,&geometry_info);
image->x_resolution=geometry_info.rho;
image->y_resolution=geometry_info.sigma;
if ((flags & SigmaValue) == 0)
image->y_resolution=image->x_resolution;
}
page.width=612;
page.height=792;
page.x=43;
page.y=43;
if (image_info->page != (char *) NULL)
(void) ParseAbsoluteGeometry(image_info->page,&page);
/*
Initialize Image structure.
*/
image->columns=(unsigned long) (((page.width*image->x_resolution)/
delta.x)+0.5);
image->rows=(unsigned long) (((page.height*image->y_resolution)/delta.y)+0.5);
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,
MaxTextExtent);
texture=ReadImage(read_info,exception);
read_info=DestroyImageInfo(read_info);
}
/*
Annotate the text image.
*/
(void) SetImageBackgroundColor(image);
draw_info=CloneDrawInfo(image_info,(DrawInfo *) NULL);
(void) CloneString(&draw_info->text,image_info->filename);
(void) FormatMagickString(geometry,MaxTextExtent,"0x0%+ld%+ld",page.x,page.y);
(void) CloneString(&draw_info->geometry,geometry);
status=GetTypeMetrics(image,draw_info,&metrics);
if (status == MagickFalse)
ThrowReaderException(TypeError,"UnableToGetTypeMetrics");
page.y=(long) (page.y+metrics.ascent+0.5);
(void) FormatMagickString(geometry,MaxTextExtent,"0x0%+ld%+ld",page.x,page.y);
(void) CloneString(&draw_info->geometry,geometry);
(void) CopyMagickString(filename,image_info->filename,MaxTextExtent);
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+=(long) (metrics.ascent-metrics.descent);
if (image->previous == (Image *) NULL)
{
status=SetImageProgress(image,LoadImageTag,offset,image->rows);
if (status == MagickFalse)
break;
示例8: WritePICONImage
//.........这里部分代码省略.........
j,
k,
y;
/*
Open output image file.
*/
assert(image_info != (const ImageInfo *) NULL);
assert(image_info->signature == MagickSignature);
assert(image != (Image *) NULL);
assert(image->signature == MagickSignature);
if (image->debug != MagickFalse)
(void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
assert(exception != (ExceptionInfo *) NULL);
assert(exception->signature == MagickSignature);
status=OpenBlob(image_info,image,WriteBinaryBlobMode,exception);
if (status == MagickFalse)
return(status);
if (IssRGBCompatibleColorspace(image->colorspace) == MagickFalse)
(void) TransformImageColorspace(image,sRGBColorspace,exception);
SetGeometry(image,&geometry);
(void) ParseMetaGeometry(PiconGeometry,&geometry.x,&geometry.y,
&geometry.width,&geometry.height);
picon=ResizeImage(image,geometry.width,geometry.height,TriangleFilter,
exception);
blob_info=CloneImageInfo(image_info);
(void) AcquireUniqueFilename(blob_info->filename);
if ((image_info->type != TrueColorType) &&
(IsImageGray(image,exception) != MagickFalse))
affinity_image=BlobToImage(blob_info,Graymap,GraymapExtent,exception);
else
affinity_image=BlobToImage(blob_info,Colormap,ColormapExtent,exception);
(void) RelinquishUniqueFileResource(blob_info->filename);
blob_info=DestroyImageInfo(blob_info);
if ((picon == (Image *) NULL) || (affinity_image == (Image *) NULL))
return(MagickFalse);
quantize_info=AcquireQuantizeInfo(image_info);
status=RemapImage(quantize_info,picon,affinity_image,exception);
quantize_info=DestroyQuantizeInfo(quantize_info);
affinity_image=DestroyImage(affinity_image);
transparent=MagickFalse;
if (picon->storage_class == PseudoClass)
{
(void) CompressImageColormap(picon,exception);
if (picon->alpha_trait == BlendPixelTrait)
transparent=MagickTrue;
}
else
{
/*
Convert DirectClass to PseudoClass picon.
*/
if (picon->alpha_trait == BlendPixelTrait)
{
/*
Map all the transparent pixels.
*/
for (y=0; y < (ssize_t) picon->rows; y++)
{
q=GetAuthenticPixels(picon,0,y,picon->columns,1,exception);
if (q == (Quantum *) NULL)
break;
for (x=0; x < (ssize_t) picon->columns; x++)
{
if (GetPixelAlpha(image,q) == (Quantum) TransparentAlpha)
transparent=MagickTrue;
示例9: Huffman2DEncodeImage
/*
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %
% %
% %
% H u f f m a n 2 D E n c o d e I m a g e %
% %
% %
% %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% Method Huffman2DEncodeImage compresses an image via two-dimensional
% Huffman-coding.
%
% The format of the Huffman2DEncodeImage method is:
%
% unsigned int Huffman2DEncodeImage(const ImageInfo *image_info,
% Image *image)
%
% A description of each parameter follows:
%
% o status: Method Huffman2DEncodeImage returns True if all the pixels are
% compressed without error, otherwise False.
%
% o image_info: The image info..
%
% o image: The image.
%
*/
static unsigned int Huffman2DEncodeImage(const ImageInfo *image_info,
Image *image)
{
char
filename[MaxTextExtent];
Image
*huffman_image;
ImageInfo
*clone_info;
long
count,
j;
register long
i;
TIFF
*tiff;
uint16
fillorder;
unsigned char
*buffer;
unsigned int
status;
unsigned long
*byte_count,
strip_size;
/*
Write image as CCITTFax4 TIFF image to a temporary file.
*/
assert(image_info != (ImageInfo *) NULL);
assert(image_info->signature == MagickSignature);
assert(image != (Image *) NULL);
assert(image->signature == MagickSignature);
huffman_image=CloneImage(image,0,0,True,&image->exception);
if (huffman_image == (Image *) NULL)
return(False);
(void) SetImageType(huffman_image,BilevelType);
if(!AcquireTemporaryFileName(filename))
{
DestroyImage(huffman_image);
ThrowBinaryException(FileOpenError,UnableToCreateTemporaryFile,
filename);
}
FormatString(huffman_image->filename,"tiff:%s",filename);
clone_info=CloneImageInfo(image_info);
clone_info->compression=Group4Compression;
clone_info->type=BilevelType;
(void) AddDefinitions(clone_info,"tiff:fill-order=msb2lsb",
&image->exception);
status=WriteImage(clone_info,huffman_image);
DestroyImageInfo(clone_info);
DestroyImage(huffman_image);
if (status == False)
return(False);
tiff=TIFFOpen(filename,"rb");
if (tiff == (TIFF *) NULL)
{
(void) LiberateTemporaryFile(filename);
ThrowBinaryException(FileOpenError,UnableToOpenFile,
image_info->filename)
}
示例10: WriteHISTOGRAMImage
static MagickBooleanType WriteHISTOGRAMImage(const ImageInfo *image_info,
Image *image)
{
#define HistogramDensity "256x200"
ChannelType
channel;
char
filename[MaxTextExtent];
const char
*option;
ExceptionInfo
*exception;
Image
*histogram_image;
ImageInfo
*write_info;
ssize_t
y;
MagickBooleanType
status;
MagickPixelPacket
*histogram;
MagickRealType
maximum,
scale;
RectangleInfo
geometry;
register const PixelPacket
*p;
register ssize_t
x;
register PixelPacket
*q,
*r;
size_t
length;
/*
Allocate histogram image.
*/
assert(image_info != (const ImageInfo *) NULL);
assert(image_info->signature == MagickSignature);
assert(image != (Image *) NULL);
assert(image->signature == MagickSignature);
if (image->debug != MagickFalse)
(void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",
image_info->filename);
SetGeometry(image,&geometry);
if (image_info->density == (char *) NULL)
(void) ParseAbsoluteGeometry(HistogramDensity,&geometry);
else
(void) ParseAbsoluteGeometry(image_info->density,&geometry);
histogram_image=CloneImage(image,geometry.width,geometry.height,MagickTrue,
&image->exception);
if (histogram_image == (Image *) NULL)
ThrowWriterException(ResourceLimitError,"MemoryAllocationFailed");
(void) SetImageStorageClass(histogram_image,DirectClass);
/*
Allocate histogram count arrays.
*/
length=MagickMax((size_t) ScaleQuantumToChar((Quantum) QuantumRange)+1UL,
histogram_image->columns);
histogram=(MagickPixelPacket *) AcquireQuantumMemory(length,
sizeof(*histogram));
if (histogram == (MagickPixelPacket *) NULL)
{
histogram_image=DestroyImage(histogram_image);
ThrowWriterException(ResourceLimitError,"MemoryAllocationFailed");
}
/*
Initialize histogram count arrays.
*/
channel=image_info->channel;
(void) ResetMagickMemory(histogram,0,length*sizeof(*histogram));
for (y=0; y < (ssize_t) image->rows; y++)
{
p=GetVirtualPixels(image,0,y,image->columns,1,&image->exception);
if (p == (const PixelPacket *) NULL)
break;
for (x=0; x < (ssize_t) image->columns; x++)
{
if ((channel & RedChannel) != 0)
histogram[ScaleQuantumToChar(GetRedPixelComponent(p))].red++;
if ((channel & GreenChannel) != 0)
histogram[ScaleQuantumToChar(GetGreenPixelComponent(p))].green++;
//.........这里部分代码省略.........
示例11: FrameImage
/*
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %
% %
% %
% F r a m e I m a g e %
% %
% %
% %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% FrameImage() adds a simulated three-dimensional border around the image.
% The color of the border is defined by the matte_color member of image.
% Members width and height of frame_info specify the border width of the
% vertical and horizontal sides of the frame. Members inner and outer
% indicate the width of the inner and outer shadows of the frame.
%
% The format of the FrameImage method is:
%
% Image *FrameImage(const Image *image,const FrameInfo *frame_info,
% ExceptionInfo *exception)
%
% A description of each parameter follows:
%
% o image: the image.
%
% o frame_info: Define the width and height of the frame and its bevels.
%
% o exception: return any errors or warnings in this structure.
%
*/
MagickExport Image *FrameImage(const Image *image,const FrameInfo *frame_info,
ExceptionInfo *exception)
{
#define FrameImageTag "Frame/Image"
CacheView
*image_view,
*frame_view;
Image
*frame_image;
MagickBooleanType
status;
MagickOffsetType
progress;
MagickPixelPacket
accentuate,
border,
highlight,
interior,
matte,
shadow,
trough;
register ssize_t
x;
size_t
bevel_width,
height,
width;
ssize_t
y;
/*
Check frame geometry.
*/
assert(image != (Image *) NULL);
assert(image->signature == MagickSignature);
if (image->debug != MagickFalse)
(void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
assert(frame_info != (FrameInfo *) NULL);
if ((frame_info->outer_bevel < 0) || (frame_info->inner_bevel < 0))
ThrowImageException(OptionError,"FrameIsLessThanImageSize");
bevel_width=(size_t) (frame_info->outer_bevel+frame_info->inner_bevel);
width=frame_info->width-frame_info->x-bevel_width;
height=frame_info->height-frame_info->y-bevel_width;
if ((width < image->columns) || (height < image->rows))
ThrowImageException(OptionError,"FrameIsLessThanImageSize");
/*
Initialize framed image attributes.
*/
frame_image=CloneImage(image,frame_info->width,frame_info->height,MagickTrue,
exception);
if (frame_image == (Image *) NULL)
return((Image *) NULL);
if (SetImageStorageClass(frame_image,DirectClass) == MagickFalse)
{
InheritException(exception,&frame_image->exception);
frame_image=DestroyImage(frame_image);
return((Image *) NULL);
}
if (frame_image->matte_color.opacity != OpaqueOpacity)
frame_image->matte=MagickTrue;
frame_image->page=image->page;
//.........这里部分代码省略.........
示例12: GetBit
static Image *ReadSTEGANOImage(const ImageInfo *image_info,
ExceptionInfo *exception)
{
#define GetBit(alpha,i) MagickMin((((size_t) (alpha) >> (size_t) \
(i)) & 0x01),16)
#define SetBit(alpha,i,set) (alpha)=(IndexPacket) ((set) != 0 ? \
(size_t) (alpha) | (one << (size_t) (i)) : (size_t) \
(alpha) & ~(one << (size_t) (i)))
Image
*image,
*watermark;
ImageInfo
*read_info;
int
c;
MagickBooleanType
status;
PixelPacket
pixel;
register IndexPacket
*indexes;
register PixelPacket
*q;
register ssize_t
x;
size_t
depth,
one;
ssize_t
i,
j,
k,
y;
/*
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);
one=1;
image=AcquireImage(image_info);
if ((image->columns == 0) || (image->rows == 0))
ThrowReaderException(OptionError,"MustSpecifyImageSize");
read_info=CloneImageInfo(image_info);
SetImageInfoBlob(read_info,(void *) NULL,0);
*read_info->magick='\0';
watermark=ReadImage(read_info,exception);
read_info=DestroyImageInfo(read_info);
if (watermark == (Image *) NULL)
return((Image *) NULL);
watermark->depth=MAGICKCORE_QUANTUM_DEPTH;
if (AcquireImageColormap(image,MaxColormapSize) == MagickFalse)
ThrowReaderException(ResourceLimitError,"MemoryAllocationFailed");
if (image_info->ping != MagickFalse)
{
(void) CloseBlob(image);
return(GetFirstImageInList(image));
}
/*
Get hidden watermark from low-order bits of image.
*/
c=0;
i=0;
j=0;
i=(ssize_t) (watermark->depth-1);
depth=watermark->depth;
for (k=image->offset; (i >= 0) && (j < (ssize_t) depth); i--)
{
for (y=0; (y < (ssize_t) image->rows) && (j < (ssize_t) depth); y++)
{
x=0;
for ( ; (x < (ssize_t) image->columns) && (j < (ssize_t) depth); x++)
{
if ((k/(ssize_t) watermark->columns) >= (ssize_t) watermark->rows)
break;
(void) GetOneVirtualPixel(watermark,k % (ssize_t) watermark->columns,
k/(ssize_t) watermark->columns,&pixel,exception);
q=GetAuthenticPixels(image,x,y,1,1,exception);
if (q == (PixelPacket *) NULL)
break;
indexes=GetAuthenticIndexQueue(image);
switch (c)
{
case 0:
{
//.........这里部分代码省略.........
示例13: ReadHDRImage
/*
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %
% %
% %
% R e a d H D R I m a g e %
% %
% %
% %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
% ReadHDRImage() reads the Radiance RGBE image format 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 ReadHDRImage method is:
%
% Image *ReadHDRImage(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 *ReadHDRImage(const ImageInfo *image_info,ExceptionInfo *exception)
{
char
format[MaxTextExtent],
keyword[MaxTextExtent],
tag[MaxTextExtent],
value[MaxTextExtent];
double
gamma;
Image
*image;
int
c;
MagickBooleanType
status,
value_expected;
register Quantum
*q;
register ssize_t
i,
x;
register unsigned char
*p;
ssize_t
count,
y;
unsigned char
*end,
pixel[4],
*pixels;
/*
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,exception);
status=OpenBlob(image_info,image,ReadBinaryBlobMode,exception);
if (status == MagickFalse)
{
image=DestroyImageList(image);
return((Image *) NULL);
}
/*
Decode image header.
*/
image->columns=0;
image->rows=0;
*format='\0';
c=ReadBlobByte(image);
if (c == EOF)
{
image=DestroyImage(image);
return((Image *) NULL);
}
while (isgraph(c) && (image->columns == 0) && (image->rows == 0))
{
if (c == (int) '#')
{
char
//.........这里部分代码省略.........
示例14: WriteCALSImage
//.........这里部分代码省略.........
count=WriteCALSRecord(image,"doccls: NONE");
count=WriteCALSRecord(image,"rtype: 1");
orient_x=0;
orient_y=0;
switch (image->orientation)
{
case TopRightOrientation:
{
orient_x=180;
orient_y=270;
break;
}
case BottomRightOrientation:
{
orient_x=180;
orient_y=90;
break;
}
case BottomLeftOrientation:
{
orient_y=90;
break;
}
case LeftTopOrientation:
{
orient_x=270;
break;
}
case RightTopOrientation:
{
orient_x=270;
orient_y=180;
break;
}
case RightBottomOrientation:
{
orient_x=90;
orient_y=180;
break;
}
case LeftBottomOrientation:
{
orient_x=90;
break;
}
default:
{
orient_y=270;
break;
}
}
(void) FormatLocaleString(header,sizeof(header),"rorient: %03ld,%03ld",
(long) orient_x,(long) orient_y);
count=WriteCALSRecord(image,header);
(void) FormatLocaleString(header,sizeof(header),"rpelcnt: %06lu,%06lu",
(unsigned long) image->columns,(unsigned long) image->rows);
count=WriteCALSRecord(image,header);
density=200;
if (image_info->density != (char *) NULL)
{
GeometryInfo
geometry_info;
(void) ParseGeometry(image_info->density,&geometry_info);
density=(size_t) floor(geometry_info.rho+0.5);
}
(void) FormatLocaleString(header,sizeof(header),"rdensty: %04lu",
(unsigned long) density);
count=WriteCALSRecord(image,header);
count=WriteCALSRecord(image,"notes: NONE");
(void) ResetMagickMemory(header,' ',128);
for (i=0; i < 5; i++)
(void) WriteBlob(image,128,(unsigned char *) header);
/*
Write CALS pixels.
*/
write_info=CloneImageInfo(image_info);
(void) CopyMagickString(write_info->filename,"GROUP4:",MaxTextExtent);
(void) CopyMagickString(write_info->magick,"GROUP4",MaxTextExtent);
group4_image=CloneImage(image,0,0,MagickTrue,&image->exception);
if (group4_image == (Image *) NULL)
{
(void) CloseBlob(image);
return(MagickFalse);
}
group4=(unsigned char *) ImageToBlob(write_info,group4_image,&length,
&image->exception);
group4_image=DestroyImage(group4_image);
if (group4 == (unsigned char *) NULL)
{
(void) CloseBlob(image);
return(MagickFalse);
}
write_info=DestroyImageInfo(write_info);
if (WriteBlob(image,length,group4) != (ssize_t) length)
status=MagickFalse;
group4=(unsigned char *) RelinquishMagickMemory(group4);
(void) CloseBlob(image);
return(status);
}
示例15: assert
MagickExport Image *OilPaintImage(const Image *image,const double radius,
ExceptionInfo *exception)
{
#define NumberPaintBins 256
#define OilPaintImageTag "OilPaint/Image"
CacheView
*image_view,
*paint_view;
Image
*paint_image;
MagickBooleanType
status;
MagickOffsetType
progress;
size_t
**restrict histograms,
width;
ssize_t
y;
/*
Initialize painted image attributes.
*/
assert(image != (const Image *) NULL);
assert(image->signature == MagickSignature);
if (image->debug != MagickFalse)
(void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
assert(exception != (ExceptionInfo *) NULL);
assert(exception->signature == MagickSignature);
width=GetOptimalKernelWidth2D(radius,0.5);
paint_image=CloneImage(image,image->columns,image->rows,MagickTrue,exception);
if (paint_image == (Image *) NULL)
return((Image *) NULL);
if (SetImageStorageClass(paint_image,DirectClass) == MagickFalse)
{
InheritException(exception,&paint_image->exception);
paint_image=DestroyImage(paint_image);
return((Image *) NULL);
}
histograms=AcquireHistogramThreadSet(NumberPaintBins);
if (histograms == (size_t **) NULL)
{
paint_image=DestroyImage(paint_image);
ThrowImageException(ResourceLimitError,"MemoryAllocationFailed");
}
/*
Oil paint image.
*/
status=MagickTrue;
progress=0;
image_view=AcquireCacheView(image);
paint_view=AcquireCacheView(paint_image);
#if defined(MAGICKCORE_OPENMP_SUPPORT)
#pragma omp parallel for schedule(dynamic,4) shared(progress,status)
#endif
for (y=0; y < (ssize_t) image->rows; y++)
{
register const IndexPacket
*restrict indexes;
register const PixelPacket
*restrict p;
register IndexPacket
*restrict paint_indexes;
register ssize_t
x;
register PixelPacket
*restrict q;
register size_t
*histogram;
if (status == MagickFalse)
continue;
p=GetCacheViewVirtualPixels(image_view,-((ssize_t) width/2L),y-(ssize_t)
(width/2L),image->columns+width,width,exception);
q=QueueCacheViewAuthenticPixels(paint_view,0,y,paint_image->columns,1,
exception);
if ((p == (const PixelPacket *) NULL) || (q == (PixelPacket *) NULL))
{
status=MagickFalse;
continue;
}
indexes=GetCacheViewVirtualIndexQueue(image_view);
paint_indexes=GetCacheViewAuthenticIndexQueue(paint_view);
histogram=histograms[GetOpenMPThreadId()];
for (x=0; x < (ssize_t) image->columns; x++)
{
register ssize_t
i,
u;
//.........这里部分代码省略.........