本文整理汇总了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);
}
}