将灰度图像读取到数组中,然后再绘制的屏幕上
2012-09-14 16:32
267 查看
char p1[2500]; //50*50
BOOL ReadGrayImg(CString path, char* pFlashImg) { memset(pFlashImg,0,sizeof(char)*2500); CImage Img; Img.Load(path); int nWidth = Img.GetWidth(); int nHeight = Img.GetHeight(); for(int i = 0; i < nHeight; i++) { for(int j = 0; j < nWidth; j++) { pFlashImg[i*nWidth+j]=Img.GetPixel(i,j); } } return TRUE; }
void CGdiTestDlg::MyDraw(){ int nWidth = 50; int nHeight = 50; int nValue=0; CDC* pDC=GetDC(); for(int i = 0; i < nHeight; i++) { for(int j = 0; j < nWidth; j++) { nValue=p1[i*nWidth+j]; pDC->SetPixel(i,j,RGB(nValue,nValue,nValue)); } } ReleaseDC(pDC); }
RGB() 为宏 可以将参数转换成COLORREF格式
相关文章推荐
- 使用jQuery匹配文档中所有的li元素,返回一个jQuery对象,然后通过数组下标的方式读取jQuery集合中第1个DOM元素,此时返回的是DOM对象,然后调用DOM属性innerHTML,读取该元素 包含的文本信息
- [计算机视觉] CImg库绘制图像灰度直方图
- Python读取MRI并显示为灰度图像实例代码
- [Python]图像处理日记——第一天(如何查询图片属性,数组与RGB,灰度图像如何互换)
- Python中对文件夹下的特定格式图像全部读取并转化为数组保存(也可转化为txt文件)
- 读取并在屏幕上显示24位bmp图像
- Qt实现读取图像并且窗口加滑动条,点击图像在鼠标点击处绘制小图像
- 【图像处理】01 读取像素数组到数组
- CImage图像得到BYTE数组数据 - 8bit灰度图像
- Fortran 从文件中读取数据放入数组中,然后对其进行bubble sort,使用了一些方法防止人为错误
- 利用数组操作实现灰度图像放大两倍(C++&opencv)
- Python图像灰度变换及图像数组操作
- python-opencv笔记 图像的读取和简单几何图形绘制
- 利用Matlab绘制图像中的某一行或者某一列的灰度曲线
- OpenCV读取yuv420对应的灰度图像
- 绘制灰度图像
- OpenCV应用笔记】(彩色/灰度)图像像素值读取并保存到txt文件
- 【OpenCV应用笔记】(彩色/灰度)图像像素值读取并保存到txt文件
- 图像灰度变换及图像数组操作
- Python图像灰度变换及图像数组操作