这篇教程C++ DestroyImage函数代码示例写得很实用,希望能帮到您。
本文整理汇总了C++中DestroyImage函数的典型用法代码示例。如果您正苦于以下问题:C++ DestroyImage函数的具体用法?C++ DestroyImage怎么用?C++ DestroyImage使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。 在下文中一共展示了DestroyImage函数的29个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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': {//.........这里部分代码省略.........
开发者ID:INT2208-ST,项目名称:MyFriend,代码行数:101,
示例2: WriteMPEGImagestatic 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; }//.........这里部分代码省略.........
开发者ID:INT2208-ST,项目名称:MyFriend,代码行数:101,
示例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://.........这里部分代码省略.........
开发者ID:liuruilinspy,项目名称:vehicleTrackingReview,代码行数:101,
示例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)//.........这里部分代码省略.........
开发者ID:JasonGross,项目名称:characters,代码行数:101,
示例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; }}
开发者ID:miettal,项目名称:armadillo420_standard,代码行数:99,
示例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)//.........这里部分代码省略.........
开发者ID:JasonGross,项目名称:characters,代码行数:101,
示例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;
开发者ID:0xPr0xy,项目名称:ImageMagick,代码行数:67,
示例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;
开发者ID:0xPr0xy,项目名称:ImageMagick,代码行数:67,
示例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) }
开发者ID:hank2015,项目名称:testCMS,代码行数:99,
示例10: WriteHISTOGRAMImagestatic 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++;//.........这里部分代码省略.........
开发者ID:JasonGross,项目名称:characters,代码行数:101,
示例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;//.........这里部分代码省略.........
开发者ID:JasonGross,项目名称:characters,代码行数:101,
示例12: GetBitstatic 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: {//.........这里部分代码省略.........
开发者ID:0xPr0xy,项目名称:ImageMagick,代码行数:101,
示例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//.........这里部分代码省略.........
开发者ID:0xPr0xy,项目名称:ImageMagick,代码行数:101,
示例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);}
开发者ID:INT2208-ST,项目名称:MyFriend,代码行数:101,
示例15: assertMagickExport 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;//.........这里部分代码省略.........
开发者ID:271845221,项目名称:Android-ImageMagick,代码行数:101,
示例16: CombineImages/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %% %% %% C o m b i n e I m a g e s %% %% %% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% CombineImages() combines one or more images into a single image. The% grayscale value of the pixels of each image in the sequence is assigned in% order to the specified channels of the combined image. The typical% ordering would be image 1 => Red, 2 => Green, 3 => Blue, etc.%% The format of the CombineImages method is:%% Image *CombineImages(const Image *image,const ChannelType channel,% ExceptionInfo *exception)%% A description of each parameter follows:%% o image: the image.%% o exception: return any errors or warnings in this structure.%*/MagickExport Image *CombineImages(const Image *image,const ChannelType channel, ExceptionInfo *exception){#define CombineImageTag "Combine/Image" CacheView *combine_view; const Image *next; Image *combine_image; MagickBooleanType status; MagickOffsetType progress; ssize_t y; /* Ensure the image are the same size. */ 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); for (next=image; next != (Image *) NULL; next=GetNextImageInList(next)) { if ((next->columns != image->columns) || (next->rows != image->rows)) ThrowImageException(OptionError,"ImagesAreNotTheSameSize"); } combine_image=CloneImage(image,0,0,MagickTrue,exception); if (combine_image == (Image *) NULL) return((Image *) NULL); if (SetImageStorageClass(combine_image,DirectClass) == MagickFalse) { InheritException(exception,&combine_image->exception); combine_image=DestroyImage(combine_image); return((Image *) NULL); } if (IssRGBCompatibleColorspace(image->colorspace) != MagickFalse) (void) SetImageColorspace(combine_image,sRGBColorspace); if ((channel & OpacityChannel) != 0) combine_image->matte=MagickTrue; (void) SetImageBackgroundColor(combine_image); /* Combine images. */ status=MagickTrue; progress=0; combine_view=AcquireAuthenticCacheView(combine_image,exception); for (y=0; y < (ssize_t) combine_image->rows; y++) { CacheView *image_view; const Image *next; PixelPacket *pixels; register const PixelPacket *restrict p; register PixelPacket//.........这里部分代码省略.........
开发者ID:JohnHeywardOBrien,项目名称:photogram,代码行数:101,
示例17: load_level//.........这里部分代码省略......... height, ntiles, ntile_rows, ntile_cols, tile_image_width, tile_image_height; /* start reading the data */ exception=inDocInfo->exception; width=ReadBlobMSBLong(image); height=ReadBlobMSBLong(image); /* read in the first tile offset. * if it is '0', then this tile level is empty * and we can simply return. */ offset=(MagickOffsetType) ReadBlobMSBLong(image); if (offset == 0) return(MagickTrue); /* Initialise the reference for the in-memory tile-compression */ ntile_rows=(height+TILE_HEIGHT-1)/TILE_HEIGHT; ntile_cols=(width+TILE_WIDTH-1)/TILE_WIDTH; ntiles=ntile_rows*ntile_cols; for (i = 0; i < (ssize_t) ntiles; i++) { status=MagickFalse; if (offset == 0) ThrowBinaryException(CorruptImageError,"NotEnoughTiles",image->filename); /* save the current position as it is where the * next tile offset is stored. */ saved_pos=TellBlob(image); /* read in the offset of the next tile so we can calculate the amount of data needed for this tile*/ offset2=(MagickOffsetType)ReadBlobMSBLong(image); /* if the offset is 0 then we need to read in the maximum possible allowing for negative compression */ if (offset2 == 0) offset2=(MagickOffsetType) (offset + TILE_WIDTH * TILE_WIDTH * 4* 1.5); /* seek to the tile offset */ offset=SeekBlob(image, offset, SEEK_SET); /* allocate the image for the tile NOTE: the last tile in a row or column may not be a full tile! */ tile_image_width=(size_t) (destLeft == (int) ntile_cols-1 ? (int) width % TILE_WIDTH : TILE_WIDTH); if (tile_image_width == 0) tile_image_width=TILE_WIDTH; tile_image_height = (size_t) (destTop == (int) ntile_rows-1 ? (int) height % TILE_HEIGHT : TILE_HEIGHT); if (tile_image_height == 0) tile_image_height=TILE_HEIGHT; tile_image=CloneImage(inLayerInfo->image,tile_image_width, tile_image_height,MagickTrue,exception); /* read in the tile */ switch (inDocInfo->compression) { case COMPRESS_NONE: if (load_tile(image,tile_image,inDocInfo,inLayerInfo,(size_t) (offset2-offset)) == 0) status=MagickTrue; break; case COMPRESS_RLE: if (load_tile_rle (image,tile_image,inDocInfo,inLayerInfo, (int) (offset2-offset)) == 0) status=MagickTrue; break; case COMPRESS_ZLIB: ThrowBinaryException(CoderError,"ZipCompressNotSupported", image->filename) case COMPRESS_FRACTAL: ThrowBinaryException(CoderError,"FractalCompressNotSupported", image->filename) } /* composite the tile onto the layer's image, and then destroy it */ (void) CompositeImage(inLayerInfo->image,CopyCompositeOp,tile_image, destLeft * TILE_WIDTH,destTop*TILE_HEIGHT); tile_image=DestroyImage(tile_image); /* adjust tile position */ destLeft++; if (destLeft >= (int) ntile_cols) { destLeft = 0; destTop++; } if (status != MagickFalse) return(MagickFalse); /* restore the saved position so we'll be ready to * read the next offset. */ offset=SeekBlob(image, saved_pos, SEEK_SET); /* read in the offset of the next tile */ offset=(MagickOffsetType) ReadBlobMSBLong(image); } if (offset != 0) ThrowBinaryException(CorruptImageError,"CorruptImage",image->filename) return(MagickTrue);}
开发者ID:JasonGross,项目名称:characters,代码行数:101,
示例18: assert/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %% %% %% R e a d X C I m a g e %% %% %% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% ReadXCImage creates a constant image and initializes it to the% X server color 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 ReadXCImage method is:%% Image *ReadXCImage(const ImageInfo *image_info,ExceptionInfo *exception)%% A description of each parameter follows:%% o image: The image.%% o image_info: the image info.%% o exception: return any errors or warnings in this structure.%*/static Image *ReadXCImage(const ImageInfo *image_info,ExceptionInfo *exception){ Image *image; IndexPacket index, *indexes; MagickBooleanType status; MagickPixelPacket color; ssize_t y; PixelPacket pixel; register ssize_t x; register PixelPacket *q; /* 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->columns=1; if (image->rows == 0) image->rows=1; (void) CopyMagickString(image->filename,image_info->filename,MaxTextExtent); status=QueryMagickColor((char *) image_info->filename,&color,exception); if (status == MagickFalse) { image=DestroyImage(image); return((Image *) NULL); } image->colorspace=color.colorspace; image->matte=color.matte; index=0; SetPixelPacket(image,&color,&pixel,&index); for (y=0; y < (ssize_t) image->rows; y++) { q=QueueAuthenticPixels(image,0,y,image->columns,1,exception); if (q == (PixelPacket *) NULL) break; for (x=0; x < (ssize_t) image->columns; x++) *q++=pixel; if (image->colorspace == CMYKColorspace) { indexes=GetAuthenticIndexQueue(image); for (x=0; x < (ssize_t) image->columns; x++) indexes[x]=index; } if (SyncAuthenticPixels(image,exception) == MagickFalse) break; } return(GetFirstImageInList(image));}
开发者ID:0xPr0xy,项目名称:ImageMagick,代码行数:100,
示例19: WriteHRZImage/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %% %% %% W r i t e H R Z I m a g e %% %% %% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% WriteHRZImage() writes an image to a file in HRZ X image format.%% The format of the WriteHRZImage method is:%% MagickBooleanType WriteHRZImage(const ImageInfo *image_info,Image *image)%% A description of each parameter follows.%% o image_info: the image info.%% o image: The image.%*/static MagickBooleanType WriteHRZImage(const ImageInfo *image_info,Image *image){ Image *hrz_image; MagickBooleanType status; register const PixelPacket *p; register ssize_t x, y; register unsigned char *q; ssize_t count; unsigned char *pixels; /* 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); hrz_image=ResizeImage(image,256,240,image->filter,image->blur, &image->exception); if (hrz_image == (Image *) NULL) return(MagickFalse); if (hrz_image->colorspace != RGBColorspace) (void) TransformImageColorspace(hrz_image,RGBColorspace); /* Allocate memory for pixels. */ pixels=(unsigned char *) AcquireQuantumMemory((size_t) hrz_image->columns, 3*sizeof(*pixels)); if (pixels == (unsigned char *) NULL) { hrz_image=DestroyImage(hrz_image); ThrowWriterException(ResourceLimitError,"MemoryAllocationFailed"); } /* Convert MIFF to HRZ raster pixels. */ for (y=0; y < (ssize_t) hrz_image->rows; y++) { p=GetVirtualPixels(hrz_image,0,y,hrz_image->columns,1,&image->exception); if (p == (PixelPacket *) NULL) break; q=pixels; for (x=0; x < (ssize_t) hrz_image->columns; x++) { *q++=ScaleQuantumToChar(GetRedPixelComponent(p))/4; *q++=ScaleQuantumToChar(GetGreenPixelComponent(p))/4; *q++=ScaleQuantumToChar(GetBluePixelComponent(p))/4; p++; } count=WriteBlob(image,(size_t) (q-pixels),pixels); if (count != (ssize_t) (q-pixels)) break; status=SetImageProgress(image,SaveImageTag,y,hrz_image->rows); if (status == MagickFalse) break; } pixels=(unsigned char *) RelinquishMagickMemory(pixels);//.........这里部分代码省略.........
开发者ID:JasonGross,项目名称:characters,代码行数:101,
示例20: GetExceptionInfoImage *substract_grayscale_to_original(Image *img, Image *gray_img, int min, int max){ unsigned int i = 0; unsigned int j = 0; PixelPacket *px_original; PixelPacket *px_gray; 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_gray = GetImagePixelsEx(gray_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) { if(px_gray[(new_img->columns * i) + j].red > max || px_gray[(new_img->columns * i) + j].red < min) { px_new[(new_img->columns * i) + j].red = 0; px_new[(new_img->columns * i) + j].blue = 0; px_new[(new_img->columns * i) + j].green = 0; } else { px_new[(new_img->columns * i) + j].red = px_original[(new_img->columns * i) + j].red; px_new[(new_img->columns * i) + j].blue = px_original[(new_img->columns * i) + j].blue; px_new[(new_img->columns * i) + j].green = px_original[(new_img->columns * i) + j].green; } j++; } i++; } SyncImagePixels(new_img); DestroyImageInfo(new_img_info); return (new_img);}
开发者ID:NIF-au,项目名称:DigitalControlServer,代码行数:71,
示例21: ReadPESImage/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %% %% %% R e a d P E S I m a g e %% %% %% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% ReadPESImage() reads a Brother PES 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 ReadPESImage method is:%% image=ReadPESImage(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 *ReadPESImage(const ImageInfo *image_info,ExceptionInfo *exception){ char filename[MaxTextExtent]; FILE *file; Image *image; ImageInfo *read_info; int delta_x, delta_y, j, unique_file, x, y; MagickBooleanType status; PESBlockInfo blocks[256]; PointInfo *stitches; SegmentInfo bounds; register ssize_t i; size_t number_blocks, number_colors, number_stitches; ssize_t count, offset; unsigned char magick[4], version[4]; /* 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); } /* Verify PES identifier. */ count=ReadBlob(image,4,magick); if ((count != 4) || (LocaleNCompare((char *) magick,"#PES",4) != 0)) ThrowReaderException(CorruptImageError,"ImproperImageHeader"); count=ReadBlob(image,4,version);//.........这里部分代码省略.........
开发者ID:CamiloBenavides,项目名称:SnoutPoint-Web,代码行数:101,
示例22: ShearImage/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %% %% %% S h e a r I m a g e %% %% %% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% ShearImage() creates a new image that is a shear_image copy of an existing% one. Shearing slides one edge of an image along the X or Y axis, creating% a parallelogram. An X direction shear slides an edge along the X axis,% while a Y direction shear slides an edge along the Y axis. The amount of% the shear is controlled by a shear angle. For X direction shears, x_shear% is measured relative to the Y axis, and similarly, for Y direction shears% y_shear is measured relative to the X axis. Empty triangles left over from% shearing the image are filled with the background color defined by member% 'background_color' of the image.. ShearImage() allocates the memory% necessary for the new Image structure and returns a pointer to the new image.%% ShearImage() is based on the paper "A Fast Algorithm for General Raster% Rotatation" by Alan W. Paeth.%% The format of the ShearImage method is:%% Image *ShearImage(const Image *image,const double x_shear,% const double y_shear,ExceptionInfo *exception)%% A description of each parameter follows.%% o image: The image.%% o x_shear, y_shear: Specifies the number of degrees to shear the image.%% o exception: Return any errors or warnings in this structure.%%*/MagickExport Image *ShearImage(const Image *image,const double x_shear, const double y_shear,ExceptionInfo *exception){ Image *integral_image, *shear_image; long x_offset, y_offset; PointInfo shear; RectangleInfo border_info; unsigned long y_width; 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); if ((x_shear != 0.0) && (fmod(x_shear,90.0) == 0.0)) ThrowImageException(ImageError,"AngleIsDiscontinuous"); if ((y_shear != 0.0) && (fmod(y_shear,90.0) == 0.0)) ThrowImageException(ImageError,"AngleIsDiscontinuous"); /* Initialize shear angle. */ integral_image=CloneImage(image,0,0,MagickTrue,exception); if (integral_image == (Image *) NULL) ThrowImageException(ResourceLimitError,"MemoryAllocationFailed"); shear.x=(-tan(DegreesToRadians(x_shear))); shear.y=tan(DegreesToRadians(y_shear)); if ((shear.x == 0.0) && (shear.y == 0.0)) return(integral_image); integral_image->storage_class=DirectClass; if (integral_image->matte == MagickFalse) SetImageOpacity(integral_image,OpaqueOpacity); /* Compute image size. */ x_offset=(long) (fabs((double) image->rows*shear.x)+0.5); y_width=(unsigned long) (fabs((double) image->rows*shear.x)+image->columns+0.5); y_offset=(long) (fabs((double) y_width*shear.y)+0.5); /* Surround image with border. */ integral_image->border_color=integral_image->background_color; border_info.width=(unsigned long) x_offset; border_info.height=(unsigned long) y_offset; shear_image=BorderImage(integral_image,&border_info,exception); if (shear_image == (Image *) NULL) ThrowImageException(ResourceLimitError,"MemoryAllocationFailed"); integral_image=DestroyImage(integral_image);//.........这里部分代码省略.........
开发者ID:miettal,项目名称:armadillo420_standard,代码行数:101,
示例23: mainint main(int ac, char **av){ char *image_path; char *image_name; RectangleInfo *portion; struct dirent **names; int nb; int i = 0; int j = 0; Image *img; Image *img_channel;Image *img_tmp; ac = ac; InitializeMagick("./"); portion = malloc(sizeof(*portion)); portion->width = 5538 - 3602; portion->height = 1523; portion->x = 3602; portion->y = 0; nb = scandir(av[1], &names, NULL, versionsort); while (i < nb) { if (check_extension(names[i]->d_name, ".jpeg")) { printf("/rImage => %i", j); fflush(stdout); asprintf(&image_path, "%s/%s", av[1], names[i]->d_name); if ((img = get_image_from_path(image_path)) == NULL) printf("Failed to load the image from disk!/n"); /* asprintf(&image_name, "%i_rgb", j); img = crop_image_from_path(image_path, portion); dump_image(img, "/media/Data/histology/brain_2", image_name, "jpeg"); free(image_name); */ if ((img_channel = get_red_channe_image(img)) == NULL) printf("Filed to extract the red channel from the image"); asprintf(&image_name, "%i_r", j); dump_image(img_channel, "/media/Data/histology/brain_1_r", image_name, "jpeg"); DestroyImage(img_channel); free(image_name); if ((img_channel = get_green_channe_image(img)) == NULL) printf("Filed to extract the green channel from the image"); asprintf(&image_name, "%i_g", j); dump_image(img_channel, "/media/Data/histology/brain_1_g", image_name, "jpeg"); free(image_name); DestroyImage(img_channel); if ((img_channel = get_blue_channe_image(img)) == NULL) printf("Filed to extract the blue channel from the image"); asprintf(&image_name, "%i_b", j); dump_image(img_channel, "/media/Data/histology/brain_1_b", image_name, "jpeg"); free(image_name); DestroyImage(img_channel); if ((img_tmp = apply_green_contrast(img, 0, 100)) == NULL) printf("Filed to extract the - channel from the image"); asprintf(&image_name, "%i_gr", j); dump_image(img_tmp, "/media/Data/histology/brain_1_gr", image_name, "jpeg"); free(image_name);/* DestroyImage(img_channel); */ if ((img_channel = get_green_grayscale_image(img_tmp)) == NULL) printf("Filed to extract the - channel from the image"); asprintf(&image_name, "%i_g", j); dump_image(img_channel, "/media/Data/histology/brain_1_gr", image_name, "jpeg"); free(image_name); DestroyImage(img_tmp); img_tmp = img_channel; if ((img_channel = substract_grayscale_to_original(img, img_tmp, 20, 255)) == NULL) printf("Filed to extract the - channel from the image"); asprintf(&image_name, "%i_final", j); dump_image(img_channel, "/media/Data/histology/brain_1_gr", image_name, "jpeg"); free(image_name); DestroyImage(img_channel); DestroyImage(img_tmp); DestroyImage(img); free(image_path); j++; } i++; } printf("/n"); return (0);}
开发者ID:NIF-au,项目名称:DigitalControlServer,代码行数:98,
示例24: RotateImage//.........这里部分代码省略.........% o image: The image.%% o degrees: Specifies the number of degrees to rotate the image.%% o exception: Return any errors or warnings in this structure.%%*/MagickExport Image *RotateImage(const Image *image,const double degrees, ExceptionInfo *exception){ Image *integral_image, *rotate_image; long x_offset, y_offset; MagickRealType angle; PointInfo shear; RectangleInfo border_info; unsigned long height, rotations, width, y_width; /* Adjust rotation angle. */ 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); angle=degrees; while (angle < -45.0) angle+=360.0; for (rotations=0; angle > 45.0; rotations++) angle-=90.0; rotations%=4; /* Calculate shear equations. */ integral_image=IntegralRotateImage(image,rotations,exception); if (integral_image == (Image *) NULL) ThrowImageException(ResourceLimitError,"MemoryAllocationFailed"); shear.x=(-tan((double) DegreesToRadians(angle)/2.0)); shear.y=sin((double) DegreesToRadians(angle)); if ((shear.x == 0.0) && (shear.y == 0.0)) return(integral_image); integral_image->storage_class=DirectClass; if (integral_image->matte == MagickFalse) SetImageOpacity(integral_image,OpaqueOpacity); /* Compute image size. */ width=image->columns; height=image->rows; if ((rotations == 1) || (rotations == 3)) { width=image->rows; height=image->columns; } x_offset=(long) (fabs(2.25*(double) height*shear.y)+0.5); y_width=(unsigned long) (fabs((double) height*shear.x)+width+0.5); y_offset=(long) (fabs((double) y_width*shear.y)+0.5); /* Surround image with a border. */ integral_image->border_color=integral_image->background_color; border_info.width=(unsigned long) x_offset; border_info.height=(unsigned long) y_offset; rotate_image=BorderImage(integral_image,&border_info,exception); integral_image=DestroyImage(integral_image); if (rotate_image == (Image *) NULL) ThrowImageException(ResourceLimitError,"MemoryAllocationFailed"); /* Rotate the image. */ XShearImage(rotate_image,shear.x,width,height,x_offset, ((long) rotate_image->rows-height)/2); YShearImage(rotate_image,shear.y,y_width,height, ((long) rotate_image->columns-y_width)/2,y_offset); XShearImage(rotate_image,shear.x,y_width,rotate_image->rows, ((long) rotate_image->columns-y_width)/2,0); CropToFitImage(&rotate_image,shear.x,shear.y,(MagickRealType) width, (MagickRealType) height,MagickTrue,exception); rotate_image->page.width=0; rotate_image->page.height=0; return(rotate_image);}
开发者ID:miettal,项目名称:armadillo420_standard,代码行数:101,
示例25: WriteTHUMBNAILImage/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %% %% %% W r i t e T H U M B N A I L I m a g e %% %% %% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% WriteTHUMBNAILImage() extracts the EXIF thumbnail image and writes it.%% The format of the WriteTHUMBNAILImage method is:%% MagickBooleanType WriteTHUMBNAILImage(const ImageInfo *image_info,% Image *image)%% A description of each parameter follows.%% o image_info: the image info.%% o image: The image.%*/static MagickBooleanType WriteTHUMBNAILImage(const ImageInfo *image_info, Image *image){ const char *property; const StringInfo *profile; Image *thumbnail_image; ImageInfo *write_info; MagickBooleanType status; register long i; ssize_t offset; size_t length; unsigned char magick[MaxTextExtent]; profile=GetImageProfile(image,"exif"); if (profile == (const StringInfo *) NULL) ThrowWriterException(CoderError,"ImageDoesNotHaveAThumbnail"); property=GetImageProperty(image,"exif:JPEGInterchangeFormat"); if (property == (const char *) NULL) ThrowWriterException(CoderError,"ImageDoesNotHaveAThumbnail"); offset=(ssize_t) StringToLong(property); property=GetImageProperty(image,"exif:JPEGInterchangeFormatLength"); if (property == (const char *) NULL) ThrowWriterException(CoderError,"ImageDoesNotHaveAThumbnail"); length=(size_t) StringToLong(property); (void) ResetMagickMemory(magick,0,sizeof(magick)); for (i=0; i < (long) length; i++) { magick[0]=magick[1]; magick[1]=magick[2]; magick[2]=GetStringInfoDatum(profile)[offset+i]; if (memcmp(magick,"/377/330/377",3) == 0) break; } thumbnail_image=BlobToImage(image_info,GetStringInfoDatum(profile)+offset+i-2, length,&image->exception); if (thumbnail_image == (Image *) NULL) return(MagickFalse); (void) SetImageType(thumbnail_image,thumbnail_image->matte == MagickFalse ? TrueColorType : TrueColorMatteType); (void) CopyMagickString(thumbnail_image->filename,image->filename, MaxTextExtent); write_info=CloneImageInfo(image_info); (void) SetImageInfo(write_info,1,&image->exception); if (LocaleCompare(write_info->magick,"THUMBNAIL") == 0) (void) FormatMagickString(thumbnail_image->filename,MaxTextExtent, "miff:%s",write_info->filename); status=WriteImage(write_info,thumbnail_image); thumbnail_image=DestroyImage(thumbnail_image); write_info=DestroyImageInfo(write_info); return(status);}
开发者ID:0xPr0xy,项目名称:ImageMagick,代码行数:93,
示例26: ReadRAWImage/*%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %% %% %% R e a d R A W I m a g e %% %% %% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% ReadRAWImage() reads an image of raw samples 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 ReadRAWImage method is:%% Image *ReadRAWImage(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 *ReadRAWImage(const ImageInfo *image_info,ExceptionInfo *exception){ Image *canvas_image, *image; MagickBooleanType status; MagickOffsetType scene; QuantumInfo *quantum_info; QuantumType quantum_type; size_t length; ssize_t count, y; unsigned char *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); if ((image->columns == 0) || (image->rows == 0)) ThrowReaderException(OptionError,"MustSpecifyImageSize"); status=OpenBlob(image_info,image,ReadBinaryBlobMode,exception); if (status == MagickFalse) { image=DestroyImageList(image); return((Image *) NULL); } if (DiscardBlobBytes(image,image->offset) == MagickFalse) ThrowFileException(exception,CorruptImageError,"UnexpectedEndOfFile", image->filename); /* Create virtual canvas to support cropping (i.e. image.gray[100x100+10+20]). */ canvas_image=CloneImage(image,image->extract_info.width,1,MagickFalse, exception); (void) SetImageVirtualPixelMethod(canvas_image,BlackVirtualPixelMethod); quantum_type=GrayQuantum; quantum_info=AcquireQuantumInfo(image_info,canvas_image); if (quantum_info == (QuantumInfo *) NULL) ThrowReaderException(ResourceLimitError,"MemoryAllocationFailed"); pixels=GetQuantumPixels(quantum_info); if (image_info->number_scenes != 0) while (image->scene < image_info->scene) { /* Skip to next image. */ image->scene++; length=GetQuantumExtent(canvas_image,quantum_info,quantum_type); for (y=0; y < (ssize_t) image->rows; y++) { count=ReadBlob(image,length,pixels); if (count != (ssize_t) length) break;//.........这里部分代码省略.........
开发者ID:divyasnair123,项目名称:vegetable_store,代码行数:101,
示例27: FloodfillPaintImage//.........这里部分代码省略......... x, x1, x2, y; /* Check boundary conditions. */ assert(image != (Image *) NULL); assert(image->signature == MagickSignature); if (image->debug != MagickFalse) (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename); assert(draw_info != (DrawInfo *) NULL); assert(draw_info->signature == MagickSignature); if ((x_offset < 0) || (x_offset >= (ssize_t) image->columns)) return(MagickFalse); if ((y_offset < 0) || (y_offset >= (ssize_t) image->rows)) return(MagickFalse); if (SetImageStorageClass(image,DirectClass) == MagickFalse) return(MagickFalse); if (image->matte == MagickFalse) (void) SetImageAlphaChannel(image,OpaqueAlphaChannel); /* Set floodfill state. */ floodplane_image=CloneImage(image,0,0,MagickTrue,&image->exception); if (floodplane_image == (Image *) NULL) return(MagickFalse); (void) SetImageAlphaChannel(floodplane_image,OpaqueAlphaChannel); segment_stack=(SegmentInfo *) AcquireQuantumMemory(MaxStacksize, sizeof(*segment_stack)); if (segment_stack == (SegmentInfo *) NULL) { floodplane_image=DestroyImage(floodplane_image); ThrowBinaryException(ResourceLimitError,"MemoryAllocationFailed", image->filename); } /* Push initial segment on stack. */ exception=(&image->exception); x=x_offset; y=y_offset; start=0; s=segment_stack; PushSegmentStack(y,x,x,1); PushSegmentStack(y+1,x,x,-1); GetMagickPixelPacket(image,&fill); GetMagickPixelPacket(image,&pixel); image_view=AcquireCacheView(image); floodplane_view=AcquireCacheView(floodplane_image); while (s > segment_stack) { register const IndexPacket *restrict indexes; register const PixelPacket *restrict p; register ssize_t x; register PixelPacket *restrict q; /*
开发者ID:271845221,项目名称:Android-ImageMagick,代码行数:67,
|