?? export.c
字號:
/*############################################################################# * 文件名:export.c * 功能: 指紋圖像輸出保存 * modified by PRTsinghua@hotmail.com#############################################################################*/#include "import.h"#include <stdio.h>#include <magick/api.h>/****************************************************************************** * 功能:將一個指紋圖像輸出到一個文件,文件的格式由文件的擴展名決定 * 參數:filename 將要保存圖像的文件名 * image 將要導出的圖像 * 返回:錯誤代碼******************************************************************************/FvsError_t FvsImageExport(const FvsImage_t image, const FvsString_t filename){ ExceptionInfo exception; Image* magicimage; ImageInfo* magicinfo; FvsError_t ret = FvsOK; FvsByte_t* buffer; FvsInt_t pitch; FvsInt_t height; FvsInt_t width; FvsInt_t i; /* 從輸入圖像中獲取 buffer, size 和 pitch */ buffer = ImageGetBuffer(image); pitch = ImageGetPitch(image); height = ImageGetHeight(image); width = ImageGetWidth(image); /* 初始化ImageMagick環境 */ InitializeMagick("."); GetExceptionInfo(&exception); /* 創建一個空的imageinfo */ magicinfo = CloneImageInfo((ImageInfo*)NULL); magicinfo->depth = 8; /* 創建圖像 */ magicimage = ConstituteImage(width, height, "I", CharPixel, buffer, &exception); if (exception.severity!=UndefinedException) CatchException(&exception); if (magicimage!=(Image*)NULL) { /* 拷貝數據 */ for (i=0; i<height; i++) { ImportImagePixels(magicimage, 0, i, width, 1, "I", CharPixel, buffer+i*pitch); } /* 保存圖像到文件 */ (void)strcpy(magicimage->filename, filename); magicimage->colorspace = GRAYColorspace; magicimage->depth = 8; WriteImage(magicinfo, magicimage); DestroyImage(magicimage); } else ret = FvsFailure; /* 清理 */ DestroyImageInfo(magicinfo); DestroyExceptionInfo(&exception); DestroyMagick(); return ret;}#if 0/* The WAND interface is pretty buggy... use the old API *//****************************************************************************** * 功能:將一個指紋圖像輸出到一個文件,文件的格式由文件的擴展名決定 * 參數:filename 將要保存圖像的文件名 * image 將要導出的圖像 * 返回:錯誤代碼******************************************************************************/FvsError_t FvsImageExport(const FvsImage_t image, const FvsString_t filename){ MagickWand* wand; FvsByte_t* buffer; FvsByte_t* out; FvsInt_t pitch; FvsInt_t height; FvsInt_t width; FvsError_t ret = FvsOK; FvsInt_t i; /* 初始化Magick */ wand = NewMagickWand(); if (wand!=NULL) { /* 提取參數 */ buffer = ImageGetBuffer(image); width = ImageGetWidth(image); height = ImageGetHeight(image); pitch = ImageGetPitch(image); /* 為像素申請新的內存 */ out = (FvsByte_t*)malloc(width*height); if (out!=NULL) { for (i=0; i<height; i++) memcpy(out+i*width, buffer+i*pitch, width); /* 輸出的圖像數據現在在連續的緩沖區中 */ MagickSetSize(wand, width, height); MagickSetImagePixels(wand, 0, 0, width, height, "I", CharPixel, out); /* 寫數據 */ MagickWriteImage(wand, filename); free(out); } else ret = FvsMemory; /* 清理 */ DestroyMagickWand(wand); } else ret = FvsMemory; return ret;}#endif
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -