19,468
社区成员
发帖
与我相关
我的任务
分享
BITMAPINFO bmpInfo; //创建位图
bmpInfo.bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
bmpInfo.bmiHeader.biWidth = (int)m_Rect.width();//宽度
bmpInfo.bmiHeader.biHeight = (int)m_Rect.height();//高度
bmpInfo.bmiHeader.biPlanes = 1;
bmpInfo.bmiHeader.biBitCount = 1;
bmpInfo.bmiHeader.biCompression = BI_RGB;
bmpInfo.bmiHeader.biSizeImage = 0;
bmpInfo.bmiHeader.biXPelsPerMeter = 0;
bmpInfo.bmiHeader.biYPelsPerMeter = 0;
bmpInfo.bmiHeader.biClrImportant = 0;
bmpInfo.bmiHeader.biClrUsed = 1;//颜色表中使用的颜色数
void* pArray = NULL;
HBITMAP hbmp = CreateDIBSection(NULL, &bmpInfo, DIB_RGB_COLORS, &pArray, NULL, 0);//创建DIB
ASSERT(hbmp != NULL);
UINT uiTotalBytes = (((int)m_Rect.width() + 31) / 32) * 4 * (int)m_Rect.height();
memset(pArray, 255, uiTotalBytes);
m_pMemBmp->Attach(hbmp);
m_pMemDc->CreateCompatibleDC(NULL);//创建空的CDC
m_pMemDc->SelectObject(m_pMemBmp); //选入位图
///////////////////////////////////创建位图/////////////////////////////
HBITMAP hbmp = CreateBitmap((int)m_Rect.width(), (int)m_Rect.height(), 1, 1, NULL);
m_pMemBmp->Attach(hbmp);
ASSERT(m_pMemBmp != NULL);
BYTE array[X_GRAPH_POINT * Y_GRAPH_POINT];
memset(array, 0, X_GRAPH_POINT * Y_GRAPH_POINT);
m_pMemBmp->SetBitmapBits(X_GRAPH_POINT * Y_GRAPH_POINT, array);
m_pMemDc->CreateCompatibleDC(NULL); //创建空的DC
m_pMemDc->SelectObject(m_pMemBmp); //选入位图
BITMAPINFO *pbmi = (BITMAPINFO *)(new BYTE [sizeof(BITMAPINFOHEADER) + sizeof(RGBQUAD) * 调色板入口数]);
BITMAPINFO bmpInfo; //创建位图
bmpInfo.bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
bmpInfo.bmiHeader.biWidth = (int)m_Rect.width();
bmpInfo.bmiHeader.biHeight = (int)m_Rect.height();
bmpInfo.bmiHeader.biPlanes = 1;
bmpInfo.bmiHeader.biBitCount = 1;
bmpInfo.bmiHeader.biCompression = BI_RGB;
bmpInfo.bmiHeader.biSizeImage = 0;
bmpInfo.bmiHeader.biXPelsPerMeter = 0;
bmpInfo.bmiHeader.biYPelsPerMeter = 0;
bmpInfo.bmiHeader.biClrImportant = 0;
bmpInfo.bmiHeader.biClrUsed = 1;//颜色表中使用的颜色数
bmpInfo.bmiColors[0].rgbRed = 255; //设置颜色
bmpInfo.bmiColors[0].rgbGreen = 255;
bmpInfo.bmiColors[0].rgbBlue = 255;
bmpInfo.bmiColors[0].rgbReserved = 0;
bmpInfo.bmiColors[1].rgbRed = 0;
bmpInfo.bmiColors[1].rgbGreen = 0;
bmpInfo.bmiColors[1].rgbBlue = 0;
bmpInfo.bmiColors[1].rgbReserved = 0;
BITMAPINFO *pbmi = (BITMAPINFO *)(new BYTE [sizeof(BITMAPINFOHEADER) + sizeof(RGBQUAD) * 2]);
pbmi->bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
pbmi->bmiHeader.biWidth = (int)m_Rect.width();
pbmi->bmiHeader.biHeight = (int)m_Rect.height();
pbmi->bmiHeader.biPlanes = 1;
pbmi->bmiHeader.biBitCount = 1;
pbmi->bmiHeader.biCompression = BI_RGB;
pbmi->bmiHeader.biSizeImage = 0;
pbmi->bmiHeader.biXPelsPerMeter = 0;
pbmi->bmiHeader.biYPelsPerMeter = 0;
pbmi->bmiHeader.biClrImportant = 0;
pbmi->bmiHeader.biClrUsed = 1;//颜色表中使用的颜色数
pbmi->bmiColors[1].rgbRed = 0;//设置颜色
pbmi->bmiColors[1].rgbGreen = 0;
pbmi->bmiColors[1].rgbBlue = 0;
pbmi->bmiColors[1].rgbReserved = 0;
pbmi->bmiColors[0].rgbRed = 255;
pbmi->bmiColors[0].rgbGreen = 255;
pbmi->bmiColors[0].rgbBlue = 255;
pbmi->bmiColors[0].rgbReserved = 0;
void* pArray = NULL;
HBITMAP hbmp = CreateDIBSection(NULL, pbmi, DIB_RGB_COLORS, &pArray, NULL, 0);
ASSERT(hbmp != NULL);
UINT uiTotalBytes = (((int)m_Rect.width() + 31) / 32) * 4 * (int)m_Rect.height();
memset(pArray, 255, uiTotalBytes);
m_pMemBmp->Attach(hbmp);
m_pMemDc->CreateCompatibleDC(NULL);//创建空的CDC
m_pMemDc->SelectObject(m_pMemBmp); //选入位图