当前位置 : 主页 > 网络编程 > net编程 >

Net GDI+总结

来源:互联网 收集:自由互联 发布时间:2023-09-07
代码分享: //绘制单色画笔 Bitmap l = new Bitmap(800, 600); Graphics g = Graphics.FromImage(l); g.Clear(Color.White); SolidBrush b = new SolidBrush(Color.Yellow); g.FillEllipse(b, 70, 20, 100, 50); System.IO.MemoryStream ms = new

代码分享:

//绘制单色画笔

Bitmap l = new Bitmap(800, 600);

Graphics g = Graphics.FromImage(l);

g.Clear(Color.White);

SolidBrush b = new SolidBrush(Color.Yellow);

g.FillEllipse(b, 70, 20, 100, 50);

System.IO.MemoryStream ms = new System.IO.MemoryStream();

l.Save(ms, System.Drawing.Imaging.ImageFormat.Gif);

Response.ClearContent();

Response.ContentType = "image/Gif";

Response.BinaryWrite(ms.ToArray());

//绘制阴影图案

//Bitmap l = new Bitmap(200, 100);

//Graphics g = Graphics.FromImage(l);

//g.Clear(Color.White);

//HatchBrush b = new HatchBrush( HatchStyle.BackwardDiagonal,Color.Pink,Color.Orange);

//g.FillEllipse(b, 70, 20, 100, 50);

//System.IO.MemoryStream ms = new System.IO.MemoryStream();

//l.Save(ms, System.Drawing.Imaging.ImageFormat.Jpeg);

//Response.ClearContent();

//Response.ContentType = "image/Jpeg";

//Response.BinaryWrite(ms.ToArray());

//绘制图像

   //Bitmap l = new Bitmap(200, 100);

   //Graphics g = Graphics.FromImage(l);

   //g.Clear(Color.White);

   //TextureBrush b = new TextureBrush(System.Drawing.Image.FromFile(Server.MapPath("~/地泵.jpg")));

   //b.WrapMode = WrapMode.Clamp;

   //g.FillEllipse(b, 70, 20, 100, 50);

   //System.IO.MemoryStream ms = new System.IO.MemoryStream();

   //l.Save(ms, System.Drawing.Imaging.ImageFormat.Jpeg);

   //Response.ClearContent();

   //Response.ContentType = "image/Jpeg";

   //Response.BinaryWrite(ms.ToArray());

   //实现渐变

   //Bitmap l = new Bitmap(200, 100);

   //Graphics g = Graphics.FromImage(l);

   //g.Clear(Color.White);

   //Rectangle b = new Rectangle(0,0,200,100);

   //LinearGradientBrush bru = new LinearGradientBrush(b, Color.Pink, Color.Green, LinearGradientMode.BackwardDiagonal);

   //g.FillRectangle(bru, 70, 20, 100, 50);

   //System.IO.MemoryStream ms = new System.IO.MemoryStream();

   //l.Save(ms, System.Drawing.Imaging.ImageFormat.Jpeg);

   //Response.ClearContent();

   //Response.ContentType = "image/Jpeg";

   //Response.BinaryWrite(ms.ToArray());

   //实现彩色渐变

   //Bitmap l = new Bitmap(400, 200);

   //Graphics g = Graphics.FromImage(l);

   //g.Clear(Color.White);

   //Point p = new Point(100, 100);

   //int R = 100;

   //GraphicsPath path = new GraphicsPath();

   //path.AddEllipse(p.X - R, p.Y - R, 2 * R, 2 * R);

   //PathGradientBrush bru = new PathGradientBrush(path);

   //bru.CenterPoint = p;

   //bru.CenterColor = Color.Green;

   //bru.SurroundColors = new Color[] {Color.Gold};

   //g.FillEllipse(bru, p.X - R, p.Y - R, 2 * R, 2 * R);

   //System.IO.MemoryStream ms = new System.IO.MemoryStream();

   //l.Save(ms, System.Drawing.Imaging.ImageFormat.Jpeg);

   //Response.ClearContent();

   //Response.ContentType = "image/Jpeg";

   //Response.BinaryWrite(ms.ToArray());

   //绘制曲线

   //Bitmap b = new Bitmap(300,200);

   //Graphics g = Graphics.FromImage(b);

   //g.Clear(Color.White);

   //Point[] ps = {new Point(10,10),new Point(10,100),new Point(200,50),new Point(260,120) };

   //g.DrawLines(new Pen(Color.Pink, 3), ps);

   //System.IO.MemoryStream ms = new System.IO.MemoryStream();

   //b.Save(ms, System.Drawing.Imaging.ImageFormat.Jpeg);

   //Response.ClearContent();

   //Response.ContentType = "image/Jpeg";

   //Response.BinaryWrite(ms.ToArray());

   //绘制矩形

   //Bitmap b = new Bitmap(500,500);

   //Graphics g = Graphics.FromImage(b);

   //g.Clear(Color.White);

   //g.DrawRectangles(new Pen(Color.Black, 2), new Rectangle[] { new Rectangle(10,10,100,200), new Rectangle(100, 200, 250, 50) });

   //System.IO.MemoryStream m = new System.IO.MemoryStream();

   //b.Save(m, System.Drawing.Imaging.ImageFormat.Jpeg);

   //Response.ClearContent();

   //Response.ContentType = "image/Jpeg";

   //Response.BinaryWrite(m.ToArray());

   //绘制椭圆

   //Bitmap b = new Bitmap(200,200);

   //Graphics g = Graphics.FromImage(b);

   //g.Clear(Color.White);

   //g.DrawEllipse(new Pen(Color.Pink, 3), new Rectangle(10, 10, 50, 100));

   //System.IO.MemoryStream m = new System.IO.MemoryStream();

   //b.Save(m, System.Drawing.Imaging.ImageFormat.Jpeg);

   //Response.ClearContent();

   //Response.ContentType = "image/Jpeg";

   //Response.BinaryWrite(m.ToArray());

   //绘制弧形

   //Bitmap b = new Bitmap(200, 200);

   //Graphics g = Graphics.FromImage(b);

   //g.Clear(Color.White);

   //g.DrawArc(new Pen(Color.Pink, 3), new Rectangle(10, 10, 50, 100),-60,180);

   //System.IO.MemoryStream m = new System.IO.MemoryStream();

   //b.Save(m, System.Drawing.Imaging.ImageFormat.Jpeg);

   //Response.ClearContent();

   //Response.ContentType = "image/Jpeg";

   //Response.BinaryWrite(m.ToArray());

   //绘制扇形

   //Bitmap b = new Bitmap(200, 200);

   //Graphics g = Graphics.FromImage(b);

   //g.Clear(Color.White);

   //g.DrawPie(new Pen(Color.Pink, 3), new Rectangle(10, 10, 150, 100), 50, 200);

   //System.IO.MemoryStream m = new System.IO.MemoryStream();

   //b.Save(m, System.Drawing.Imaging.ImageFormat.Jpeg);

   //Response.ClearContent();

   //Response.ContentType = "image/Jpeg";

   //Response.BinaryWrite(m.ToArray());

   

   图片展示:

Net GDI+总结_net


上一篇:Net绘制柱形图
下一篇:没有了
网友评论