让我烦了半天的一个小问题,readbmp(filename,bmp &fh,bit&ih)
记住一定要加地址符&,而writebmp是不需要&。
就其原因,对指针的使用和理解不熟悉。
#include<iostream>
#include <cstdio>
#include <cstdlib>
using namespace std;
#pragma pack(push,1)
struct BMPFILEHEADER
{
unsigned short bfType;
unsigned int bfSize;
unsigned short bfReserved1;
unsigned short bfReserved2;
unsigned int bfOffBits;
};
#pragma pack(pop)
struct BITMAPINFOHEADER
{
unsigned long biSize; //本结构所占用字节数 40字节
long biWidth; //位图的宽度,以像素为单位
long biHeight; //位图的高度,以像素为单位
unsigned short biPlanes; //目标设备的级别,必须为1
unsigned short biBitCount; //每个像素所需的位数,必须是1(双色)、
//4(16色)、8(256色)或24(真彩色)之一
unsigned long biCompression; //位图压缩类型,必须是 0(BI_RGB不压缩)、
//1(BI_RLE8压缩类型)