资源简介
C语言实现图像的旋转缩放裁切,此为本人图像处理与成像制导的作业,完全可以实现,并且附有详细的实验报告。旋转可以自己输入旋转的角度,切割可以输入切割的大小,缩放也是任意比例的缩放,可以自己输入比例系数。

代码片段和文件信息
#include
#include
#include
#include
#include
#include
#include “stdafx.h“
#define pi 3.1415
float zoomnumber=1; //初始放大倍数默认为1
unsigned char *pBmpBuf; //读入图像数据的指针
unsigned char *pNewBmpBuf;
int bmpWidth; //图像的宽
int bmpHeight; //图像的高
RGBQUAD *pColorTable; //颜色表指针
int biBitCount; //图像类型,每像素位数
int newBmpWidth; //变化后图像的宽
int newBmpHeight; //变化后图像的高
int newLineByte; //变化后图像数据每行的字节数
unsigned char * rotate(unsigned char *pImage int width int height int biBitCount float angle);
void crop(long Widthunsigned char *pImagelong x1long x2long y1long y2);
void ShowImage(char * bmpName);
int ReadBmp(const char* bmpName)
{FILE *fp=fopen(bmpName“rb“);
if(fp==0)
{ printf(“打开文件失败\n“);
return 0;
}
fseek(fpsizeof(BITMAPFILEHEADER)0);
BITMAPINFOHEADER head;
fread(&headsizeof(BITMAPINFOHEADER)1fp);
bmpWidth = head.biWidth;
bmpHeight = head.biHeight;
biBitCount = head.biBitCount;
int lineByte = (bmpWidth *biBitCount/8+3)/4*4;//计算图像每行像素所占的字节数
if(biBitCount == 8)
{ pColorTable = new RGBQUAD[256];
fread(pColorTablesizeof(RGBQUAD)256fp);
}
pBmpBuf = new unsigned char [lineByte *bmpHeight];
fread(pBmpBuf1lineByte *bmpHeightfp);
return 1;
}
/****************************************************************************
*函数名称: saveBmp()
*函数参数: const char *bmpName 写入bmp格式文件的名称及路径
unsigned char *imgBuf 待存盘的位图数据
int width 以像素为单位待存盘的位图宽
int height 以像素为单位待存盘的位图高
int biBitCount 每个像素占的位数
RGBQUAD *pColorTable 颜色表指针
*函数返回值:0为失败 1为成功
*函数描述:给定写入bmp文件的名称和路径,写入图像的位图数据,宽,高,写进文件中
***************************************************************************/
int SaveBmp(const char* bmpNameunsigned char *imgBufint widthint heightint biBitCountRGBQUAD *pColorTable)
{if(!imgBuf)//imgBuf 待存盘的位图数据
return 0;
int colorTablesize = 0;
if(biBitCount == 8)
colorTablesize =1024;
int lineByte = (width * biBitCount/8+3)/4*4;
FILE *fp = fopen(bmpName“wb“);
if(fp == 0) return 0;
BITMAPFILEHEADER fileHead;
fileHead.bfType= 0x4d42;
fileHead.bfSize = sizeof(BITMAPFILEHEADER)+sizeof(BITMAPINFOHEADER) + colorTablesize + lineByte *height;
fileHead.bfReserved1 = 0;
fileHead.bfReserved2 = 0;
fileHead.bfOffBits = 54 +colorTablesize;
fwrite(&fileHeadsizeof(BITMAPFILEHEADER)1fp);
BITMAPINFOHEADER head;
head.biBitCount = biBitCount;
head.biClrImportant = 0;
head.biClrUsed = 0;
head.biCompression = 0;
head.biHeight = height;
head.biPlanes =1;
head.biSize = 40;
head.biSizeImage = lineByte *height;
head.biWidth = width;
head.biXPelsPerMeter = 0;
head.biYPelsPerMeter = 0;
fwrite(&headsizeof(BITMAPINFOHEADER)1fp);
if(biBitCount == 8)
fwrite(pColorTablesizeof(RGBQUAD)256fp);
fwrite(imgBufheight * lineByte1fp);
fclose(fp);
return 1;
}
void PrintMenu()
{printf(“ ------选择您的操作------\n“);
printf
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
目录 0 2012-11-29 11:20 C语言实现图像的旋转缩放裁切\
目录 0 2012-11-29 11:20 C语言实现图像的旋转缩放裁切\bmp\
文件 263222 2012-11-24 09:50 C语言实现图像的旋转缩放裁切\bmp\dollar.bmp
文件 65262 2012-11-24 09:50 C语言实现图像的旋转缩放裁切\bmp\dollarcut.bmp
文件 553126 2012-11-24 09:50 C语言实现图像的旋转缩放裁切\bmp\large.bmp
文件 361078 2012-11-24 09:50 C语言实现图像的旋转缩放裁切\bmp\rotate79.bmp
文件 17206 2012-11-24 09:50 C语言实现图像的旋转缩放裁切\bmp\small.bmp
文件 10853 2012-11-24 09:50 C语言实现图像的旋转缩放裁切\main.cpp
文件 233 2012-11-24 09:50 C语言实现图像的旋转缩放裁切\stdafx.h
文件 498 2012-11-24 09:50 C语言实现图像的旋转缩放裁切\targetver.h
文件 705703 2012-11-24 09:50 C语言实现图像的旋转缩放裁切\Wssillustrate.pdf
文件 891 2012-11-24 09:50 C语言实现图像的旋转缩放裁切\wsswork2.sln
文件 3918 2012-11-24 09:50 C语言实现图像的旋转缩放裁切\wsswork2.vcxproj
- 上一篇:用C语言编写的经典小游戏
- 下一篇:php-5.3.5-Win32-VC6-x64
相关资源
- 国际象棋的qt源代码
- C++中头文件与源文件的作用详解
- C++多线程网络编程Socket
- VC++ 多线程文件读写操作
- 利用C++哈希表的方法实现电话号码查
- 移木块游戏,可以自编自玩,vc6.0编写
- C++纯文字DOS超小RPG游戏
- VC++MFC小游戏实例教程(实例)+MFC类库
- 用C语言进行数字图像处理
- 连铸温度场计算程序(C++)
- 6自由度机器人运动学正反解C++程序
- Em算法(使用C++编写)
- libstdc++-4.4.7-4.el6.i686.rpm
- VC++实现CMD命令执行与获得返回信息
- 白话C++(全)
- C++标准库第1、2
- 大数类c++大数类
- C++语言编写串口调试助手
- c++素数筛选法
- C++ mqtt 用法
- 商品库存管理系统 C++ MFC
- c++ 多功能计算器
- C++17 In Detail
- 嵌入式QtC++编程课件
- 颜色识别形状识别STM103嵌入式代码
- c++ 邮件多附件群发
- c++ 透明代理(hookproxy)
- mfc 调用redis
- FTP客户端源码(c++)
- basler相机图像采集和显示
评论
共有 条评论