資源簡介
壓縮包包含了圖片讀取、算法計算、圖像輸出,下載后可以直接執行

代碼片段和文件信息
#include?
#include?
#include?
#include?“bmpfile.h“
//Open?the?BMP?input?file
FILE?*BMP_InputOpen(char?*name){
??FILE?*bmp_file?=?fopen(name“rb“);
??if(!bmp_file){
????printf(“ERROR:?could?not?open?%s?for?reading\n“name);
??}
??else
????return?bmp_file;
}
//Open?the?BMP?output?file
FILE?*BMP_OutputOpen(char?*name){
??FILE?*bmp_file?=?fopen(name“wb“);
??if(!bmp_file){
????printf(“ERROR:?could?not?open?%s?for?writing\n“name);
??}
??else
????return?bmp_file;
}
//Close?BMP?file
int?BMP_Close(FILE?*bmp_file){
??if(bmp_file){
????fclose(bmp_file);
????return?0;
??}
??else{
????printf(“ERROR:?could?not?close?%s\n“bmp_file);
????return?1;
??}
}
//Read?the?BMP?file?header
int?BMP_Read_FileHeader(FILE?*bmp_file?BMPHeader?*file_header){
??if(!bmp_file){
????printf(“ERROR:?Can‘t?read?the?image?file\n“);
????return?1;
??}
??if(!fread(file_header114bmp_file)){
????printf(“ERROR:?Failed?to?read?the?image?file?header?\n“);
????return?1;
??}
??else
????return?0;
}
//Read?the?BMP?data?header
int?BMP_Read_ImageHeader(FILE?*bmp_file?BMPImageHeader?*image_header){
??if(!bmp_file){
????printf(“ERROR:?Can‘t?read?the?image?file\n“);
????return?1;
??}
??if(!fread(image_header140bmp_file)){
????printf(“ERROR:?Failed?to?read?the?image?data?header?\n“);
????return?1;
??}
??else
????return?0;
}
//Read?the?BMP?image?data
int?BMP_Read_Image(FILE?*bmp_file?unsigned?char?*data?int?size){
???if(!bmp_file){
????printf(“ERROR:?Can‘t?read?the?image?file\n“);
????return?1;
??}
???if(!fread(data1sizebmp_file)){
??????printf(“ERROR:?Can‘t?read?the?image?data\n“);
????return?1;
???}
???else{
?????return?0;
???}
}
//Blank?BMP?Image
BMPImage?*BMP_CreateBlank(void){
??BMPImage?*bitmap?=?NULL;
??BMPHeader?*file_header?=?NULL;
??BMPImageHeader?*image_header?=?NULL;
??unsigned?char?*data;
??file_header?=?(BMPHeader?*)?calloc(sizeof(BMPHeader)1);
??if(!file_header){
????printf(“ERROR:?Can‘t?create?file?header?in?blank?BMP\n“);
????return?NULL;
??}
??image_header?=?(BMPImageHeader?*)?calloc(sizeof(BMPImageHeader)1);
??if(!image_header){
????printf(“ERROR:?Can‘t?create?image?header?in?blank?BMP\n“);
????if(file_header)?free(file_header);
????return?NULL;
??}
??bitmap?=?(BMPImage?*)?malloc(sizeof(BMPImage));
??if(!bitmap){
????printf(“ERROR:?Can‘t?create?image?data?in?blank?BMP\n“);
????if(file_header)?free(file_header);
????if(image_header)?free(image_header);
????return?NULL;
??}
??
??data?=?(unsigned?char?*)?malloc(MAX_COLS*MAX_ROWS*3);
??if(!data){
????printf(“ERROR:?Allocate?image?temp?space\n“);
????if(file_header)?free(file_header);
????if(image_header)?free(image_header);
????if(bitmap)?free(bitmap);
????return?NULL;
??}
??
??bitmap->file_header?=?file_header;
??bitmap->image_header?=?image_header;
??bitmap->data?=?data;
??//Initialize?to?0
??int?i?j;
??for(i?=?0;?i?????for(j=?0;?j?
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????文件??????40960??2016-04-26?11:06??otsu_c\Debug\otsu_c.exe
?????文件?????306688??2016-04-26?11:06??otsu_c\Debug\otsu_c.ilk
?????文件?????461824??2016-04-26?11:06??otsu_c\Debug\otsu_c.pdb
?????文件???????9763??2016-04-11?13:55??otsu_c\otsu_c\bmpfile.cpp
?????文件???????1465??2016-04-11?13:47??otsu_c\otsu_c\bmpfile.h
?????文件??????26180??2016-04-11?13:55??otsu_c\otsu_c\Debug\bmpfile.obj
?????文件???????1038??2016-04-26?11:06??otsu_c\otsu_c\Debug\cl.command.1.tlog
?????文件???????3942??2016-04-26?11:06??otsu_c\otsu_c\Debug\CL.read.1.tlog
?????文件????????646??2016-04-26?11:06??otsu_c\otsu_c\Debug\CL.write.1.tlog
?????文件??????????2??2016-04-26?11:06??otsu_c\otsu_c\Debug\li
?????文件??????????2??2016-04-26?11:06??otsu_c\otsu_c\Debug\li
?????文件??????????2??2016-04-26?11:06??otsu_c\otsu_c\Debug\li
?????文件??????????2??2016-04-26?11:06??otsu_c\otsu_c\Debug\li
?????文件??????????2??2016-04-26?11:06??otsu_c\otsu_c\Debug\li
?????文件??????????2??2016-04-26?11:06??otsu_c\otsu_c\Debug\li
?????文件??????????2??2016-04-26?11:06??otsu_c\otsu_c\Debug\li
?????文件??????????2??2016-04-26?11:06??otsu_c\otsu_c\Debug\li
?????文件??????????2??2016-04-26?11:06??otsu_c\otsu_c\Debug\li
?????文件??????????2??2016-04-26?11:06??otsu_c\otsu_c\Debug\li
?????文件??????????2??2016-04-26?11:06??otsu_c\otsu_c\Debug\li
?????文件??????????2??2016-04-26?11:06??otsu_c\otsu_c\Debug\li
?????文件??????????2??2016-04-26?11:06??otsu_c\otsu_c\Debug\li
?????文件??????????2??2016-04-26?11:06??otsu_c\otsu_c\Debug\li
?????文件??????????2??2016-04-26?11:06??otsu_c\otsu_c\Debug\li
?????文件??????????2??2016-04-26?11:06??otsu_c\otsu_c\Debug\li
?????文件???????1034??2016-04-26?11:06??otsu_c\otsu_c\Debug\li
?????文件???????2380??2016-04-26?11:06??otsu_c\otsu_c\Debug\li
?????文件????????308??2016-04-26?11:06??otsu_c\otsu_c\Debug\li
?????文件??????12623??2016-04-26?11:06??otsu_c\otsu_c\Debug\otsu.obj
?????文件?????????43??2016-04-26?11:06??otsu_c\otsu_c\Debug\otsu_c.lastbuildstate
............此處省略20個文件信息
- 上一篇:Apriori算法與改進算法代碼
- 下一篇:VHDL FPGA 數控振蕩器NCO
評論
共有 條評論