to Kinglht:
首先谢谢你的回答。
我觉得问题不在于图片的尺寸。对于同一幅图片,只要x坐标>0,则在不同的位置平铺其效果不同。如
g.FillRectangle(brush, new Rectangle(0,
100,top_right.Width,top_right.Height));
平铺正常。而
g.FillRectangle(brush, new Rectangle(10, 100,top_right.Width,top_right.Height));
或
g.FillRectangle(brush, new Rectangle(20, 100,top_right.Width,top_right.Height));
或
g.FillRectangle(brush, new Rectangle(30, 100,top_right.Width,top_right.Height));
......
则平铺效果不正常。平铺位置的x坐标离x=0越远,则平铺偏差越大。
我不明白其中的机理。
首先谢谢你的回答。
我觉得问题不在于图片的尺寸。对于同一幅图片,只要x坐标>0,则在不同的位置平铺其效果不同。如
g.FillRectangle(brush, new Rectangle(0,
100,top_right.Width,top_right.Height));
平铺正常。而
g.FillRectangle(brush, new Rectangle(10, 100,top_right.Width,top_right.Height));
或
g.FillRectangle(brush, new Rectangle(20, 100,top_right.Width,top_right.Height));
或
g.FillRectangle(brush, new Rectangle(30, 100,top_right.Width,top_right.Height));
......
则平铺效果不正常。平铺位置的x坐标离x=0越远,则平铺偏差越大。
我不明白其中的机理。
绘制区域的长、宽绝对正确
绘制区域的x、y坐标应该说没什么限制(只要不出去Form区域就行)
那为什么在两个区域:new Rectangle(0,0,image.width,image.height)和new Rectangle(100,100,image.width,image.height)上填充该image却得到不同的效果。
头疼!!!!!!!
g.RendringOrigin.X不可设置。
Graphics.RenderingOrigin = new Point(100,100);
X,Y change by rectange location of the picture.
for(int x=0;x<=300;x+=100)
{
System.Drawing.Drawing2D.Matrix m = brush.Transform;
m.Translate(x,0);
brush.Transform = m;
g.FillRectangle(brush, new Rectangle(x, 100,top_right.Width,top_right.Height));
}
“System.Drawing.Brush”并不包含对“Transform”的定义
Transform 是TextureBrush的属性
Translate里的两个参数
分别等于你rectangle起始点的坐标
Translate里的两个参数
分别等于你rectangle起始点的坐标