您的位置:首页 > 其它

将灰度图像读取到数组中,然后再绘制的屏幕上

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格式
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐