图片简单处理

前台

<%@ 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";
    }

}

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

时间: 2024-08-03 09:50:53

图片简单处理的相关文章

分别用css3、JS实现图片简单的无缝轮播功效

本文主要介绍分别使用CSS3.JS实现图片简单无缝轮播功效: 一.使用CSS3实现:利用animation属性 (实现一张一张的轮播,肉眼只看见一张图片) HTML部分比较简单,两个div下包着几个img标签:为了实现无缝轮播,注意第一张图片要与最后一张图片相同: <div class="out"> <div class="imgs"> <img src="img/beatuy.jpg"/> <img s

Android剪裁图片简单的方法

/** * 按正方形裁切图片 */ public static Bitmap ImageCrop(Bitmap bitmap) { int w = bitmap.getWidth(); // 得到图片的宽,高 int h = bitmap.getHeight(); int wh = w > h ? h : w;// 裁切后所取的正方形区域边长 int retX = w > h ? (w - h) / 2 : 0;//基于原图,取正方形左上角x坐标 int retY = w > h ? 0

Android:使用ViewPager实现左右滑动切换图片 (简单版)

ViewPager,它是google SDk中自带的一个附加包的一个类, 可以使视图滑动. 步骤: 1.引入android-support-v4.jar包,在主布局里加入 <android.support.v4.view.ViewPager android:id="@+id/viewPager" android:layout_width="match_parent" android:layout_height="wrap_content"

跑马灯抽奖,本地图片简单实现

公司要做个抽奖功能,写了两个demo,这个是使用本地图片的跑马灯抽奖.加载的本地图片,这种的比较简单.想“跑”起来原理也很简单.      一个是控制好线程sleep时间,sleep时做图片的变换,变换指的就是用滚动的图片依次替换下一个图片.      再一个就是图片的定位,这个根据当前图片位置就可以精确计算了,比用WheelView做的老\虎\机容易定位.      我还添加了SoundPool 让每次变动都有一个声音,这样更像游戏. 注意额:跑马灯还可以做成网络图片版本,稍微复杂一点,处理好

android获取拍照图片、本地图片简单实现!

在安卓应用开发中经常会用到调用系统相机拍照跟获取本地图片功能,下面就是对这一常用功能的简单实现Demo! 在获取拍照图片功能中要加上这两权限. <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" /> <uses-permission android:name="android.permission.CAMERA" /> 布局文件 1 <Re

Python2.7 基于bs4与requests库的网页图片简单爬取

爬虫入门新手,自学笔记,如果理解有错误请指正. import requests from bs4 import BeautifulSoup import urllib url = 'http://www.nipic.com/index.html' #图片网站 data = requests.get(url) #获取网站响应 soup = BeautifulSoup(data.text,'html.parser') #解析 imgs = soup.find_all('img') Beautiful

机器学习入门之python实现图片简单分类

小任务:实现图片分类 1.图片素材 python批量压缩jpg图片: PIL库 resize http://blog.csdn.net/u012234115/article/details/50248409 2.环境搭建 windows下python的安装 版本比较 2.7 vs 3.6 https://pypi.python.org/pypi windows下PIL库的安装 https://pypi.python.org/pypi windows下PIL库的安装 http://zjfsharp

python下载图片简单教程

通过urlretrieve方法import os#导入os包,没有该模块的可通过pip installl 命令安装模块from urllib.request import urlretrieve#导入urllib模块IMAGE_URL="https://bpic.588ku.com/element_pic/00/16/10/21580951c08d0a9.jpg!/fw/208/quality/90/unsharp/true/compress/true"#设置一个图片的url,随便一个

javascript:第一章 练习 图片简单切换

<!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> <meta http-equiv="Content-