本文整理匯總了C#中System.Drawing.Graphics.FromImage方法的典型用法代碼示例。如果您正苦於以下問題:C# Graphics.FromImage方法的具體用法?C# Graphics.FromImage怎麽用?C# Graphics.FromImage使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類System.Drawing.Graphics
的用法示例。
在下文中一共展示了Graphics.FromImage方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。
示例1: FromImageImage
private void FromImageImage(PaintEventArgs e)
{
// Create image.
Image imageFile = Image.FromFile("SampImag.jpg");
// Create graphics object for alteration.
Graphics newGraphics = Graphics.FromImage(imageFile);
// Alter image.
newGraphics.FillRectangle(new SolidBrush(Color.Black), 100, 50, 100, 100);
// Draw image to screen.
e.Graphics.DrawImage(imageFile, new PointF(0.0F, 0.0F));
// Dispose of graphics object.
newGraphics.Dispose();
}
示例2: Form1_Paint
//引入命名空間
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
using System.Drawing.Drawing2D;
public class Form1 : System.Windows.Forms.Form {
private void Form1_Paint(object sender,
System.Windows.Forms.PaintEventArgs p) {
Graphics g = p.Graphics;
}
private void createManually() {
Graphics g;
g = this.CreateGraphics();
}
private void createFromFile() {
Graphics g;
Bitmap b;
b = new Bitmap("C:\\E.bmp");
g = Graphics.FromImage(b);
}
private void drawLine() {
Graphics g;
g = this.CreateGraphics();
Icon i = new Icon(@"C:\Desktop.ico");
g.DrawIcon(i, 150, 15);
}
}