zoukankan      html  css  js  c++  java
  • 图片水印

    <%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>
    
    <!DOCTYPE html>
    
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head runat="server">
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
        <title></title>
    </head>
    <body>
        <form id="form1" runat="server">
        <div>
            <asp:FileUpload ID="FileUpload1" runat="server" />
            <asp:Button ID="Button1" runat="server" Text="上传" /><br />
            <asp:Image ID="Image1" runat="server" />
        </div>
        </form>
    </body>
    </html>
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Web;
    using System.Web.UI;
    using System.Web.UI.WebControls;
    using System.Drawing;
    
    public partial class _Default : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            Button1.Click += Button1_Click;   //上传按钮点击事件
        }
    
        //上传按钮点击事件
        void Button1_Click(object sender, EventArgs e)
        {
            //1、创建画布
            System.Drawing.Image img = System.Drawing.Image.FromStream(FileUpload1.FileContent);
            Graphics g = Graphics.FromImage(img);
            
            //2、选择画笔、颜色
            Brush b = new SolidBrush(Color.WhiteSmoke);
    
            //3、设置字体,大小
            Font f = new Font("黑体", 28);
    
            //4、编辑内容
            string s = "南娜官方网站";
    
            //5、绘画,设置位置  
            g.DrawString(s, f, b, 100, 100);
    
            //6、保存画好的图片
            string path="Default"+FileUpload1.FileName;
            img.Save(Server.MapPath(path));
            Image1.ImageUrl = path;
        }
    }

  • 相关阅读:
    Ocaml入门(3)
    Delphi数组成员丢失
    Delphi合并2个动态数组
    Delphi用指针读取数组某个元素
    Delphi函数返回数组之TList函数返回
    Delphi函数返回数组之使用TList参数
    Delphi让函数返回数组
    Delphi双向链表
    Delphi指针与string
    Delphi函数指针,用于加载DLL
  • 原文地址:https://www.cnblogs.com/xiao55/p/6005713.html
Copyright © 2011-2022 走看看