zoukankan
html css js c++ java
给上传的图片加上一个水印
UpImage.aspx
<%
@ Page language
=
"
c#
"
Codebehind
=
"
UpImage.aspx.cs
"
AutoEventWireup
=
"
false
"
Inherits
=
"
Sand.WebForm4
"
%>
<!
DOCTYPE HTML PUBLIC
"
-//W3C//DTD HTML 4.0 Transitional//EN
"
>
<
HTML
>
<
HEAD
>
<
title
>
WebForm4
</
title
>
<
meta name
=
"
GENERATOR
"
Content
=
"
Microsoft Visual Studio .NET 7.1
"
>
<
meta name
=
"
CODE_LANGUAGE
"
Content
=
"
C#
"
>
<
meta name
=
"
vs_defaultClientScript
"
content
=
"
JavaScript
"
>
<
meta name
=
"
vs_targetSchema
"
content
=
"
http://schemas.microsoft.com/intellisense/ie5
"
>
</
HEAD
>
<
body MS_POSITIONING
=
"
GridLayout
"
>
<
form id
=
"
Form1
"
method
=
"
post
"
runat
=
"
server
"
>
<
FONT face
=
"
宋体
"
><
INPUT id
=
"
UpFile
"
style
=
"
Z-INDEX: 101; LEFT: 256px; POSITION: absolute; TOP: 152px
"
type
=
"
file
"
runat
=
"
server
"
><
INPUT id
=
"
Submit_File
"
style
=
"
Z-INDEX: 102; LEFT: 504px; POSITION: absolute; TOP: 152px
"
type
=
"
button
"
value
=
"
上传
"
name
=
"
Button1
"
runat
=
"
server
"
></
FONT
>
</
form
>
</
body
>
</
HTML
>
UpImage.aspx.cs
private
void
Button1_ServerClick(
object
sender, System.EventArgs e)
{
//
上传文件
string
UpFileName
=
UpFile.PostedFile.FileName.Substring(UpFile.PostedFile.FileName.LastIndexOf(
"
\\
"
),UpFile.PostedFile.FileName.Length
-
UpFile.PostedFile.FileName.LastIndexOf(
"
\\
"
));
UpFile.PostedFile.SaveAs(Server.MapPath(
"
Images\\
"
+
UpFileName));
//
给上传的文件添加水印
System.Drawing.Image YImage
=
System.Drawing.Image.FromFile(Server.MapPath(
"
Images\\
"
+
UpFileName));
//
获取要添加水印的图片
System.Drawing.Image SYImage
=
System.Drawing.Image.FromFile(Server.MapPath(
"
Images\\shiyin.png
"
));
//
获取水印的图片
System.Drawing.Graphics G
=
System.Drawing.Graphics.FromImage(YImage);
G.DrawImage(SYImage,
new
System.Drawing.Rectangle(
new
System.Drawing.Point(
0
,
0
),
new
System.Drawing.Size(SYImage.Width,SYImage.Height)),
5
,
9
,SYImage.Width,SYImage.Height,System.Drawing.GraphicsUnit.Pixel);
YImage.Save(Server.MapPath(
"
Images\\sss.jpg
"
));
G.Dispose();
G
=
null
;
SYImage.Dispose();
SYImage
=
null
;
YImage.Dispose();
YImage
=
null
;
}
查看全文
相关阅读:
触发器(2)
触发器
GZipStream
MemoryStream类读写内存
ashx一般处理程序
Redmin 一键安装
Unity3D和网页数据交互的基本原理
apk MIME类型
[leetcode]Valid Sudoku
[leetcode]Search in Rotated Sorted Array
原文地址:https://www.cnblogs.com/Sandheart/p/94834.html
最新文章
在Docker上部署使用Azure CLI镜像
Linux上使用Azure CLI来管理Azure
Azure File文件共享(6):使用Python开发
利用Azure Automation实现云端自动化运维(3)
利用Azure Automation实现云端自动化运维(1)
利用Azure Automation实现云端自动化运维(2)
利用Azure Automation实现云端自动化运维(4)
使用Python管理Azure(1):基础配置
你不知道的HTTP之首部字段一览
Django之admin的使用及源码分析
热门文章
NumPy库的基本使用
单例模式
MongoDB详解
爬虫基本原理及requests,response详解
《实时控制软件设计》第一次阅读笔记
《实时控制软件设计》第一个编程作业
《实时控制软件设计》教学计划
《实时控制软件设计》课程
SQL Server RAISERROR() 函数
SQL Server OBJECT_ID() 函数
Copyright © 2011-2022 走看看