本文整理匯總了C#中System.Drawing.TextureBrush類的典型用法代碼示例。如果您正苦於以下問題:C# TextureBrush類的具體用法?C# TextureBrush怎麽用?C# TextureBrush使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
TextureBrush類屬於System.Drawing命名空間,在下文中一共展示了TextureBrush類的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。
示例1: Button2_Click
private void Button2_Click(System.Object sender, System.EventArgs e)
{
try
{
Bitmap image1 = (Bitmap) Image.FromFile(@"C:\Documents and Settings\" +
@"All Users\Documents\My Music\music.bmp", true);
TextureBrush texture = new TextureBrush(image1);
texture.WrapMode = System.Drawing.Drawing2D.WrapMode.Tile;
Graphics formGraphics = this.CreateGraphics();
formGraphics.FillEllipse(texture,
new RectangleF(90.0F, 110.0F, 100, 100));
formGraphics.Dispose();
}
catch(System.IO.FileNotFoundException)
{
MessageBox.Show("There was an error opening the bitmap." +
"Please check the path.");
}
}
示例2: new TextureBrush(bmp, new Rectangle(0, 0, 25, 25))
//引入命名空間
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
public class Form1 : Form {
protected override void OnPaint(PaintEventArgs e) {
Graphics g = e.Graphics;
Bitmap bmp = new Bitmap("alphabet.gif");
TextureBrush tb = new TextureBrush(bmp, new Rectangle(0, 0, 25, 25));
g.FillRectangle(tb, 45, 45, 70, 150);
bmp.Dispose();
tb.Dispose();
}
public static void Main() {
Application.Run(new Form1());
}
}