首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > VC/MFC >

已有像素点矩阵在内存中,CDC怎么得到

2012-08-24 
已有像素点矩阵在内存中,CDC如何得到rt,CDC如何能得到并处理内存中已存在的像素点矩阵[解决办法]// get me

已有像素点矩阵在内存中,CDC如何得到
rt,CDC如何能得到并处理内存中已存在的像素点矩阵

[解决办法]
// get mem
unsigned fsize;
fsize =if_hnd.GetLength();//
BYTE *ScreenPtr1=0;
ScreenPtr1=(BYTE *)new char[fsize]; //
// read all in
if_hnd.Read(ScreenPtr1,fsize);// 数据在这里
// image data are in buffer
if(if_hnd) if_hnd.Close();
// make bitmap info
LPBITMAPINFO pBMPinfo;
pBMPinfo=(LPBITMAPINFO)new BYTE[sizeof(BITMAPINFOHEADER)+16*sizeof(RGBQUAD)];
ZeroMemory(&pBMPinfo->bmiHeader,sizeof(BITMAPINFOHEADER));
pBMPinfo->bmiHeader.biSize=sizeof(BITMAPINFOHEADER);
pBMPinfo->bmiHeader.biBitCount=4;
pBMPinfo->bmiHeader.biWidth=648;
pBMPinfo->bmiHeader.biHeight=508;
pBMPinfo->bmiHeader.biPlanes=1;
pBMPinfo->bmiHeader.biSizeImage=648*508/2;
// copy colors
for(int jj=0; jj<16; jj++)
{// reversed !
pBMPinfo->bmiColors[jj].rgbReserved=0;
pBMPinfo->bmiColors[jj].rgbRed=(BYTE)(color_table[jj] & 0x0000FF);
pBMPinfo->bmiColors[jj].rgbGreen=(BYTE)((color_table[jj] & 0x00FF00) >> 8);
pBMPinfo->bmiColors[jj].rgbBlue=(BYTE)((color_table[jj] & 0xFF0000) >> 16);
}
// draw bmp
pDC->SetStretchBltMode(COLORONCOLOR);
StretchDIBits(pDC->GetSafeHdc(),0,0,wid,hei,0,0,wid,hei,
ScreenPtr1,
pBMPinfo,
DIB_RGB_COLORS,SRCCOPY);
// free
delete pBMPinfo;
delete [] ScreenPtr1;
return;

[解决办法]
SetDIBitsToDevice

热点排行