⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 bmp.cpp

📁 图像处理软件,功能比较基础
💻 CPP
字号:
#include <stdio.h>

unsigned short	id;				//the characters identifying the bitmap. the following entries are possible
unsigned long	file_size;		//complete file size in bytes
unsigned long	reserved;		//reserved for later use
unsigned long	bitmap_head_size;	//length of the bitmap info header used to describe the bitmap colors, compression
unsigned long	width;				//horizontal width of bitmap in pixels
unsigned long	height;				//vertical height of bitmap in pixels
unsigned short	planes;			//number of planes in this bitmap
unsigned short	bits_per_pixels;	//
unsigned long	compression;		//compression specifications
unsigned long	bitmap_data_size;	//size of the bitmap data in bytes. this number must be rounded to the next 4 byte boundary
unsigned long	hresolution;	//horizontal resolution expressed in pixel per meter
unsigned long	vresolution;	//vertical resolution expressed in pixels per meter
unsigned long	colors;			//number of colors used by this bitmap. for a 8-bit / pixel bitmap this will be 100h or 256
unsigned long	important_colors;	//number of important colors

unsigned char **ReadBMPFile(char *sfile,short *row,short *col)
{
	FILE *fp;
	short i;
	short skip,linebytes;

	unsigned char rgbBlue[256];
	unsigned char rgbRed[256];
	unsigned char rgbGreen[256];
	unsigned char rgbReserve[256];
	unsigned char **image;

	fp = fopen(sfile,"rb");
	if(fp==NULL) return NULL;
	
	fread(&id,2,1,fp);
	fread(&file_size,4,1,fp);
	fread(&reserved,4,1,fp);
	fread(&bitmap_head_size,4,1,fp);
	fread(&width,4,1,fp);
	fread(&height,4,1,fp);
	fread(&planes,4,1,fp);
	fread(&bits_per_pixels,4,1,fp);
	fread(&compression,4,1,fp);
	fread(&bitmap_data_size,4,1,fp);
	fread(&hresolution,4,1,fp);
	fread(&vresolution,4,1,fp);
	fread(&colors,4,1,fp);
	fread(&important_colors,4,1,fp);

//	if(planes!=8) return NULL;
	for(i=0;i<256;i++) {
		fread(&rgbBlue[i],1,1,fp);
		fread(&rgbGreen[i],1,1,fp);
		fread(&rgbRed[i],1,1,fp);
		fread(&rgbReserved[i],1,1,fp);
	}

	image = (unsigned char **)calloc(height,1);
	if(image==NULL) return NULL;
	for(i=0; i<height; i++) {
		image[i] = (unsigned char *)calloc(width,1);
		if(image[i]==NULL) return NULL;
	}
	
	if(planes==8) {
		switch(compression) {
		case 0:
			skip = (4-width%4)%4;
			linebytes = ((width+3)/4)*4;

			

			break;
		case 1: 
//			break;
		case 2: 
//			break;
		case 3:
//			break;
		default: return NULL;
			
		}
	}








}






⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -