C语言 BMP图片的旋转与缩放

目录

一、bmp文件头、文件信息头、位图实际数据的数据结构定义 

二、源BMP文件信息的读取

三、实际位图数据的旋转、缩放操作

四、生成转换过后的新位图文件


 

#include <stdlib.h>

#ifndef PHOTODEAL_H
#define PHOTODEAL_H

#pragma pack(1)
typedef struct tagBmpFileHeader{
	unsigned short bfType;
	unsigned long bfSize;
	unsigned short bfReserved1;
	unsigned short bfReserved2;
	unsigned long bfOffBits;
}BMPFILEHEADER;
typedef struct tagBmpInfoHeader{
	unsigned long biSize;
	long biWidth;
	long biHeight;
	unsigned short biPlanes;
	unsigned short biBitCount;
	unsigned long biCompression;
	unsigned long biSizeImage;
	long biXPelsPerMeter;
	long biYPelsPerMeter;
	unsigned long biClrUsed;
	unsigned long biClrImportant;
}BMPINFOHEADER;
typedef struct tagPalEn{
	unsigned char rgbRed;
	unsigned char rgbGreen;
	unsigned char rgbBlue;
	unsigned char rgbFlags;
}PALEN;
typedef struct tagPalette{
	unsigned short palVersion;
	unsigned short palNumEntries;
	PALEN palPalEN[1];
}PALETTE;

#pragma pack()


void OnLoad(char* path, BMPFILEHEADER* srcBmpFileHeader, BMPINFOHEADER* srcBmpInfoHeader, unsigned char** srcBmpData);
void WriteData(char* path, BMPFILEHEADER* desBmpFileHeader, BMPINFOHEADER* desBmpInfoHeader, unsigned char* desBmpData);
void RotateBmp(BMPFILEHEADER* srcBmpFileHeader, BMPINFOHEADER* srcBmpInfoHeader, BMPFILEHEADER* desBmpFileHeader, BMPINFOHEADER* desBmpInfoHeader, unsigned char** srcBmpData, /*double dAngle,*/ unsigned char* desBmpData);
void ZoomBmp(BMPFILEHEADER* srcBmpFileHeader, BMPINFOHEADER* srcBmpInfoHeader, BMPFILEHEADER* desBmpFileHeader, BMPINFOHEADER* desBmpInfoHeader,
	unsigned char* srcBmpData, unsigned char** desBmpData /*, int zmHeight, int zmWidth, , double dxRate, double dyRate*/);

void start();
//void suofang();





#endif


#define _CRT_SECURE_NO_WARNINGS
#include "PHOTODEAL.h"
#include <stdio.h>
//#include <stdlib.h>
#include <string.h>
#include <math.h>

BMPFILEHEADER srcBmpFileHeader, desBmpFileHeader;
BMPINFOHEADER srcBmpInfoHeader, desBmpInfoHeader;
unsigned char* srcBmpData = NULL;
unsigned char* desBmpData = NULL;

void OnLoad(char* path, BMPFILEHEADER* srcBmpFileHeader, BMPINFOHEADER* srcBmpInfoHeader, unsigned char** srcBmpData){
	FILE* pFile;
	unsigned char* tempData
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值