二、画刷的使用
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Drawing.Imaging;
public Form1()
{
InitializeComponent();
comboBox1.SelectedIndex = 0;
}
private void button1_Click(object sender, EventArgs e)
{
Bitmap bp = new Bitmap("1.jpg");
TextureBrush tb = new TextureBrush(bp);
Graphics g = this.CreateGraphics();
g.FillRectangle(tb, this.ClientRectangle);
bp.Dispose();
tb.Dispose();
g.Dispose();
}
private void button2_Click(object sender, EventArgs e)
{
Bitmap bp = new Bitmap("1.jpg");
TextureBrush tb = new TextureBrush(bp, new Rectangle(0, 0, 100, 100));
Graphics g = this.CreateGraphics();
switch (comboBox1.SelectedItem.ToString().Trim())
{
case "Clamp":
tb.WrapMode = WrapMode.Clamp;
g.FillRectangle(tb, this.ClientRectangle);
bp.Dispose();
tb.Dispose();
g.Dispose();
break;
case "Tile":
tb.WrapMode = WrapMode.Tile;
g.FillRectangle(tb, this.ClientRectangle);
bp.Dispose();
tb.Dispose();
g.Dispose();
break;
case "TileFlipX":
tb.WrapMode = WrapMode.TileFlipX;
g.FillRectangle(tb, this.ClientRectangle);
bp.Dispose();
tb.Dispose();
g.Dispose();
break;
case "TileFlipXY":
tb.WrapMode = WrapMode.TileFlipXY;
g.FillRectangle(tb, this.ClientRectangle);
bp.Dispose();
tb.Dispose();
g.Dispose();
break;
case "TileFlipY":