void CTestBmpView::OnDraw(CDC* pDC)
{
CTestBmpDoc* pDoc = GetDocument();
ASSERT_VALID(pDoc);
WORD a,b,c,d,e,f,g,h;
a = 0xff;
b = 0xff;
c = 0xff;
d = 0xff;
e = 0x00;
f = 0x00;
g = 0x00;
h = 0x11;
WORD HatchBits[8*8] = {
a, b, c, d, e,f, g, h,
a, b, c, d, e,f, g, h,
a, b, c, d, e,f, g, h,
a, b, c, d, e,f, g, h,
a, b, c, d, e,f, g, h,
a, b, c, d, e,f, g, h,
a, b, c, d, e,f, g, h,
a, b, c, d, e,f, g, h
};
// Use the bit pattern to create a bitmap.
CBitmap bm;
bm.CreateBitmap(8,8,1,8, HatchBits);
// Create a pattern brush from the bitmap.
CBrush brush;
brush.CreatePatternBrush(&bm);//因为,要创建一个和pDC格式相同的memdc,才能用biblt,
//所以,我把这段msdn上的程序修改了一下。用了8位的,msdn上面是单色的。
// Select the brush into a device context, and draw.
CBrush* pOldBrush = (CBrush*)pDC->SelectObject(&brush);
pDC->RoundRect(CRect(50, 50, 200, 200), CPoint(10,10));
// Restore the original brush.
pDC->SelectObject(pOldBrush);
}
标签:CreateBitmap,位图,创建