首页 > 其他 > 详细

GDI+(Graphics Device Interface)例子

时间:2014-12-08 17:39:18      阅读:276      评论:0      收藏:0      [点我收藏+]

使用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)例子

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

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!