将给定的字符文字保存成.bmpd的图象!~~~在此谢过了!!~~~
解决方案 »
- 串口通信,XP系统下的“OCX”控件
- CStringArray释放问题
- 关于VC6.0的编辑器显示中文乱码的问题
- 求助!!!!
- 如何实现让自定义类中的某个成员变量等于某个值后,触发消息???
- 江湖救急~~小弟初入江湖,涉世为生,那位大侠,拔刀相助,感恩戴德,他日结草衔环,涌泉相报
- 难能可贵的技术问卷!
- 求教!!怎样对ListCtrl控件进行颜色设置???
- 奶奶的,再散,我拼了。
- 各位大虾,关于集合的问题
- 关于CToolTipCtrl ,我鼠标移动到ListCtrl的某一格,就显示Tips,怎么实现?
- 比如,我在程序里面OnOpenDocument()函数打开了一个文件,当我在程序外部删除该文件后,程序如何能马上知道该文件不存在了,然后马上提示
CString strText = _T("TEXT");
HDC hdc = ::GetDC(NULL);
ASSERT(hdc);
CRect rect(0, 0, 0, 0);
int iReturn;
::DrawText(hdc, strText, strText.GetLength(), &rect, DT_CALCRECT); HBITMAP hbitmap = ::CreateCompatibleBitmap(hdc, rect.Width(), rect.Height()); HDC hMemDC = ::CreateCompatibleDC(hdc);
hbitmap = (HBITMAP)::SelectObject(hMemDC, hbitmap); ::PatBlt(hMemDC, rect.left, rect.top, rect.right, rect.bottom, WHITENESS);
::SetBkMode(hMemDC, TRANSPARENT);
::DrawText(hMemDC, strText, strText.GetLength(), &rect, DT_LEFT | DT_BOTTOM);
hbitmap = (HBITMAP)::SelectObject(hMemDC, hbitmap);
::DeleteDC(hMemDC); long lSizeImage = rect.Height() * (4 * (rect.Width()*24 + 31)/32); BITMAPINFOHEADER bmih;
BITMAPFILEHEADER bmfh;
::memset(&bmih, 0, sizeof(bmih));
bmih.biSize = sizeof(BITMAPINFOHEADER);
bmih.biPlanes = 1;
bmih.biBitCount = 24;
bmih.biWidth = rect.Width();
bmih.biHeight = rect.Height();
bmih.biCompression = BI_RGB;
PBYTE pbits = new BYTE[lSizeImage];
ASSERT(pbits); iReturn = ::GetDIBits(hdc, hbitmap, 0, rect.Height(), pbits, (LPBITMAPINFO)&bmih, DIB_RGB_COLORS);
::ReleaseDC(NULL, hdc);
::DeleteObject(hbitmap); long lFileSize = sizeof(BITMAPFILEHEADER) + sizeof(BITMAPINFOHEADER) + lSizeImage; bmfh.bfType = *(WORD*)"BM";
bmfh.bfSize = lFileSize;
bmfh.bfOffBits = sizeof(BITMAPFILEHEADER) + sizeof(BITMAPINFOHEADER);
bmfh.bfReserved1 = 0;
bmfh.bfReserved2 = 0; HANDLE hFile = ::CreateFile(_T("c:\\TEXT.bmp"), GENERIC_WRITE, 0, NULL,CREATE_ALWAYS ,FILE_ATTRIBUTE_NORMAL, NULL);
ASSERT(hFile != INVALID_HANDLE_VALUE); DWORD dwNum;
BOOL bReturn;
bReturn = ::WriteFile(hFile, &bmfh, sizeof(bmfh), &dwNum, NULL);
bReturn = ::WriteFile(hFile, &bmih, sizeof(bmih), &dwNum, NULL);
bReturn = ::WriteFile(hFile, pbits, lSizeImage, &dwNum, NULL); delete []pbits;
CloseHandle(hFile);
}
const BYTE *pByMaskeData )
{
for ( DWORD i = DWORD_ZERO; i < m_dwPixelNum / NUM_8BIT; i++ )
{
std::bitset<NUM_8BIT> bitMask( *( pByMaskeData + i ) );
for ( UINT j = UINT_ZERO; j < NUM_8BIT; j++ )
{
if ( true == bitMask[ UINT_SEVEN - j ] )
{
*( pdwDestData + i * NUM_8BIT + j ) &= ALPHA_0;
}
else
{
*( pdwDestData + i * NUM_8BIT + j ) |= ALPHA_255;
}
}
}
}
{ nPixelData = pByImageData[nRGBGuadSize+i];
pdwTempPixelData[i] = ( BYTE_FF << NUM_24BIT )
+ ( ByRGEGuad[nPixelData].rgbRed << NUM_16BIT )
+ ( ByRGEGuad[nPixelData].rgbGreen << NUM_8BIT )
+ ByRGEGuad[nPixelData].rgbBlue;
nPixelData = DWORD_ZERO;
}