码迷,mamicode.com
首页 > 其他好文 > 详细

GDI+(Graphics Device Interface)例子

时间:2014-12-08 17:40:01      阅读:170      评论:0      收藏:0      [点我收藏+]

标签:style   io   ar   color   使用   sp   for   on   bs   

使用SolidBrush 单色画笔

            Bitmap bitmap = new Bitmap(800, 600);
            Graphics graphics = Graphics.FromImage(bitmap);
            graphics.Clear(Color.White);
            SolidBrush mySolidBrush = new SolidBrush(Color.Yellow);
            graphics.FillEllipse(mySolidBrush, 70, 20, 100, 50);
            System.IO.MemoryStream ms = new System.IO.MemoryStream();
            bitmap.Save(ms, System.Drawing.Imaging.ImageFormat.Gif);
            Response.ClearContent();
            Response.ContentType = "image/Gif";
            Response.BinaryWrite(ms.ToArray());

img派生类的对象->画布->清理画布->声明画笔->画椭圆->把img存到内存流中->二进制数组从服务器发送到浏览器上

使用HatchBrush绘制简单图案

            Bitmap bitmap = new Bitmap(200, 100);
            Graphics graphics = Graphics.FromImage(bitmap);
            graphics.Clear(Color.White);
            HatchBrush myhatchBrush = new HatchBrush(HatchStyle.BackwardDiagonal, Color.Green, Color.Orange);
            graphics.FillEllipse(myhatchBrush, 0, 0, 200, 100);
            System.IO.MemoryStream ms = new System.IO.MemoryStream();
            bitmap.Save(ms, System.Drawing.Imaging.ImageFormat.Jpeg);
            Response.ClearContent();
            Response.ContentType = "image/Jpeg";
            Response.BinaryWrite(ms.ToArray());

img派生类的对象->画布->清理画布->声明画笔->画椭圆->把img存到内存流中->二进制数组从服务器发送到浏览器上

 

GDI+(Graphics Device Interface)例子

标签:style   io   ar   color   使用   sp   for   on   bs   

原文地址:http://www.cnblogs.com/handsomer/p/4151403.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!