4,445
社区成员
发帖
与我相关
我的任务
分享
#include <iostream>
#include <fstream>
using namespace std;
#define N 480 // 原始宽度
#define I 245 // 改变后宽度
#define M 640 // 原始长度
unsigned char b[960][1920];
int main()
{
unsigned char a[54];
unsigned char zhongzhi;
unsigned char *pt1;
float ni=(float)N/(float)I; // N/I的值
int m=(int)((float)M/ni)/1+1; // 改变后的长度值,包括边缘
float py1,py2,py3,hx1,hx2,hx3; //竖着与横着分量的值,应该小于ni
float hx4,hx5; //
int y1,y2,x1,x2; //取整的值,用来定位新像素占原像素的位置。
ifstream infile("11.bmp",ios::binary); //打开11.bmp。
if(!infile)
{cout<<"open 11.bmp error!"<<endl;
abort();
}
infile.read((char *)a,54); //读取文件头存入数组a中。
infile.seekg(54); //定位
infile.read((char *)b,921600); //读取数据存入二维数组b中。
infile.close(); //关闭
int i;
int j;
ofstream outfile("12.bmp",ios::binary); //打开12.bmp写数据
if(!outfile)
{cout<<"open 12.bmp error!"<<endl;
abort();
}