.NET 2.0的绘图功能
System.Drawing
提供对GDI+基本图形功能访问。
更高级的功能在System.Drawing.Drawing2D、System.Drawing.Imaging和System.Drawing.Text命名空间提供。
Graphics类提供了绘制到显示设备的方法。诸如Rectangle和Point等类可封装GDI+基元。
Pen类用于绘制直线和曲线。
从抽象类Brush派生出了的类则用于填充形状的内部。
类
Bitmap 封装GDI+位图,此位图由图形图像及属性的像素组成,用于处理由像素数据定义的图像对象。
语法:
[SerializableAttribute]
[ComVisibleAttribute(true)]
Public sealed class Bitmap:Image
Bitmap成员
公共构造函数
Bitmap 已重载 初始化Bitmap类的新实例
Bitmap(Image original)
Bitmap(string fileName)
Bitmap(System.IO.Stream stream)
Bitmap(Image original,Size newSize)
Bitmap(int width,int height)
Bitmap(string filename,bool Icm)
Bitmap(System.IO.Stream stream,bool useIcm)
Bitmap(Type type,string resource)
Bitmap(Image original,int width,int height)
Bitmap(int width,int height,Graphics g)
Bitmap(int width,int height,System.Drawing.Imaging.PixelFormat format)
Bitmap(int width,int height,System.Drawing.Imaging.PixelFormat format)
使用Bitmap(int width,int height)自己绘制一个图像
Graphics g;
Bitmap bm=new Bitmap(400,400);
g=Graphics.FromImage(bm);
g.DrawLine(Pens.Red,0,0,400,400);
g.DrawLine(Pens.Red,0,400,400,0);
使用已有的图像
Bitmap bm=new Bitmap(“Images//boy.jpg”);
路径分隔符
相对目录:Images//boy.jpg
..//..//Images//boy.jpg ..表示返回上一级目录