win32下GDI+ 平铺绘制算法有关问题
win32下GDI+ 平铺绘制算法问题
win32下的 GDI+绘制提供了多种绘制方式灵活调用。
不知道是不是有方法可以实现,一张图形,我指定 头尾不变,中间一部分作为平铺重绘的区域,来进行填充或者绘制呢?
不使用剪裁图形的方式实现绘制,GDI+中是否有方法能够实现这种绘制呢?
------解决方案--------------------
可以定义图片来做为画刷, 然后填充一块区域就可以了.不过好像是只能用整张图片, 不能用图片的一部分.
------解决方案--------------------
肯定是可以的,但没有这样特殊的API,要组合使用。
你把图片想象成9宫格,如果你能把中间一格的图片绘制到窗口的某个区域上,就可以用来填充某个区域。
------解决方案--------------------
Tiling a Shape with an Image
ms-help://MS.MSDNQTR.v80.chs/MS.MSDN.v80/MS.WIN32COM.v10.en/gdicpp/GDIPlus/usingGDIPlus/usingabrushtofillshapes/tilingashapewithanimage.htm
------解决方案--------------------
Just as tiles can be placed next to each other to cover a floor, rectangular images can be placed next to each other to fill (tile) a shape. To tile the interior of a shape, use a texture brush. When you construct a TextureBrush object, one of the arguments you pass to the constructor is the address of an Image object. When you use the texture brush to paint the interior of a shape, the shape is filled with repeated copies of this image.
The wrap mode property of the TextureBrush object determines how the image is oriented as it is repeated in a rectangular grid. You can make all the tiles in the grid have the same orientation, or you can make the image flip from one grid position to the next. The flipping can be horizontal, vertical, or both. The following examples demonstrate tiling with different types of flipping.
Tiling an Image
This example uses the following 75 ×75 image to tile a 200 ×200 rectangle:
Image image(L"HouseAndTree.gif");
TextureBrush tBrush(&image);
Pen blackPen(Color(255, 0, 0, 0));
stat = graphics.FillRectangle(&tBrush, Rect(0, 0, 200, 200));
stat = graphics.DrawRectangle(&blackPen, Rect(0, 0, 200, 200));
The following illustration shows how the rectangle is tiled with the image. Note that all tiles have the same orientation; there is no flipping.
Flipping an Image Horizontally While Tiling
This example uses a 75 ×75 image to fill a 200 ×200 rectangle. The wrap mode is set to flip the image horizontally.
Image image(L"HouseAndTree.gif");
TextureBrush tBrush(&image);
Pen blackPen(Color(255, 0, 0, 0));
stat = tBrush.SetWrapMode(WrapModeTileFlipX);
stat = graphics.FillRectangle(&tBrush, Rect(0, 0, 200, 200));
stat = graphics.DrawRectangle(&blackPen, Rect(0, 0, 200, 200));
The following illustration shows how the rectangle is tiled with the image. Note that as you move from one tile to the next in a given row, the image is flipped horizontally.
Flipping an Image Vertically While Tiling
This example uses a 75 ×75 image to fill a 200 ×200 rectangle. The wrap mode is set to flip the image vertically.
Image image(L"HouseAndTree.gif");
TextureBrush tBrush(&image);
Pen blackPen(Color(255, 0, 0, 0));
stat = tBrush.SetWrapMode(WrapModeTileFlipY);
stat = graphics.FillRectangle(&tBrush, Rect(0, 0, 200, 200));
stat = graphics.DrawRectangle(&blackPen, Rect(0, 0, 200, 200));
The following illustration shows how the rectangle is tiled with the image. Note that as you move from one tile to the next in a given column, the image is flipped vertically.
Flipping an Image Horizontally and Vertically While Tiling
This example uses a 75 ×75 image to tile a 200 ×200 rectangle. The wrap mode is set to flip the image both horizontally and vertically.
Image image(L"HouseAndTree.gif");
TextureBrush tBrush(&image);
win32下的 GDI+绘制提供了多种绘制方式灵活调用。
不知道是不是有方法可以实现,一张图形,我指定 头尾不变,中间一部分作为平铺重绘的区域,来进行填充或者绘制呢?
不使用剪裁图形的方式实现绘制,GDI+中是否有方法能够实现这种绘制呢?
------解决方案--------------------
可以定义图片来做为画刷, 然后填充一块区域就可以了.不过好像是只能用整张图片, 不能用图片的一部分.
------解决方案--------------------
肯定是可以的,但没有这样特殊的API,要组合使用。
你把图片想象成9宫格,如果你能把中间一格的图片绘制到窗口的某个区域上,就可以用来填充某个区域。
------解决方案--------------------
Tiling a Shape with an Image
ms-help://MS.MSDNQTR.v80.chs/MS.MSDN.v80/MS.WIN32COM.v10.en/gdicpp/GDIPlus/usingGDIPlus/usingabrushtofillshapes/tilingashapewithanimage.htm
------解决方案--------------------
Just as tiles can be placed next to each other to cover a floor, rectangular images can be placed next to each other to fill (tile) a shape. To tile the interior of a shape, use a texture brush. When you construct a TextureBrush object, one of the arguments you pass to the constructor is the address of an Image object. When you use the texture brush to paint the interior of a shape, the shape is filled with repeated copies of this image.
The wrap mode property of the TextureBrush object determines how the image is oriented as it is repeated in a rectangular grid. You can make all the tiles in the grid have the same orientation, or you can make the image flip from one grid position to the next. The flipping can be horizontal, vertical, or both. The following examples demonstrate tiling with different types of flipping.
Tiling an Image
This example uses the following 75 ×75 image to tile a 200 ×200 rectangle:
Image image(L"HouseAndTree.gif");
TextureBrush tBrush(&image);
Pen blackPen(Color(255, 0, 0, 0));
stat = graphics.FillRectangle(&tBrush, Rect(0, 0, 200, 200));
stat = graphics.DrawRectangle(&blackPen, Rect(0, 0, 200, 200));
The following illustration shows how the rectangle is tiled with the image. Note that all tiles have the same orientation; there is no flipping.
Flipping an Image Horizontally While Tiling
This example uses a 75 ×75 image to fill a 200 ×200 rectangle. The wrap mode is set to flip the image horizontally.
Image image(L"HouseAndTree.gif");
TextureBrush tBrush(&image);
Pen blackPen(Color(255, 0, 0, 0));
stat = tBrush.SetWrapMode(WrapModeTileFlipX);
stat = graphics.FillRectangle(&tBrush, Rect(0, 0, 200, 200));
stat = graphics.DrawRectangle(&blackPen, Rect(0, 0, 200, 200));
The following illustration shows how the rectangle is tiled with the image. Note that as you move from one tile to the next in a given row, the image is flipped horizontally.
Flipping an Image Vertically While Tiling
This example uses a 75 ×75 image to fill a 200 ×200 rectangle. The wrap mode is set to flip the image vertically.
Image image(L"HouseAndTree.gif");
TextureBrush tBrush(&image);
Pen blackPen(Color(255, 0, 0, 0));
stat = tBrush.SetWrapMode(WrapModeTileFlipY);
stat = graphics.FillRectangle(&tBrush, Rect(0, 0, 200, 200));
stat = graphics.DrawRectangle(&blackPen, Rect(0, 0, 200, 200));
The following illustration shows how the rectangle is tiled with the image. Note that as you move from one tile to the next in a given column, the image is flipped vertically.
Flipping an Image Horizontally and Vertically While Tiling
This example uses a 75 ×75 image to tile a 200 ×200 rectangle. The wrap mode is set to flip the image both horizontally and vertically.
Image image(L"HouseAndTree.gif");
TextureBrush tBrush(&image);