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;
                }
            }
        }
    }
  • 相关阅读:
    vue类似tab切换的效果,显示和隐藏的判断。
    vue 默认展开详情页
    vue echarts圆角阴影效果
    vue画图运用echarts
    随机函数rand()
    Qt解析CSV文件
    Qt生成CSV 文件
    QRegExp解析
    Qt中csv文件的导入与导出
    Qt 生成word、pdf文档
  • 原文地址:https://www.cnblogs.com/wyt007/p/6099142.html
Copyright © 2011-2022 走看看