这个问题我前两天发过一个贴:http://topic.csdn.net/u/20100812/13/c6c9a6bd-8636-441d-9c53-ddc4b35f9388.htmlSyntax FETCh:DPSA:TRACe:BITMap?
Arguments None
Returns (With Option 200) A binary block of 32-bit floating point values (IEEE standard
single precision floating point format). Each value ranges from 0 to 1.0, where 1.0
represents 100%. Option 200 bitmaps have 201 rows and 801 columns. Data[0]
is the first column in the first row, data[801] is the first column in the 2nd row,
and so on.
(Without Option 200) A binary block of unsigned 16-bit Little Endian
integers. Each value ranges from 0 to 2^16-1, where 2^16-1 represents 100%.
Non-option-200 bitmaps have 201 rows and 501 columns. Data[0] is the first
column in the first row, data[501] is the first column in the 2nd row, and so on.
Examples FETCH:DPSA:TRACE:BITMAP? might return #6644004xxxx... (Option 200)
or #161,001xxxx... (non-Option 200).
现在想问问具体该如何编码实现?这两天我看了《Windows程序设计》中的位图、DIB和调色板管理器。最后一部分看的有点半知半解。请问显示上面的数据需要调色板吗,还是直接在BITMAPINFO中直接指定RGBQUAD结构?
Arguments None
Returns (With Option 200) A binary block of 32-bit floating point values (IEEE standard
single precision floating point format). Each value ranges from 0 to 1.0, where 1.0
represents 100%. Option 200 bitmaps have 201 rows and 801 columns. Data[0]
is the first column in the first row, data[801] is the first column in the 2nd row,
and so on.
(Without Option 200) A binary block of unsigned 16-bit Little Endian
integers. Each value ranges from 0 to 2^16-1, where 2^16-1 represents 100%.
Non-option-200 bitmaps have 201 rows and 501 columns. Data[0] is the first
column in the first row, data[501] is the first column in the 2nd row, and so on.
Examples FETCH:DPSA:TRACE:BITMAP? might return #6644004xxxx... (Option 200)
or #161,001xxxx... (non-Option 200).
现在想问问具体该如何编码实现?这两天我看了《Windows程序设计》中的位图、DIB和调色板管理器。最后一部分看的有点半知半解。请问显示上面的数据需要调色板吗,还是直接在BITMAPINFO中直接指定RGBQUAD结构?
http://hi.baidu.com/clxye/album/item/0a6d0209898524ec2fddd41e.html#IMG=0a6d0209898524ec2fddd41e
http://hi.baidu.com/clxye/album/item/0a6d0209898524ec2fddd41e.html#IMG=0a6d0209898524ec2fddd41e
根据图,感觉原始图像格式是以频率特征编码的,需要转化成位图格式。但是转换的公式,楼主好像没有提供。
http://hi.csdn.net/attachment/201008/16/36689_1281939756N533.jpg这个公式应该还好,文档中说明:Each value ranges from 0 to 2^16-1, where 2^16-1 represents 100%。也就是说实际的值是0 - 2^16-1,所表示的意义就是0-100。可以简单理解成一次没出现就是0,出现25次就是25,大于等于100就是100来算。
0 - 2^16 - 1
对应意义
0 - 100下面是它文档中规定的颜色对应颜色
黑色 - 蓝色 - 浅蓝色 - 青色 - 竹绿色 - 绿色 - 黄色 - 橙色 - 桔红色 - 红色
0 1 2 3 4 5 6 7 8 9也就是对应着十个等级,等分就可以了。现在的问题是该如何创建DIB信息和颜色表并显示出来?
你只要了解一下位图格式就行了。
//传入参数:
// hWnd: 显示图像用的窗口
// pwData:从设备读出的数据(应为501 * 201个WORD型数据)
// nWidth:图像宽度,应为501
// nHeight:图像高度,应为201
void Display(HWND hWnd, const WORD *pwData, int nWidth, int nHeight)
{
BITMAPINFO *pBMInfo = (BITMAPINFO *)(new BYTE [sizeof(BITMAPINFOHEADER) + 16 * sizeof(RGBQUARD)];
BITMAPINFOHEADER *pbmh = &(pBMInfo->bmiHeader);
RGBQUARD *pPal = &(pBMInfo->bmiColors); ZeroMemory(pbmh, sizeof(BITMAPINFOHEADER));
pbmh->biSize = sizeof(BITMAPINFOHEADER);
pbmh->biWidth = nWidth;
pbmh->biHeight = nHeight;
pbmh->biPlanes = 1;
pbmh->biBitCount = 4; ZeroMemory(pbmh, sizeof(RGBQUARD) * 16);
pPal[0].rgbBlue = 0;
pPal[0].rgbGreen = 0;
pPal[0].rgbRed = 0;
pPal[1].rgbBlue = 255;
pPal[1].rgbGreen = 0;
pPal[1].rgbRed = 0;
pPal[2].rgbBlue = 255;
pPal[2].rgbGreen = 127;
pPal[2].rgbRed = 0;
pPal[3].rgbBlue = 255;
pPal[3].rgbGreen = 255;
pPal[3].rgbRed = 0;
pPal[4].rgbBlue = 127;
pPal[4].rgbGreen = 255;
pPal[4].rgbRed = 0;
pPal[5].rgbBlue = 0;
pPal[5].rgbGreen = 255;
pPal[5].rgbRed = 0;
pPal[6].rgbBlue = 0;
pPal[6].rgbGreen = 255;
pPal[6].rgbRed = 255;
pPal[7].rgbBlue = 0;
pPal[7].rgbGreen = 127;
pPal[7].rgbRed = 255;
pPal[8].rgbBlue = 0;
pPal[8].rgbGreen = 63;
pPal[8].rgbRed = 255;
pPal[9].rgbBlue = 0;
pPal[9].rgbGreen = 0;
pPal[9].rgbRed = 255; DWORD dwLineBytes = ((pbmh->biWidth * pbmh->biBitCount + 31) / 32) * 4;
BYTE *pucBits = new BYTE [dwLineBytes * pbmh->biHeight];
BYTE *pucLine, *pucPixel; pucLine = pucBits;
BOOL bOdd = FALSE;
for(i = 0; i < pbmh->biHeight; i++) {
pucPixel = pucLine;
for(j = 0; j < pbmh->biHeight; j++) {
if(bOdd) *pucPixel = (BYTE)((*pwData++ >> 12) << 4);
else *pucPixel++ |= (BYTE)(*pwData++ >> 12);
bOdd = !bOdd;
}
pucLine += dwLineBytes;
} RECT rect;
HDC hDC = ::GetDC(hWnd); ::GetClientRect(hWnd, &rect);
::SetStretchBltMode(COLORONCOLOR);
::StretchDIBits(hDC, rect.left, rect.top, rect.right - rect.left, rect.bottom - rect.top, 0, 0, pbmi->biWidth, pbmi->biHeight, pucBits, pBMInfo, DIB_RGB_COLORS, SRCCOPY); ::ReleaseDC(hWnd, hDC);
delete pBits;
delete pBMInfo;
}
这句错了,应该是:
for(j = 0; j < pbmh->biWidth; j++) {
bOdd = FALSE;
//传入参数:
// hWnd: 显示图像用的窗口
// pwData:从设备读出的数据(应为501 * 201个WORD型数据)
// nWidth:图像宽度,应为501
// nHeight:图像高度,应为201
void Display(HWND hWnd, const WORD *pwData, int nWidth, int nHeight)
{
BITMAPINFO *pBMInfo = (BITMAPINFO *)(new BYTE [sizeof(BITMAPINFOHEADER) + 16 * sizeof(RGBQUARD)];
BITMAPINFOHEADER *pbmh = &(pBMInfo->bmiHeader);
RGBQUARD *pPal = &(pBMInfo->bmiColors); ZeroMemory(pbmh, sizeof(BITMAPINFOHEADER));
pbmh->biSize = sizeof(BITMAPINFOHEADER);
pbmh->biWidth = nWidth;
pbmh->biHeight = nHeight;
pbmh->biPlanes = 1;
pbmh->biBitCount = 4; ZeroMemory(pbmh, sizeof(RGBQUARD) * 16);
pPal[0].rgbBlue = 0;
pPal[0].rgbGreen = 0;
pPal[0].rgbRed = 0;
pPal[1].rgbBlue = 255;
pPal[1].rgbGreen = 0;
pPal[1].rgbRed = 0;
pPal[2].rgbBlue = 255;
pPal[2].rgbGreen = 127;
pPal[2].rgbRed = 0;
pPal[3].rgbBlue = 255;
pPal[3].rgbGreen = 255;
pPal[3].rgbRed = 0;
pPal[4].rgbBlue = 127;
pPal[4].rgbGreen = 255;
pPal[4].rgbRed = 0;
pPal[5].rgbBlue = 0;
pPal[5].rgbGreen = 255;
pPal[5].rgbRed = 0;
pPal[6].rgbBlue = 0;
pPal[6].rgbGreen = 255;
pPal[6].rgbRed = 255;
pPal[7].rgbBlue = 0;
pPal[7].rgbGreen = 127;
pPal[7].rgbRed = 255;
pPal[8].rgbBlue = 0;
pPal[8].rgbGreen = 63;
pPal[8].rgbRed = 255;
pPal[9].rgbBlue = 0;
pPal[9].rgbGreen = 0;
pPal[9].rgbRed = 255; DWORD dwLineBytes = ((pbmh->biWidth * pbmh->biBitCount + 31) / 32) * 4;
BYTE *pucBits = new BYTE [dwLineBytes * pbmh->biHeight];
BYTE *pucLine, *pucPixel; pucLine = pucBits;
BOOL bOdd;
for(i = 0; i < pbmh->biHeight; i++) {
pucPixel = pucLine;
bOdd = FALSE;
for(j = 0; j < pbmh->biWidth; j++) {
if(!bOdd) *pucPixel = (BYTE)((*pwData++ >> 12) << 4);
else *pucPixel++ |= (BYTE)(*pwData++ >> 12);
bOdd = !bOdd;
}
pucLine += dwLineBytes;
} RECT rect;
HDC hDC = ::GetDC(hWnd); ::GetClientRect(hWnd, &rect);
::SetStretchBltMode(COLORONCOLOR);
::StretchDIBits(hDC, rect.left, rect.top, rect.right - rect.left, rect.bottom - rect.top, 0, 0, pbmi->biWidth, pbmi->biHeight, pucBits, pBMInfo, DIB_RGB_COLORS, SRCCOPY); ::ReleaseDC(hWnd, hDC);
delete pBits;
delete pBMInfo;
}
void CBmpTestDlg::Display( HWND hWnd, const WORD *pwData, int nWidth, int nHeight )
{
BITMAPINFO *pBMInfo = (BITMAPINFO *)(new BYTE [sizeof(BITMAPINFOHEADER) + 16 * sizeof(RGBQUAD)]);
BITMAPINFOHEADER *pbmh = &(pBMInfo->bmiHeader);
RGBQUAD *pPal = pBMInfo->bmiColors;
RECT rect;
HDC hDC = ::GetDC(hWnd); ZeroMemory(pbmh, sizeof(BITMAPINFOHEADER));
pbmh->biSize = sizeof(BITMAPINFOHEADER);
pbmh->biWidth = nWidth;
pbmh->biHeight = nHeight;
pbmh->biPlanes = 1;
pbmh->biBitCount = 4; ZeroMemory(pPal, sizeof(RGBQUAD) * 16);
pPal[0].rgbBlue = 0;
pPal[0].rgbGreen = 0;
pPal[0].rgbRed = 0;
pPal[1].rgbBlue = 255;
pPal[1].rgbGreen = 0;
pPal[1].rgbRed = 0;
pPal[2].rgbBlue = 255;
pPal[2].rgbGreen = 127;
pPal[2].rgbRed = 0;
pPal[3].rgbBlue = 255;
pPal[3].rgbGreen = 255;
pPal[3].rgbRed = 0;
pPal[4].rgbBlue = 127;
pPal[4].rgbGreen = 255;
pPal[4].rgbRed = 0;
pPal[5].rgbBlue = 0;
pPal[5].rgbGreen = 255;
pPal[5].rgbRed = 0;
pPal[6].rgbBlue = 0;
pPal[6].rgbGreen = 255;
pPal[6].rgbRed = 255;
pPal[7].rgbBlue = 0;
pPal[7].rgbGreen = 127;
pPal[7].rgbRed = 255;
pPal[8].rgbBlue = 0;
pPal[8].rgbGreen = 63;
pPal[8].rgbRed = 255;
pPal[9].rgbBlue = 0;
pPal[9].rgbGreen = 0;
pPal[9].rgbRed = 255; DWORD dwLineBytes = ((pbmh->biWidth * pbmh->biBitCount + 31) / 32) * 4;
BYTE *pucBits = new BYTE [dwLineBytes * pbmh->biHeight];
BYTE *pucLine, *pucPixel; pucLine = pucBits;
BOOL bOdd = FALSE;
for(int i = 0; i < pbmh->biWidth; i++) {
pucPixel = pucLine;
bOdd = FALSE;
for(int j = 0; j < pbmh->biHeight; j++) {
if(bOdd) *pucPixel = (BYTE)((*pwData++ >> 12) << 4);
else *pucPixel++ |= (BYTE)(*pwData++ >> 12);
bOdd = !bOdd;
}
pucLine += dwLineBytes;
} ::GetClientRect(hWnd, &rect);
::SetStretchBltMode(hDC, COLORONCOLOR);
::StretchDIBits(hDC, rect.left, rect.top, rect.right - rect.left, rect.bottom - rect.top, 0, 0, pbmh->biWidth, pbmh->biHeight, pucBits, pBMInfo, DIB_RGB_COLORS, SRCCOPY); ::ReleaseDC(hWnd, hDC);
delete pBMInfo;
}如果需要,我可以把我捕获到的二进制文件发给你,便于调试。如果没时间就算了,但依然要感谢你的帮助!
看你文档里的颜色说明,似乎RGB(255,255,0)应该被称作橙色~~
那么颜色段可以这样分:
0 黑色 0, 0, 0
1 蓝色 0, 0,255
2 浅蓝色 0, G,255
3 青色 0,255,255
4 竹绿色 0,255, B
5 绿色 0,255, 0
7 黄色 R,255, 0
6 橙色 255,255, 0
8 桔红色 255, G, 0
9 红色 255, 0, 0
这样,除了蓝到黑是比例稍微有点不同外,其余的红色之间正好隔开一个颜色。
16楼的创建了4位DIB,忽略了很多颜色哎~~~
应该创建32位的位图,这样显示出来才显得平滑。
void Display(HWND hWnd, const WORD *pwData, int nWidth, int nHeight)
{
BITMAPINFO *pBMInfo = (BITMAPINFO *)(new BYTE [sizeof(BITMAPINFOHEADER) + 16 * sizeof(RGBQUAD)]);
BITMAPINFOHEADER *pbmh = &(pBMInfo->bmiHeader);
RGBQUAD *pPal = pBMInfo->bmiColors; ZeroMemory(pbmh, sizeof(BITMAPINFOHEADER));
pbmh->biSize = sizeof(BITMAPINFOHEADER);
pbmh->biWidth = nWidth;
pbmh->biHeight = nHeight;
pbmh->biPlanes = 1;
pbmh->biBitCount = 4; ZeroMemory(pbmh, sizeof(RGBQUAD) * 16);
pPal[0].rgbBlue = 0;
pPal[0].rgbGreen = 0;
pPal[0].rgbRed = 0;
pPal[1].rgbBlue = 255;
pPal[1].rgbGreen = 0;
pPal[1].rgbRed = 0;
pPal[2].rgbBlue = 255;
pPal[2].rgbGreen = 127;
pPal[2].rgbRed = 0;
pPal[3].rgbBlue = 255;
pPal[3].rgbGreen = 255;
pPal[3].rgbRed = 0;
pPal[4].rgbBlue = 127;
pPal[4].rgbGreen = 255;
pPal[4].rgbRed = 0;
pPal[5].rgbBlue = 0;
pPal[5].rgbGreen = 255;
pPal[5].rgbRed = 0;
pPal[6].rgbBlue = 0;
pPal[6].rgbGreen = 255;
pPal[6].rgbRed = 255;
pPal[7].rgbBlue = 0;
pPal[7].rgbGreen = 127;
pPal[7].rgbRed = 255;
pPal[8].rgbBlue = 0;
pPal[8].rgbGreen = 63;
pPal[8].rgbRed = 255;
pPal[9].rgbBlue = 0;
pPal[9].rgbGreen = 0;
pPal[9].rgbRed = 255; DWORD dwLineBytes = ((pbmh->biWidth * pbmh->biBitCount + 31) / 32) * 4;
BYTE *pucBits = new BYTE [dwLineBytes * pbmh->biHeight];
BYTE *pucLine, *pucPixel; pucLine = pucBits;
BOOL bOdd;
for(int i = 0; i < pbmh->biHeight; i++) {
pucPixel = pucLine;
bOdd = FALSE;
for(int j = 0; j < pbmh->biWidth; j++) {
if(!bOdd) *pucPixel = (BYTE)((*pwData++ >> 12) << 4);
else *pucPixel++ |= (BYTE)(*pwData++ >> 12);
bOdd = !bOdd;
}
pucLine += dwLineBytes;
} RECT rect;
HDC hDC = ::GetDC(hWnd); ::GetClientRect(hWnd, &rect);
::SetStretchBltMode(hDC, COLORONCOLOR);
::StretchDIBits(hDC, rect.left, rect.top, rect.right - rect.left, rect.bottom - rect.top, 0, 0, pbmh->biWidth, pbmh->biHeight, pucBits, pBMInfo, DIB_RGB_COLORS, SRCCOPY); ::ReleaseDC(hWnd, hDC);
delete pucBits;
delete pBMInfo;
}
无法获得预期的结果,那么结果是怎么样的?
ZeroMemory(pbmh, sizeof(RGBQUAD) * 16);
估计应该是笔误,应该是改成下面这样吧:
ZeroMemory(pPal, sizeof(RGBQUAD) * 16);
下面是我这边的运行效果图:
http://hi.csdn.net/space-36689-do-album-picid-614180.html我们要下班了,非常感谢你的帮助。如果您方便的话,希望明天能再给我点帮助,我晚上回去再找点资料看看。谢谢!!
void CBmpTestDlg::Display( HDC hDC, int nWidth, int nHeight, const WORD *pwData, DWORD dwLen )
{
BITMAPINFO bminfo;
BITMAPINFOHEADER *pbmih = &bminfo.bmiHeader;
RGBTRIPLE *pPixel = NULL;
CRect rect;
DWORD dwPoints = dwLen / sizeof(WORD);
int nIndex; COLORREF rgbTable[10] = { RGB(255, 255, 255), // 白色
RGB(0, 0, 156), // 蓝色
RGB(0, 60, 231), // 浅蓝色
RGB(0, 207, 231), // 青色
RGB(33, 227, 0), // 竹绿色
RGB(222, 227, 0), // 黄色
RGB(214, 166, 0), // 橙色
RGB(231, 20, 0), // 桔红色
RGB(165, 0, 0) // 红色
}; pbmih->biSize = sizeof(BITMAPINFOHEADER);
pbmih->biBitCount = 24;
pbmih->biClrImportant = 0;
pbmih->biClrUsed = 0;
pbmih->biCompression = BI_RGB;
pbmih->biHeight = nHeight;
pbmih->biPlanes = 1;
pbmih->biSizeImage = 0;
pbmih->biWidth = nWidth;
pbmih->biXPelsPerMeter = 0;
pbmih->biYPelsPerMeter = 0; DWORD dwLineBytes = ( pbmih->biWidth * pbmih->biBitCount + 31 / 32) * 4;
BYTE *pBytes = new BYTE[dwLineBytes * nHeight];
pPixel = (RGBTRIPLE *)pBytes; for( DWORD i = 0; i < dwPoints; i++ )
{
switch( pwData[i] )
{
case 0: nIndex = 0; break;
case 1: nIndex = 1; break;
case 2: nIndex = 2; break;
case 3: nIndex = 3; break;
case 4: nIndex = 4; break;
case 5: nIndex = 5; break;
case 6: nIndex = 6; break;
case 7: nIndex = 7; break;
case 8: nIndex = 8; break;
case 9: nIndex = 9; break;
default: nIndex = 9; break;
}
pPixel[i].rgbtRed = GetRValue( rgbTable[nIndex] );
pPixel[i].rgbtGreen = GetGValue( rgbTable[nIndex] );
pPixel[i].rgbtBlue = GetBValue( rgbTable[nIndex] );
} GetClientRect( rect );
::SetStretchBltMode( hDC, COLORONCOLOR );
::StretchDIBits( hDC, rect.left, rect.top, rect.Width(), rect.Height(), 0, 0, nWidth, nHeight, (LPBYTE)pPixel, &bminfo, DIB_RGB_COLORS, SRCCOPY ); ::ReleaseDC( m_hWnd, hDC );
delete pPixel;
}
效果图:http://hi.csdn.net/space-36689-do-album-picid-614678.html
COLORREF rgbTable[10] = { RGB(255, 255, 255), // 白色
RGB(0, 0, 156), // 蓝色
RGB(0, 60, 231), // 浅蓝色
RGB(0, 207, 231), // 青色
RGB(33, 227, 0), // 竹绿色
RGB(222, 227, 0), // 黄色
RGB(214, 166, 0), // 橙色
RGB(231, 20, 0), // 桔红色
RGB(165, 0, 0) // 红色
};
怎么有白色的?而且其他的颜色RGB数字毫无规律,
跟我在18楼写的完全不一样。
你switch那里错了。你把大于9的数都处理成9了。- -
应该先把pwData[i]除以65535再乘以9,看结果处在0-9的哪个区间,比如:
pwData[i]=65534,则60000/65535*9=8.24,
则它处在:
8 桔红色 255, G, 0//G=127.5
9 红色 255, 0, 0
之间。
而这之间的颜色只是绿色分量不同。
那么你只要把127.5*(9-8.24)=96.9
则该点的颜色为RGB(255,96,0)。
另外把RGBTRIPLE通通改为RGBQUAD。
把for循环改为如下形式:
for(int i = 0; i < pbmih->biHeight; i++) {
for(int j = 0; j < pbmih->biWidth; j++) {
//代码
}
pucLine += dwLineBytes;
}
然后在StretchDIBits之前把:
pbmih->biHeight再赋值为一个负值:
pbmih->biHeight = -nHeight;
按说应该满窗口的,但图像变窄了。我再找找原因
int s_nClrArrayNum = CreateColorArray(); pbmih->biSize = sizeof(BITMAPINFOHEADER);
pbmih->biBitCount = 24;
pbmih->biClrImportant = 0;
pbmih->biClrUsed = 0;
pbmih->biCompression = BI_RGB;
pbmih->biHeight = -nHeight;
pbmih->biPlanes = 1;
pbmih->biSizeImage = 0;
pbmih->biWidth = nWidth;
pbmih->biXPelsPerMeter = 0;
pbmih->biYPelsPerMeter = 0; DWORD dwLineBytes = ( (pbmih->biWidth * pbmih->biBitCount + 31) / 32) * 4;
BYTE *pBytes = new BYTE[dwLineBytes * nHeight]; for( DWORD i = 0; i < nHeight; i++ )
{
for( DWORD j = 0; j < nWidth; j++ )
{
nIndex = pwData[i * nWidth + j] * s_nClrArrayNum/65535; pPixel = (RGBTRIPLE *)(pBytes + i * dwLineBytes + j); pPixel->rgbtRed = GetRValue( s_crColorArray[nIndex] );
pPixel->rgbtGreen = GetGValue( s_crColorArray[nIndex] );
pPixel->rgbtBlue = GetBValue( s_crColorArray[nIndex] );
}
} GetClientRect( rect );
::SetStretchBltMode( hDC, COLORONCOLOR );
::StretchDIBits( hDC, rect.left, rect.top, rect.Width(), rect.Height(), 0, 0, nWidth, nHeight, (LPBYTE)pBytes, &bminfo, DIB_RGB_COLORS, SRCCOPY );
{
BITMAPINFO bminfo;
BITMAPINFOHEADER *pbmih = &bminfo.bmiHeader;
CRect rect;
RGBTRIPLE *pPixel;
DWORD dwPoints = dwLen / sizeof(WORD);
int nIndex; int s_nClrArrayNum = CreateColorArray(); pbmih->biSize = sizeof(BITMAPINFOHEADER);
pbmih->biBitCount = 24;
pbmih->biClrImportant = 0;
pbmih->biClrUsed = 0;
pbmih->biCompression = BI_RGB;
pbmih->biHeight = -nHeight;
pbmih->biPlanes = 1;
pbmih->biSizeImage = 0;
pbmih->biWidth = nWidth;
pbmih->biXPelsPerMeter = 0;
pbmih->biYPelsPerMeter = 0; DWORD dwLineBytes = ( (pbmih->biWidth * pbmih->biBitCount + 31) / 32) * 4;
BYTE *pBytes = new BYTE[dwLineBytes * nHeight]; for( DWORD i = 0; i < nHeight; i++ )
{
for( DWORD j = 0; j < nWidth; j++ )
{
pPixel = (RGBTRIPLE *)(pBytes + i * dwLineBytes + j * pbmih->biBitCount / 8); nIndex = pwData[i * nWidth + j] * s_nClrArrayNum / 65535;
pPixel->rgbtRed = GetRValue( s_crColorArray[nIndex] );
pPixel->rgbtGreen = GetGValue( s_crColorArray[nIndex] );
pPixel->rgbtBlue = GetBValue( s_crColorArray[nIndex] );
}
} GetClientRect( rect );
::SetStretchBltMode( hDC, COLORONCOLOR );
::StretchDIBits( hDC, rect.left, rect.top, rect.Width(), rect.Height(), 0, 0, nWidth, nHeight, (LPBYTE)pBytes, &bminfo, DIB_RGB_COLORS, SRCCOPY ); ::ReleaseDC( m_hWnd, hDC );
delete pBytes;
}