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;
                }
            }
        }
    }
  • 相关阅读:
    iOS 网络优化--页面返回的时候取消网络请求
    iOS 内存管理
    realm数据库使用
    KNN 算法分类电影类型
    sklearn库学习之01
    Python 生成4位验证码图片
    Python——读写Excel文件
    KNN--用于手写数字识别
    Python基础学习-'module' object has no attribute 'urlopen'解决方法
    swift_通知的使用
  • 原文地址:https://www.cnblogs.com/wyt007/p/6099142.html
Copyright © 2011-2022 走看看