VC实现BMP图像文件的读取、显示与存储

一、创建工程

1、创建AppWizard文件
vc-001
2、选择基本对话框
vc-002
3、新建一个按钮
vc-003
4、设置Button属性
ID设置为ID_OPEN,标题是“打开图像”
vc-004
5、依次设置其他4个按钮
vc-005
函数名称,0nc2g()
明:将P格式的彩色图像转化为256级灰度图像。
uold CColor2Gr ayD1g: :0nC2g()
11 T0D0: dd your control notification handler code here
1/如果图像数据的指针为空则返回
if (1p8itnap–0) return:
//定义图像的横。枞坐标(循环变量)以及当前像素点的位置
int x.9.:
//用于保存变换后的灰度值
BYTE Point;
//循环过程,对rgo图像中的每个像素进行灰度变换
for(y- BnyeotHeight :y**)
for(x= 0;x<nvidth;x**)
p-x-2+

y*nByteMidth;
Point-(BYTE)(O.31-(float )1pBits[p+2]+0.59*(float)1pBits[p+1]+8.1+(float)1pBits[p]);
1pBits[p+2]-Point:
1pBits[p-1j-Point:
IpBitsip]-Point;
11显示变换后的灰度图像
Mnd2 .Shoul nage(nvidth ,nHeight .1pBits);

猜你喜欢

转载自blog.csdn.net/Prototype___/article/details/123961664
今日推荐