转 mvc3 webimages

在System.Web.Helpers.DLL中提供一个类:WebImage

通过她可以方便的进行图片处理,她提供了对图片的切割、翻转、旋转、加文字水印或图片水印等功能。

创建Asp.net mvc3网站项目。

在Controller中添加如下代码:

代码
 1           private   static   readonly   string  ImagePath  =   @" C:\Users\Administrator\Desktop\1.png " ;
 2 
 3           ///   <summary>
 4           ///  源图
 5           ///   </summary>
 6           public   void  Origenal()
 7          {
 8               new  WebImage(ImagePath)
 9                  .Write();
10          }
11 
12           ///   <summary>
13           ///  切割
14           ///   </summary>
15           public   void  Cropping()
16          {
17               new  WebImage(ImagePath)
18                  .Crop( 10 , 30 , 50 , 100 )
19                  .Write();
20          }
21 
22           ///   <summary>
23           ///  水平翻转
24           ///   </summary>
25           public   void  HorizontalFilp()
26          {
27               new  WebImage(ImagePath)
28              .FlipHorizontal()
29              .Write();
30          }
31 
32           ///   <summary>
33           ///  垂直翻转
34           ///   </summary>
35           public   void  VerticalFilp()
36          {
37               new  WebImage(ImagePath)
38              .FlipVertical()
39              .Write();
40          }
41 
42           ///   <summary>
43           ///  重置大小
44           ///   </summary>
45           public   void  Resize()
46          {
47               new  WebImage(ImagePath)
48              .Resize( 100 100 )
49              .Write();
50          }
51 
52           ///   <summary>
53           ///  左旋转
54           ///   </summary>
55           public   void  RotateLeft()
56          {
57               new  WebImage(ImagePath)
58              .RotateLeft()
59              .Write();
60          }
61 
62           ///   <summary>
63           ///  右旋转
64           ///   </summary>
65           public   void  RotateRight()
66          {
67               new  WebImage(ImagePath)
68              .RotateRight()
69              .Write();
70          }
71 
72           ///   <summary>
73           ///  文字水印
74           ///   </summary>
75           public   void  TextWaterMark()
76          {
77               new  WebImage(ImagePath)
78              .AddTextWatermark( " Xaoxong " " Red " 14 " Bold " )
79              .Write();
80          }
81 
82           ///   <summary>
83           ///  图片水印
84           ///   </summary>
85           public   void  ImageWaterMark()
86          {
87              var img  =   new  WebImage(ImagePath)
88              .Resize( 100 100 );
89              
90               new  WebImage(ImagePath)
91              .AddImageWatermark(img)
92              .Write();
93          }

转载于:https://www.cnblogs.com/JosephLiu/archive/2010/11/06/1870563.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值