简体   繁体   English

图案画笔可以填充 win32 中的任何矩形吗?

[英]Can a Pattern Brush fill any rectangle in win32?

Ok now suppose I have a Bitmap, called smile.bmp .好的,现在假设我有一个 Bitmap,叫做smile.bmp

And then I load the bitmap with a width of 100px and a height of 100px .然后我加载宽度为 100px高度为 100px的 bitmap 。

HBITMAP hBitmap = (HBITMAP)LoadImage(NULL,
                     L"C:/MyImages/smile.bmp",
                     IMAGE_BITMAP,
                     100 /*Width of Image*/,
                     100 /*Height of Image*/,
                     LR_LOADFROMFILE);
// Loading the Bitmap with a width and height of 100px.

And then I create a pattern brush using the Bitmap.然后我使用 Bitmap 创建了一个图案画笔。

HBRUSH hBrush = CreatePatternBrush(hBitmap /*The Bitmap*/);

Now if I use FillRect using this brush, could I using any RECT structure?现在,如果我使用此画笔使用FillRect ,我可以使用任何RECT结构吗? For example,例如,

RECT rect1 = {0, 0, 200, 200};
FillRect(hdc, &rect1, hBrush);
// Would it stretch the Bitmap or not even bother drawing it?

If you can recall I loaded the Bitmap with a width and height of 100px .如果您还记得的话,我加载了宽度和高度为100px的 Bitmap。 But now I am filling a rectangle with a width and height of 200px .但是现在我正在填充一个宽度和高度为200px的矩形。


So here is my question, would it even fill the area, or would it stretch the pixels to match the area?所以这是我的问题,它会填充该区域,还是会拉伸像素以匹配该区域?

It will tile the brush pattern to fill the area.它将平铺画笔图案以填充该区域。 The documentation shows an example.文档显示了一个示例。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM