asp.Net 一些常用的方法和类(11)

来源:未知 责任编辑:责任编辑 发表时间:2013-11-17 14:40 点击:

                Graphics g = Graphics.FromImage(img);//通过图片对象创建画布 
                g.DrawImage(watering, new Rectangle(img.Width - watering.Width, img.Height - watering.Height, watering.Width, watering.Height), 0, 0, watering.Width, watering.Height, GraphicsUnit.Pixel);//画图 
                context.Response.ContentType = "image/jpeg";//设置图片的格式 
                img.Save(context.Response.OutputStream, ImageFormat.Jpeg);//把图片保存在输出流中 
                g.Dispose();//销毁画布 
                img.Dispose();//销毁图片 
                context.Response.End(); 
            } 
            else 
            { 
                Image defaultimg = Image.FromFile(context.Server.MapPath("~/themes/images/water.jpg"));//通过图片路径得到默认图片对象 
                Image watering = Image.FromFile(context.Server.MapPath("~/themes/images/water.jpg"));//得到数字水印图片 
                Graphics g = Graphics.FromImage(defaultimg);//通过图片对象创建画布 
                g.DrawImage(watering, new Rectangle(defaultimg.Width - watering.Width, defaultimg.Height - watering.Height, watering.Width, watering.Height), 0, 0, watering.Width, watering.Height, GraphicsUnit.Pixel);//画图 
 
                context.Response.ContentType = "image/jpeg";//设置图片的格式 
                defaultimg.Save(context.Response.OutputStream, ImageFormat.Jpeg); 
                g.Dispose(); 
                defaultimg.Dispose(); 
                context.Response.End(); 
发表评论
请自觉遵守互联网相关的政策法规,严禁发布色情、暴力、反动的言论。
用户名: 验证码:点击我更换图片
最新评论 更多>>

推荐热点

  • 浅析.NET下XML数据访问新机制
  • asp.net 面试+笔试题目第1/2页
  • C# 邮件地址是否合法的验证
  • asp.net 设置GridView的选中行的实现代码
  • C#高级编程:数据库连接[1]
  • 经典C++程序1
  • IIS 自动回收导致后台定时器失效的问题解决
  • ASP.NET GridView列表代码示例
  • Asp.net MVC源码分析--Action Filter的链式调用
网站首页 - 友情链接 - 网站地图 - TAG标签 - RSS订阅 - 内容搜索
Copyright © 2008-2015 计算机技术学习交流网. 版权所有

豫ICP备11007008号-1