c++中如何创建一个空的图片 如题,请高手指点! 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 void Ctest_display_ddbView::OnDraw(CDC* pDC){ Ctest_display_ddbDoc* pDoc = GetDocument(); ASSERT_VALID(pDoc); if (!pDoc) return; // TODO: 在此处为本机数据添加绘制代码 CBitmap Bitmap;/** 如果要创建彩色位图,要用CreateCompatibleBitmap而不是CreateBitmap!!!*/ //Bitmap.CreateBitmap(50,50,1,24,NULL); Bitmap.CreateCompatibleBitmap(pDC,500,500); BITMAP bm; Bitmap.GetObject(sizeof(BITMAP),&bm); unsigned char *pData = new unsigned char [bm.bmHeight * bm.bmWidthBytes]; /*WORD BitsPerPixel = bm.bmBitsPixel; CString strTmp; strTmp.Format(_T("%d"), BitsPerPixel); AfxMessageBox(strTmp);*/ for(int y = 0; y < bm.bmHeight; ++y) { for(int x = 0; x < bm.bmWidth; ++x) { pData[x * 4 + y * bm.bmWidthBytes] = 0; pData[x * 4 + y * bm.bmWidthBytes + 1] = 0; pData[x * 4 + y * bm.bmWidthBytes + 2] = 0; pData[x * 4 + y * bm.bmWidthBytes + 3] = 0; } } Bitmap.SetBitmapBits(bm.bmHeight * bm.bmWidthBytes, pData); //delete pData; CDC MemDC; MemDC.CreateCompatibleDC(pDC); CBitmap *pOldBitmap = MemDC.SelectObject(&Bitmap); int nReturned = pDC->BitBlt(10, 10, bm.bmWidth, bm.bmHeight, &MemDC, 0, 0, SRCCOPY); //pDC->StretchBlt(0,0, bm.bmWidth, bm.bmHeight, &MemDC,0,0,bm.bmWidth,bm.bmHeight,SRCCOPY); MemDC.SelectObject(pOldBitmap); delete pData; UpdateData(false);} 空图片,直接创建就可以啊CBitmap bmp;bmp.Create(); 你所说图片是什么呢?一个HBITMAP对象还是什么啊? 如何下载文件的指定字节段? winsock问题!恳请高手解答 求教 对于listctrl如何知道那一列单击了? 请问用UML分析设计,用VC实现时,大家经常用什么工具作分析?用什么工具作UML图? 当我用capCaptureSequence函数摄像时,应该怎么记时用SetTimer好象不行,不能响应SetTimer函数,谢谢 这个错误我真的看不出来,那位DX帮帮忙!!! 谁要豪华C++编辑器的源代码? 急,在线等!!! 关于ActiveX中的ON_EVENT宏? 简单的问题 PostThreadMessage?
{
Ctest_display_ddbDoc* pDoc = GetDocument();
ASSERT_VALID(pDoc);
if (!pDoc)
return; // TODO: 在此处为本机数据添加绘制代码
CBitmap Bitmap;/** 如果要创建彩色位图,要用CreateCompatibleBitmap而不是CreateBitmap!!!*/
//Bitmap.CreateBitmap(50,50,1,24,NULL);
Bitmap.CreateCompatibleBitmap(pDC,500,500); BITMAP bm;
Bitmap.GetObject(sizeof(BITMAP),&bm); unsigned char *pData =
new unsigned char [bm.bmHeight * bm.bmWidthBytes]; /*WORD BitsPerPixel = bm.bmBitsPixel;
CString strTmp;
strTmp.Format(_T("%d"), BitsPerPixel);
AfxMessageBox(strTmp);*/ for(int y = 0; y < bm.bmHeight; ++y)
{
for(int x = 0; x < bm.bmWidth; ++x)
{
pData[x * 4 + y * bm.bmWidthBytes] = 0;
pData[x * 4 + y * bm.bmWidthBytes + 1] = 0;
pData[x * 4 + y * bm.bmWidthBytes + 2] = 0;
pData[x * 4 + y * bm.bmWidthBytes + 3] = 0;
}
} Bitmap.SetBitmapBits(bm.bmHeight * bm.bmWidthBytes, pData); //delete pData; CDC MemDC;
MemDC.CreateCompatibleDC(pDC); CBitmap *pOldBitmap = MemDC.SelectObject(&Bitmap); int nReturned = pDC->BitBlt(10, 10, bm.bmWidth, bm.bmHeight, &MemDC, 0, 0, SRCCOPY);
//pDC->StretchBlt(0,0, bm.bmWidth, bm.bmHeight, &MemDC,0,0,bm.bmWidth,bm.bmHeight,SRCCOPY); MemDC.SelectObject(pOldBitmap); delete pData;
UpdateData(false);
}
CBitmap bmp;
bmp.Create();