zoukankan      html  css  js  c++  java
  • 一般处理程序画图打水印

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Web;
    using System.Drawing;
    
    namespace CZBK.ItcastProject.WebApp._2015_5_27
    {
        /// <summary>
        /// MakeImage 的摘要说明
        /// </summary>
        public class MakeImage : IHttpHandler
        {
    
            public void ProcessRequest(HttpContext context)
            {
                context.Response.ContentType = "text/html";
                //给用户创建一张图片,并把这张图片保存。
                //创建一张画布
                using (Bitmap map=new Bitmap(300,400))
                {
                    //给画布创建一个画笔
                    using (Graphics g=Graphics.FromImage(map))
                    {
                        //用画笔清除画布绘图面并以颜色填充
                        g.Clear(Color.Gray);
                        //在画布上写字,参数:写的字,字体样式,字体颜色,填充位置
                        g.DrawString("打上水印,哈哈哈", new Font("黑体", 14.0f, FontStyle.Bold), Brushes.Red,new PointF(150,200));
                        //将画布保存成一张图片
                        string fileName=Guid.NewGuid().ToString();
                        //将画布保存成一张图片并指定图片的类型。
                        map.Save(context.Request.MapPath("/ImageUpload/" + fileName + ".jpg"),System.Drawing.Imaging.ImageFormat.Jpeg);
                        //
                        context.Response.Write("<html><body><img src='/ImageUpload/" + fileName + ".jpg" + "' /></body></html>");
                    }
                }
    
            }
    
            public bool IsReusable
            {
                get
                {
                    return false;
                }
            }
        }
    }
  • 相关阅读:
    面试题总结
    h5c3新特性
    redis常用命令大全
    windows下挂载linux的nfs网络硬盘
    mysql之char、varchar、text对比
    Lua与C的交互
    通信模型socket
    程序编译流程
    区块链共识机制(POW、POS、DPOS等)的优缺点
    .net c#获取自定义Attribute
  • 原文地址:https://www.cnblogs.com/wyt007/p/6099142.html
Copyright © 2011-2022 走看看