zoukankan      html  css  js  c++  java
  • 图片简单处理

    前台

     
    <%@ Page Language="C#" AutoEventWireup="true" CodeFile="Pictrue.aspx.cs" Inherits="Make_Pictrue_Pictrue" %>
    
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head runat="server">
        <title></title>
        <style type="text/css">
        </style>
    </head>
    <body>
        <form id="form1" runat="server">
        <div>
            <asp:Image ID="IMG1" runat="server" ImageUrl="~/App_Themes/Image/0.jpg" />
            <asp:Image ID="IMG2" runat="server" />
            <asp:Image ID="IMG3" runat="server" />
            <asp:Image ID="IMG4" runat="server" />
            <br />
            
            <asp:Button ID="Btn_SuoFang" runat="server" Text="缩放" OnClick="Click_Btn_SuoFang" />
            <asp:Button ID="Btn_ZiCai" runat="server" Text="自定义缩放" OnClick="Click_Btn_ZiCai" />
            <asp:Button ID="Btn_ShuiYing" runat="server" Text="水印" OnClick="Click_Btn_ShuiYing" />
        </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;
    
    public partial class Make_Pictrue_Pictrue : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                
            }
        }
    
        /// <summary>
        /// 缩放图片
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void Click_Btn_SuoFang(object sender, EventArgs e)
        {
            Make_pictrue img = new Make_pictrue();
    
            System.IO.FileStream fs = new System.IO.FileStream(Server.MapPath("~/App_Themes/Image/0.jpg"), System.IO.FileMode.Open);
    
            byte[] buffer = new byte[fs.Length];
    
            fs.Read(buffer, 0, buffer.Length);
    
            string dirpath = Server.MapPath("~/App_Themes/Image/1.jpg");
    
            img.CutForSquare(fs, dirpath, 100, 100);
    
            fs.Close();
    
            IMG3.ImageUrl = "~/App_Themes/Image/1.jpg";
        }
    
    
        /// <summary>
        /// 自定义截图缩放
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void Click_Btn_ZiCai(object sender, EventArgs e)
        {
            Make_pictrue img = new Make_pictrue();
    
            System.IO.FileStream fs = new System.IO.FileStream(Server.MapPath("~/App_Themes/Image/0.jpg"), System.IO.FileMode.Open);
    
            byte[] buffer = new byte[fs.Length];
    
            fs.Read(buffer, 0, buffer.Length);
    
            string dirpath = Server.MapPath("~/App_Themes/Image/2.jpg");
    
            img.CutForCustom(fs, dirpath, 300, 300, 100);
    
            fs.Close();
    
            IMG2.ImageUrl = "~/App_Themes/Image/2.jpg";
        }
    
    
        /// <summary>
        /// 水印
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void Click_Btn_ShuiYing(object sender, EventArgs e)
        {
            Make_pictrue img = new Make_pictrue();
    
            System.IO.FileStream fs = new System.IO.FileStream(Server.MapPath("~/App_Themes/Image/0.jpg"), System.IO.FileMode.Open);
    
            byte[] buffer = new byte[fs.Length];
    
            fs.Read(buffer, 0, buffer.Length);
    
            string dirpath = Server.MapPath("~/App_Themes/Image/3.jpg");
    
            string Shuipath = Server.MapPath("~/App_Themes/Image/shuiyin.jpg");
    
            img.ZoomAuto(fs, dirpath,150,150,"123",Shuipath);
    
            fs.Close();
    
            IMG4.ImageUrl = "~/App_Themes/Image/3.jpg";
        }
    
    }

    简单的处理一下图片算是一点小积累~

    123

  • 相关阅读:
    HAProxy从零开始到掌握
    学会这15点,让你分分钟拿下Redis数据库
    求一个字符串长度
    js时间戳怎么转成日期格式
    js获取url参数值的两种方式
    js 处理URL实用技巧
    jQuery操作radio、checkbox、select 集合
    js处理url的技巧和归纳
    ajax hash缓存
    jquery ajax跨域
  • 原文地址:https://www.cnblogs.com/houlin/p/4228217.html
Copyright © 2011-2022 走看看