首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > VC/MFC >

怎么用位图来填充一个矩形区域

2012-01-31 
如何用位图来填充一个矩形区域?我有一个位图,但如何填充一个矩形区域呢?[解决办法]// Create a hatched bi

如何用位图来填充一个矩形区域?
我有一个位图,但如何填充一个矩形区域呢?

[解决办法]
// Create a hatched bit pattern.
WORD HatchBits[8] = { 0x11, 0x22, 0x44, 0x88, 0x11,
0x22, 0x44, 0x88 };

// Use the bit pattern to create a bitmap.
CBitmap bm;
bm.CreateBitmap(8,8,1,1, HatchBits);

// Create a pattern brush from the bitmap.
CBrush brush;
brush.CreatePatternBrush(&bm);

// 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);


[解决办法]
使用 BitBlt函数,把图片拷贝到矩形就行了

热点排行