2 回答

TA貢獻1844條經驗 獲得超8個贊
如果要從文件加載圖像,可以使用FromFile 方法。
來自 msdn 的例子:
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.");
}
}
如果要從流加載圖像,也可以使用FromStream 方法。
- 2 回答
- 0 關注
- 335 瀏覽
添加回答
舉報