zoukankan
html css js c++ java
象yhoo相册那样在网页上操作图片(不完全)_2
操作页面后面代码
protected
System.Web.UI.WebControls.Image MyImage;
//
private System.Drawing.Image ResultImg = null;
private
void
Page_Load(
object
sender, System.EventArgs e)
{
//
在此处放置用户代码以初始化页面
if
(
!
Page.IsPostBack)
{
urlStr.Value
=
"
fileName=3_21165.jpg
"
;
ChangImag();
}
}
private
void
Button1_Click(
object
sender, System.EventArgs e)
{
string
strFilename
=
string
.Empty;
System.Drawing.Image i;
strFilename
=
Server.MapPath(
"
img/3_21165.jpg
"
);
i
=
System.Drawing.Image.FromFile(strFilename);
System.Drawing.Bitmap b
=
new
System.Drawing.Bitmap(
500
,
600
);
Graphics g
=
System.Drawing.Graphics.FromImage(b);
//
'切割图片
g.DrawImage(i,
new
Rectangle(
0
,
0
,b.Width,b.Height),
200
,
20
,b.Width,b.Height,GraphicsUnit.Pixel);
Response.ContentType
=
"
image/jpeg
"
;
b.Save(Server.MapPath(
"
img/1.jpg
"
),System.Drawing.Imaging.ImageFormat.Jpeg);
b.Dispose();
Response.Write(
"
<script language='javascript'>alert('OK');</script>
"
);
}
private
void
TurnOne_Click(
object
sender, System.Web.UI.ImageClickEventArgs e)
{
//翻转
#region
//
翻转
string
goUrl
=
urlStr.Value;
int
i
=
goUrl.IndexOf(
"
ring
"
);
if
(i
==-
1
)
{
goUrl
+=
"
&ring=Rotate180FlipY
"
;
}
else
{
string
donum
=
null
;
for
(
int
j
=
i
+
5
;j
<
goUrl.Length;j
++
)
{
if
(goUrl.Substring(j,
1
)
!=
"
&
"
)
{
donum
+=
goUrl.Substring(j,
1
);
}
else
{
break
;
}
}
switch
(donum)
{
case
"
Rotate90FlipNone
"
:
goUrl
=
goUrl.Replace(
"
&ring=Rotate90FlipNone
"
,
"
&ring=Rotate90FlipX
"
);
break
;
case
"
Rotate180FlipNone
"
:
goUrl
=
goUrl.Replace(
"
&ring=Rotate180FlipNone
"
,
"
&ring=Rotate180FlipX
"
);
break
;
case
"
Rotate270FlipNone
"
:
goUrl
=
goUrl.Replace(
"
&ring=Rotate270FlipNone
"
,
"
&ring=Rotate90FlipY
"
);
break
;
case
"
Rotate90FlipX
"
:
goUrl
=
goUrl.Replace(
"
&ring=Rotate90FlipX
"
,
"
&ring=Rotate90FlipNone
"
);
break
;
case
"
Rotate180FlipX
"
:
goUrl
=
goUrl.Replace(
"
&ring=Rotate180FlipX
"
,
"
&ring=Rotate180FlipNone
"
);
break
;
case
"
Rotate270FlipX
"
:
goUrl
=
goUrl.Replace(
"
&ring=Rotate270FlipX
"
,
"
&ring=Rotate90FlipXY
"
);
break
;
case
"
RotateNoneFlipX
"
:
goUrl
=
goUrl.Replace(
"
&ring=RotateNoneFlipX
"
,
""
);
break
;
case
"
Rotate90FlipY
"
:
goUrl
=
goUrl.Replace(
"
&ring=Rotate90FlipY
"
,
"
&ring=Rotate270FlipNone
"
);
break
;
case
"
Rotate180FlipY
"
:
goUrl
=
goUrl.Replace(
"
&ring=Rotate180FlipY
"
,
""
);
break
;
case
"
Rotate270FlipY
"
:
goUrl
=
goUrl.Replace(
"
&ring=Rotate270FlipY
"
,
"
&ring=Rotate90FlipNone
"
);
break
;
case
"
RotateNoneFlipY
"
:
goUrl
=
goUrl.Replace(
"
&ring=RotateNoneFlipY
"
,
"
&ring=Rotate180FlipNone
"
);
break
;
case
"
Rotate90FlipXY
"
:
goUrl
=
goUrl.Replace(
"
&ring=Rotate90FlipXY
"
,
"
&ring=Rotate270FlipX
"
);
break
;
case
"
Rotate180FlipXY
"
:
goUrl
=
goUrl.Replace(
"
&ring=Rotate180FlipXY
"
,
"
&ring=RotateNoneFlipX
"
);
break
;
case
"
Rotate270FlipXY
"
:
goUrl
=
goUrl.Replace(
"
&ring=Rotate270FlipXY
"
,
"
&ring=Rotate90FlipX
"
);
break
;
case
"
RotateNoneFlipXY
"
:
goUrl
=
goUrl.Replace(
"
&ring=RotateNoneFlipXY
"
,
"
&ring=RotateNoneFlipY
"
);
break
;
}
}
#endregion
urlStr.Value
=
goUrl;
ChangImag();
}
private
void
ChangImag()
{
MyImage.ImageUrl
=
"
MyImg.aspx?
"
+
urlStr.Value;
}
private
void
GoRr_Click(
object
sender, System.Web.UI.ImageClickEventArgs e)
{
//顺时钟
#region
//
顺时钟
string
goUrl
=
urlStr.Value;
int
i
=
goUrl.IndexOf(
"
ring
"
);
if
(i
==-
1
)
{
goUrl
+=
"
&ring=Rotate90FlipNone
"
;
}
else
{
string
donum
=
null
;
for
(
int
j
=
i
+
5
;j
<
goUrl.Length;j
++
)
{
if
(goUrl.Substring(j,
1
)
!=
"
&
"
)
{
donum
+=
goUrl.Substring(j,
1
);
}
else
{
break
;
}
}
switch
(donum)
{
case
"
Rotate90FlipNone
"
:
goUrl
=
goUrl.Replace(
"
&ring=Rotate90FlipNone
"
,
"
&ring=Rotate180FlipNone
"
);
break
;
case
"
Rotate180FlipNone
"
:
goUrl
=
goUrl.Replace(
"
&ring=Rotate180FlipNone
"
,
"
&ring=Rotate270FlipNone
"
);
break
;
case
"
Rotate270FlipNone
"
:
goUrl
=
goUrl.Replace(
"
&ring=Rotate270FlipNone
"
,
""
);
break
;
case
"
Rotate90FlipX
"
:
goUrl
=
goUrl.Replace(
"
&ring=Rotate90FlipX
"
,
"
&ring=RotateNoneFlipX
"
);
break
;
case
"
Rotate180FlipX
"
:
goUrl
=
goUrl.Replace(
"
&ring=Rotate180FlipX
"
,
"
&ring=Rotate90FlipX
"
);
break
;
case
"
Rotate270FlipX
"
:
goUrl
=
goUrl.Replace(
"
&ring=Rotate270FlipX
"
,
"
&ring=Rotate180FlipX
"
);
break
;
case
"
RotateNoneFlipX
"
:
goUrl
=
goUrl.Replace(
"
&ring=RotateNoneFlipX
"
,
"
&ring=Rotate270FlipX
"
);
break
;
case
"
Rotate90FlipY
"
:
goUrl
=
goUrl.Replace(
"
&ring=Rotate90FlipY
"
,
"
&ring=RotateNoneFlipY
"
);
break
;
case
"
Rotate180FlipY
"
:
goUrl
=
goUrl.Replace(
"
&ring=Rotate180FlipY
"
,
"
&ring=Rotate90FlipY
"
);
break
;
case
"
Rotate270FlipY
"
:
goUrl
=
goUrl.Replace(
"
&ring=Rotate270FlipY
"
,
"
&ring=Rotate180FlipY
"
);
break
;
case
"
RotateNoneFlipY
"
:
goUrl
=
goUrl.Replace(
"
&ring=RotateNoneFlipY
"
,
"
&ring=Rotate270FlipY
"
);
break
;
case
"
Rotate90FlipXY
"
:
goUrl
=
goUrl.Replace(
"
&ring=Rotate90FlipXY
"
,
"
&ring=Rotate180FlipXY
"
);
break
;
case
"
Rotate180FlipXY
"
:
goUrl
=
goUrl.Replace(
"
&ring=Rotate180FlipXY
"
,
"
&ring=Rotate270FlipXY
"
);
break
;
case
"
Rotate270FlipXY
"
:
goUrl
=
goUrl.Replace(
"
&ring=Rotate270FlipXY
"
,
"
&ring=RotateNoneFlipXY
"
);
break
;
case
"
RotateNoneFlipXY
"
:
goUrl
=
goUrl.Replace(
"
&ring=RotateNoneFlipXY
"
,
"
&ring=Rotate90FlipXY
"
);
break
;
}
}
#endregion
urlStr.Value
=
goUrl;
ChangImag();
}
private
void
GoRl_Click(
object
sender, System.Web.UI.ImageClickEventArgs e)
{
//逆时钟
#region
//
逆时钟
string
goUrl
=
urlStr.Value;
int
i
=
goUrl.IndexOf(
"
ring
"
);
if
(i
==-
1
)
{
goUrl
+=
"
&ring=Rotate270FlipNone
"
;
}
else
{
string
donum
=
null
;
for
(
int
j
=
i
+
5
;j
<
goUrl.Length;j
++
)
{
if
(goUrl.Substring(j,
1
)
!=
"
&
"
)
{
donum
+=
goUrl.Substring(j,
1
);
}
else
{
break
;
}
}
switch
(donum)
{
case
"
Rotate90FlipNone
"
:
goUrl
=
goUrl.Replace(
"
&ring=Rotate90FlipNone
"
,
""
);
break
;
case
"
Rotate180FlipNone
"
:
goUrl
=
goUrl.Replace(
"
&ring=Rotate180FlipNone
"
,
"
&ring=Rotate90FlipNone
"
);
break
;
case
"
Rotate270FlipNone
"
:
goUrl
=
goUrl.Replace(
"
&ring=Rotate270FlipNone
"
,
"
&ring=Rotate180FlipNone
"
);
break
;
case
"
RotateNoneFlipX
"
:
goUrl
=
goUrl.Replace(
"
&ring=RotateNoneFlipX
"
,
"
&ring=Rotate90FlipX
"
);
break
;
case
"
Rotate90FlipX
"
:
goUrl
=
goUrl.Replace(
"
&ring=Rotate90FlipX
"
,
"
&ring=Rotate180FlipX
"
);
break
;
case
"
Rotate180FlipX
"
:
goUrl
=
goUrl.Replace(
"
&ring=Rotate180FlipX
"
,
"
&ring=Rotate270FlipX
"
);
break
;
case
"
Rotate270FlipX
"
:
goUrl
=
goUrl.Replace(
"
&ring=Rotate270FlipX
"
,
"
&ring=RotateNoneFlipX
"
);
break
;
case
"
RotateNoneFlipY
"
:
goUrl
=
goUrl.Replace(
"
&ring=RotateNoneFlipY
"
,
"
&ring=Rotate90FlipY
"
);
break
;
case
"
Rotate90FlipY
"
:
goUrl
=
goUrl.Replace(
"
&ring=Rotate90FlipY
"
,
"
&ring=Rotate180FlipY
"
);
break
;
case
"
Rotate180FlipY
"
:
goUrl
=
goUrl.Replace(
"
&ring=Rotate180FlipY
"
,
"
&ring=Rotate270FlipY
"
);
break
;
case
"
Rotate270FlipY
"
:
goUrl
=
goUrl.Replace(
"
&ring=Rotate270FlipY
"
,
"
&ring=RotateNoneFlipY
"
);
break
;
case
"
RotateNoneFlipXY
"
:
goUrl
=
goUrl.Replace(
"
&ring=RotateNoneFlipXY
"
,
"
&ring=Rotate270FlipXY
"
);
break
;
case
"
Rotate90FlipXY
"
:
goUrl
=
goUrl.Replace(
"
&ring=Rotate90FlipXY
"
,
"
&ring=RotateNoneFlipXY
"
);
break
;
case
"
Rotate180FlipXY
"
:
goUrl
=
goUrl.Replace(
"
&ring=Rotate180FlipXY
"
,
"
&ring=Rotate90FlipXY
"
);
break
;
case
"
Rotate270FlipXY
"
:
goUrl
=
goUrl.Replace(
"
&ring=Rotate270FlipXY
"
,
"
&ring=Rotate180FlipXY
"
);
break
;
}
}
#endregion
urlStr.Value
=
goUrl;
ChangImag();
}
private
void
ContCut_Click(
object
sender, System.Web.UI.ImageClickEventArgs e)
{
对比减小
#region
对比减小
string
goUrl
=
urlStr.Value;
int
i
=
goUrl.IndexOf(
"
Contrast
"
);
string
donum
=
null
;
if
(i
==-
1
)
{
goUrl
+=
"
&Contrast=-0.1
"
;
}
else
{
for
(
int
j
=
i
+
9
;j
<
goUrl.Length;j
++
)
{
if
(goUrl.Substring(j,
1
)
!=
"
&
"
)
{
donum
+=
goUrl.Substring(j,
1
);
}
else
{
break
;
}
}
double
brightnum
=
0
;
try
{
brightnum
=
double
.Parse(donum);
}
catch
{
brightnum
=
0
;
}
if
(brightnum
>-
1
&&
brightnum
<=
1
)
{
brightnum
-=
0.1
;
}
goUrl
=
goUrl.Replace(
"
&Contrast=
"
+
donum,
"
&Contrast=
"
+
brightnum.ToString());
}
urlStr.Value
=
goUrl;
ChangImag();
#endregion
}
private
void
ContAdd_Click(
object
sender, System.Web.UI.ImageClickEventArgs e)
{
对比增加
#region
对比增加
string
goUrl
=
urlStr.Value;
int
i
=
goUrl.IndexOf(
"
Contrast
"
);
string
donum
=
null
;
if
(i
==-
1
)
{
goUrl
+=
"
&Contrast=0.1
"
;
}
else
{
for
(
int
j
=
i
+
9
;j
<
goUrl.Length;j
++
)
{
if
(goUrl.Substring(j,
1
)
!=
"
&
"
)
{
donum
+=
goUrl.Substring(j,
1
);
}
else
{
break
;
}
}
double
brightnum
=
0
;
try
{
brightnum
=
double
.Parse(donum);
}
catch
{
brightnum
=
0
;
}
if
(brightnum
>=-
1
&&
brightnum
<
1
)
{
brightnum
+=
0.1
;
}
goUrl
=
goUrl.Replace(
"
&Contrast=
"
+
donum,
"
&Contrast=
"
+
brightnum.ToString());
}
urlStr.Value
=
goUrl;
ChangImag();
#endregion
}
private
void
BrightAdd_Click(
object
sender, System.Web.UI.ImageClickEventArgs e)
{
亮度增加
#region
亮度增加
string
goUrl
=
urlStr.Value;
int
i
=
goUrl.IndexOf(
"
Bright
"
);
string
donum
=
null
;
if
(i
==-
1
)
{
goUrl
+=
"
&Bright=1.1
"
;
}
else
{
for
(
int
j
=
i
+
7
;j
<
goUrl.Length;j
++
)
{
if
(goUrl.Substring(j,
1
)
!=
"
&
"
)
{
donum
+=
goUrl.Substring(j,
1
);
}
else
{
break
;
}
}
double
brightnum
=
1
;
try
{
brightnum
=
double
.Parse(donum);
}
catch
{
brightnum
=
1
;
}
if
(brightnum
>=
0
&&
brightnum
<
3
)
{
brightnum
+=
0.1
;
}
goUrl
=
goUrl.Replace(
"
&Bright=
"
+
donum,
"
&Bright=
"
+
brightnum.ToString());
}
urlStr.Value
=
goUrl;
ChangImag();
#endregion
}
private
void
BrightCut_Click(
object
sender, System.Web.UI.ImageClickEventArgs e)
{
亮度减少
#region
亮度减少
string
goUrl
=
urlStr.Value;
int
i
=
goUrl.IndexOf(
"
Bright
"
);
if
(i
==-
1
)
{
goUrl
+=
"
&Bright=0.9
"
;
}
else
{
string
donum
=
null
;
for
(
int
j
=
i
+
7
;j
<
goUrl.Length;j
++
)
{
if
(goUrl.Substring(j,
1
)
!=
"
&
"
)
{
donum
+=
goUrl.Substring(j,
1
);
}
else
{
break
;
}
}
double
brightnum
=
1
;
try
{
brightnum
=
double
.Parse(donum);
}
catch
{
brightnum
=
1
;
}
if
(brightnum
>
0
&&
brightnum
<=
3
)
{
brightnum
-=
0.1
;
}
goUrl
=
goUrl.Replace(
"
&Bright=
"
+
donum,
"
&Bright=
"
+
brightnum.ToString());
}
urlStr.Value
=
goUrl;
ChangImag();
#endregion
}
查看全文
相关阅读:
Largest Rectangle in Histogram, 求矩形图中最大的长方形面积
MergeSortedArray,合并两个有序的数组
Remove Duplicates from Sorted List ,除去链表中相邻的重复元素
Word Search, 在矩阵中寻找字符串,回溯算法
SubSets,SubSets2, 求数组所有子集
Longest Substring Without Repeating Characters,求没有重复字符的最长字串
Minimum Window Substring, 包含子串的最小窗口,双指针
Sort Colors,颜色排序
Search a 2D Matrix,在有序矩阵查找,二分查找的变形; 行有序,列有序查找。
EditDistance,求两个字符串最小编辑距离,动态规划
原文地址:https://www.cnblogs.com/cerxp/p/80870.html
最新文章
6053: Lawrence(区间DP+四边形不等式优化)
6018: Buy Tickets(线段树单点更新)
6069: Detachment(乘法逆元)
1546: Just Pour the Water(矩阵快速幂+思维)
2037: [Sdoi2008]Sue的小球(区间DP)
P1220 关路灯(区间DP)
1428 漫步校园(记忆化搜索)
【UVA10118】Free Candies(记忆化搜索)
1501 Zipper(dp或dfs)
滑雪(记忆化搜索)
热门文章
Binary Tree(hdu 5573 思维题)
The Game of Life (队列+map)
Cats and Fish (模拟)
Selecting courses(hdu 3697 贪心
A hard Aoshu Problem(hdu 3699 暴力枚举
Fermat Point in Quadrangle(hdu 3694 求两直线交点
5845: A^B的约数和(因子和与因子个数
National Day Parade(hdu3687 模拟 easy
Ugly Windows (hdu 2487 模拟题 easy
Roundgod and Milk Tea(多校8 ,1011 )贪心
Copyright © 2011-2022 走看看