ASP.NET Ajax实现图片剪裁

ASP.NET Ajax实现图片剪裁
-

实现这个功能主要用到了JQuery和基于JQuery的图片处理插件JCrop

JQuery可以下载下来,或者在代码中这样引用<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3/jquery.min.js"></script>
JCrop
需要下载,其中还包括相应的一些例子可以作为参考。

这个例子有三部分功能,一、图片上传,二、现实用户上传上来的图片,三、图片剪裁。
主要的流程是:用户上传图片,显示图片,在用户点击剪裁按钮之后,用ajax的方式显示剪裁之后的图片。
上传图片就用的ASP.NET自带的文件上传控件,整个文件上传功能放在一个用户空间里面。
每次用户上传了图片以后,文件存放的位置持久化在一个xml文件中。
在用
JCrop实现剪裁功能的时候,需要在页面中添加一些隐藏域来
存储图片剪裁中用到的坐标和宽高等数据。剪裁则用JQueryAjax功能实现。


 1  <% @ Page Language = " C# "  AutoEventWireup = " true "  CodeFile = " Default.aspx.cs "  Inherits = " Pages_Default "   %>
 2 
 3
  <% @ Register Src = " ../Controls/ImageUpload.ascx "  TagName = " ImageUpload "  TagPrefix = " uc1 "  %>
 4
  <! DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
 5
  < html  xmlns ="http://www.w3.org/1999/xhtml" >
 6
  < head  runat ="server" >
 7
       < title ></ title >
 8
 
 9
       < script  src ="../Scripts/jquery.min.js"  type ="text/javascript" ></ script >
10
 
11
       < script  src ="../Scripts/jquery.Jcrop.js"  type ="text/javascript" ></ script >
12
 
13
       < link  href ="../Style/jquery.Jcrop.css"  rel ="stylesheet"  type ="text/css"   />
14
       < link  href ="../Style/demos.css"  rel ="stylesheet"  type ="text/css"   />
15
 
16
       < script  type ="text/javascript"  language ="Javascript" >
17
 
18
           //  Remember to invoke within jQuery(window).load(ASP.NET Ajax实现图片剪裁)
19
           //  If you don't, Jcrop may not initialize properly
20
          jQuery(document).ready( function() {
21 
22
              jQuery( ' #cropbox ').Jcrop({
23                   // onChange: showCoords,
24
                  onSelect: showCoords
25              });
26 
27
          });
28 
29
           function onCropClick() {
30 
31
               // alert("{ pPartStartPointX: '" + $('#x').val() + "', pPartStartPointY: '" + $('#y').val() + "', pPartWidth: '" + $('#w').val() + "', pPartHeight: '" + $('#h').val() + "'}");
32
              $.ajax({
33                  type:  " POST ",
34                  contentType:  " application/json; charset=utf-8 ",
35                  data:  " { pPartStartPointX: ' "   +  $( ' #x ' ).val()  +   " ', pPartStartPointY: ' "   +  $( ' #y ' ).val()  +   " ', pPartWidth: ' "   +  $( ' #w ' ).val()  +   " ', pPartHeight: ' "   +  $( ' #h ' ).val()  +   " '} ",
36                  url:  " Default.aspx/CroppedImage ",
37                  dataType:  " json ",
38                  success:  function(data) {
39                       // alert(data.d);
40
                       // $("#CustomerDetails").html(data);
41
                      $( ' #disp ' ).html( " <img src=' "   +  data.d  +   " ' alt='' /> ");
42                  }
43              });
44          }
45 
46
           //  Our simple event handler, called from onChange and onSelect
47
           //  event handlers, as per the Jcrop invocation above
48
           function showCoords(c) {
49              jQuery( ' #x ').val(c.x);
50              jQuery( ' #y ').val(c.y);
51               // jQuery('#x2').val(c.x2);
52
               // jQuery('#y2').val(c.y2);
53
              jQuery( ' #w ').val(c.w);
54              jQuery( ' #h ').val(c.h);
55          };
56 
57
       </ script >
58
 
59
  </ head >
60
  < body >
61
       < form  id ="form1"  runat ="server" >
62
       < div >
63
           <!--  This is the image we're attaching Jcrop to  -->
64
           < img  runat ="server"  id ="cropbox"   />
65
           < input  type ="button"  id ="btnCrop"  value =" Crop Image "  onclick ="onCropClick();"   />
66
           < div  id ="disp" >
67
           </ div >
68
           < label >
69
               <% -- X1 -- %>
70
               < input  type ="hidden"  size ="4"  id ="x"  name ="x"   /></ label >
71
           < label >
72
               <% -- Y1 -- %>
73
               < input  type ="hidden"  size ="4"  id ="y"  name ="y"   /></ label >
74
           < label >
75
               <% -- X2 -- %>
76
               < input  type ="hidden"  size ="4"  id ="x2"  name ="x2"   /></ label >
77
           < label >
78
               <% -- Y2 -- %>
79
               < input  type ="hidden"  size ="4"  id ="y2"  name ="y2"   /></ label >
80
           < label >
81
               <% -- W -- %>
82
               < input  type ="hidden"  size ="4"  id ="w"  name ="w"   /></ label >
83
           < label >
84
               <% -- H -- %>
85
               < input  type ="hidden"  size ="4"  id ="h"  name ="h"   /></ label >
86           < uc1:ImageUpload  ID ="ImageUpload1"  runat ="server"   />
87       </ div >
88       </ form >
89  </ body >
90  </ html >

注意在页面代码中添加需要的javascript和css样式表

1 ASP.NET Ajax实现图片剪裁 < script  src ="../Scripts/jquery.min.js"  type ="text/javascript" ></ script >
2 ASP.NET Ajax实现图片剪裁 < script  src ="../Scripts/jquery.Jcrop.js"  type ="text/javascript" ></ script >
3 ASP.NET Ajax实现图片剪裁 < link  href ="../Style/jquery.Jcrop.css"  rel ="stylesheet"  type ="text/css"   />
4 ASP.NET Ajax实现图片剪裁 < link  href ="../Style/demos.css"  rel ="stylesheet"  type ="text/css"   />


然后我们需要添加调用JCrop的代码来实现图片的剪裁

 1 ASP.NET Ajax实现图片剪裁      < script  type ="text/javascript"  language ="Javascript" >
 2ASP.NET Ajax实现图片剪裁
 3ASP.NET Ajax实现图片剪裁        jQuery(document).ready(function() {
 4ASP.NET Ajax实现图片剪裁
 5ASP.NET Ajax实现图片剪裁            jQuery('#cropbox').Jcrop({
 6ASP.NET Ajax实现图片剪裁                onSelect: showCoords
 7ASP.NET Ajax实现图片剪裁            }
);
 8ASP.NET Ajax实现图片剪裁        }
);
 9ASP.NET Ajax实现图片剪裁
10ASP.NET Ajax实现图片剪裁        function onCropClick() {
11ASP.NET Ajax实现图片剪裁
12ASP.NET Ajax实现图片剪裁            $.ajax({
13ASP.NET Ajax实现图片剪裁                type: "POST",
14ASP.NET Ajax实现图片剪裁                contentType: "application/json; charset=utf-8",
15ASP.NET Ajax实现图片剪裁                data: "{ pPartStartPointX: '" + $('#x').val() + "', pPartStartPointY: '" + $('#y').val() + "', pPartWidth: '" + $('#w').val() + "', pPartHeight: '" + $('#h').val() + "'}",
16ASP.NET Ajax实现图片剪裁                url: "Default.aspx/CroppedImage",
17ASP.NET Ajax实现图片剪裁                dataType: "json",
18ASP.NET Ajax实现图片剪裁                success: function(data) {
19ASP.NET Ajax实现图片剪裁                    $('#disp').html("<img src='" + data.d + "' alt='' />");
20ASP.NET Ajax实现图片剪裁                }

21ASP.NET Ajax实现图片剪裁            }
);
22ASP.NET Ajax实现图片剪裁        }

23ASP.NET Ajax实现图片剪裁
24ASP.NET Ajax实现图片剪裁        function showCoords(c) {
25ASP.NET Ajax实现图片剪裁            jQuery('#x').val(c.x);
26ASP.NET Ajax实现图片剪裁            jQuery('#y').val(c.y);
27ASP.NET Ajax实现图片剪裁            jQuery('#w').val(c.w);
28ASP.NET Ajax实现图片剪裁            jQuery('#h').val(c.h);
29ASP.NET Ajax实现图片剪裁        }
;
30ASP.NET Ajax实现图片剪裁
31ASP.NET Ajax实现图片剪裁    
</ script >

这个代码都很简单。JCrop处理id为cropbox的img中的图片。在onSelect事件中添加函数showCoords来记录用户选中图片区域的数据。
并在剪裁按钮的点击事件中实现Ajax的功能,将后台处理好的图片显示在页面上。

所需的命名空间
1 ASP.NET Ajax实现图片剪裁 using  System;
2 ASP.NET Ajax实现图片剪裁 using  System.Web;
3 ASP.NET Ajax实现图片剪裁 using  System.Web.Services;

为什么要用System.Web.Services这个命名空间呢,因为我们用JQuery调用后台代码时用的是后台的页面方法
 1 ASP.NET Ajax实现图片剪裁     [WebMethod]
 2 ASP.NET Ajax实现图片剪裁     public   static   string  CroppedImage( int  pPartStartPointX,  int  pPartStartPointY,  int  pPartWidth,  int  pPartHeight)
 3 ASP.NET Ajax实现图片剪裁     {
 4ASP.NET Ajax实现图片剪裁        XmlHelper xmlHelper = new XmlHelper();
 5ASP.NET Ajax实现图片剪裁        xmlHelper.XmlPath = HttpContext.Current.Server.MapPath("~/App_Data/ImagePaths.xml");
 6ASP.NET Ajax实现图片剪裁        string originalPath = xmlHelper.GetImagepath();
 7ASP.NET Ajax实现图片剪裁        string savePath = HttpContext.Current.Server.MapPath("~/Images/CropImg/");
 8ASP.NET Ajax实现图片剪裁        string filename = ImageHelper.CropImage(originalPath, savePath, pPartWidth, pPartHeight, pPartStartPointX, pPartStartPointY);
 9ASP.NET Ajax实现图片剪裁
10ASP.NET Ajax实现图片剪裁        string fullpath = "../Images/CropImg/" + filename;
11ASP.NET Ajax实现图片剪裁        return fullpath;
12ASP.NET Ajax实现图片剪裁    }

前面提到过用户控件,上传图片并记录图片的存放路径。存放图片路径主要通过类XmlHelper来实现。
<% @ Control Language = " C# "  AutoEventWireup = " true "  CodeFile = " ImageUpload.ascx.cs "  Inherits = " Controls_ImageUpload "   %>
<% --< asp:PlaceHolder ID = " imageContainer "  runat = " server " ></ asp:PlaceHolder >-- %>
< table >
    
< tr >
        
< td >
            
< asp:FileUpload  ID ="imgUpload"  runat ="server"   />
        
</ td >
    
</ tr >
    
< tr >
        
< td >
            
< asp:Button  ID ="btnUpload"  runat ="server"  Text =" Up Load "  
                onclick
="btnUpload_Click"   />
        
</ td >
    
</ tr >
</ table >

后台代码
 1 ASP.NET Ajax实现图片剪裁 using  System;
 2 ASP.NET Ajax实现图片剪裁 using  System.Web.UI.HtmlControls;
 3 ASP.NET Ajax实现图片剪裁
 4 ASP.NET Ajax实现图片剪裁 public   partial   class  Controls_ImageUpload : System.Web.UI.UserControl
 5 ASP.NET Ajax实现图片剪裁 {
 6ASP.NET Ajax实现图片剪裁    private readonly string IMG_PATH = "~/Images/Upload/";
 7ASP.NET Ajax实现图片剪裁    private XmlHelper _xmlHelper = new XmlHelper();
 8ASP.NET Ajax实现图片剪裁
 9ASP.NET Ajax实现图片剪裁    /// <summary>
10ASP.NET Ajax实现图片剪裁    /// Name of a control to operate
11ASP.NET Ajax实现图片剪裁    /// </summary>

12ASP.NET Ajax实现图片剪裁    public string ControlName getset; }
13ASP.NET Ajax实现图片剪裁
14ASP.NET Ajax实现图片剪裁    protected void Page_Load(object sender, EventArgs e)
15ASP.NET Ajax实现图片剪裁    {
16ASP.NET Ajax实现图片剪裁        if (!IsPostBack)
17ASP.NET Ajax实现图片剪裁        {
18ASP.NET Ajax实现图片剪裁            SetPathInfo();
19ASP.NET Ajax实现图片剪裁        }

20ASP.NET Ajax实现图片剪裁    }

21ASP.NET Ajax实现图片剪裁
22ASP.NET Ajax实现图片剪裁    protected void btnUpload_Click(object sender, EventArgs e)
23ASP.NET Ajax实现图片剪裁    {
24ASP.NET Ajax实现图片剪裁        try
25ASP.NET Ajax实现图片剪裁        {
26ASP.NET Ajax实现图片剪裁            // Specify the path on the server to
27ASP.NET Ajax实现图片剪裁            // save the uploaded file to.
28ASP.NET Ajax实现图片剪裁            String savePath = Server.MapPath(IMG_PATH);
29ASP.NET Ajax实现图片剪裁
30ASP.NET Ajax实现图片剪裁            // Before attempting to perform operations
31ASP.NET Ajax实现图片剪裁            // on the file, verify that the FileUpload 
32ASP.NET Ajax实现图片剪裁            // control contains a file.
33ASP.NET Ajax实现图片剪裁            if (imgUpload.HasFile)
34ASP.NET Ajax实现图片剪裁            {
35ASP.NET Ajax实现图片剪裁                // Get the name of the file to upload.
36ASP.NET Ajax实现图片剪裁                String fileName = imgUpload.FileName;
37ASP.NET Ajax实现图片剪裁
38ASP.NET Ajax实现图片剪裁                // Append the name of the file to upload to the path.
39ASP.NET Ajax实现图片剪裁                savePath += fileName;
40ASP.NET Ajax实现图片剪裁
41ASP.NET Ajax实现图片剪裁                // Call the SaveAs method to save the 
42ASP.NET Ajax实现图片剪裁                // uploaded file to the specified path.
43ASP.NET Ajax实现图片剪裁                // This example does not perform all
44ASP.NET Ajax实现图片剪裁                // the necessary error checking.               
45ASP.NET Ajax实现图片剪裁                // If a file with the same name
46ASP.NET Ajax实现图片剪裁                // already exists in the specified path,  
47ASP.NET Ajax实现图片剪裁                // the uploaded file overwrites it.
48ASP.NET Ajax实现图片剪裁                imgUpload.SaveAs(savePath);
49ASP.NET Ajax实现图片剪裁
50ASP.NET Ajax实现图片剪裁                _xmlHelper.XmlPath = Server.MapPath("~/App_Data/ImagePaths.xml");
51ASP.NET Ajax实现图片剪裁                _xmlHelper.StoreImagePath(savePath);
52ASP.NET Ajax实现图片剪裁
53ASP.NET Ajax实现图片剪裁                SetPathInfo();
54ASP.NET Ajax实现图片剪裁            }

55ASP.NET Ajax实现图片剪裁        }

56ASP.NET Ajax实现图片剪裁        catch (Exception)
57ASP.NET Ajax实现图片剪裁        {
58ASP.NET Ajax实现图片剪裁            this.Page.ClientScript.RegisterStartupScript(this.GetType(), """alert('Image can not be uploaded, please check!'"true);
59ASP.NET Ajax实现图片剪裁        }

60ASP.NET Ajax实现图片剪裁    }

61ASP.NET Ajax实现图片剪裁
62ASP.NET Ajax实现图片剪裁
63ASP.NET Ajax实现图片剪裁    private void SetPathInfo()
64ASP.NET Ajax实现图片剪裁    {
65ASP.NET Ajax实现图片剪裁        string serverPath = "~/Images/Upload/";
66ASP.NET Ajax实现图片剪裁
67ASP.NET Ajax实现图片剪裁        XmlHelper xmlHelper = new XmlHelper();
68ASP.NET Ajax实现图片剪裁        xmlHelper.XmlPath = Server.MapPath("~/App_Data/ImagePaths.xml");
69ASP.NET Ajax实现图片剪裁        string imgPath = xmlHelper.GetImagepath();
70ASP.NET Ajax实现图片剪裁        string filename = GetFileName(imgPath);
71ASP.NET Ajax实现图片剪裁
72ASP.NET Ajax实现图片剪裁        serverPath += filename;
73ASP.NET Ajax实现图片剪裁
74ASP.NET Ajax实现图片剪裁        HtmlImage cropbox = (HtmlImage)Parent.FindControl("cropbox");
75ASP.NET Ajax实现图片剪裁        if (cropbox != null)
76ASP.NET Ajax实现图片剪裁            cropbox.Src = serverPath;
77ASP.NET Ajax实现图片剪裁        HtmlImage preview = (HtmlImage)Parent.FindControl("preview");
78ASP.NET Ajax实现图片剪裁        if (preview != null)
79ASP.NET Ajax实现图片剪裁            preview.Src = serverPath;
80ASP.NET Ajax实现图片剪裁
81ASP.NET Ajax实现图片剪裁        Context.Items["imgsrc"= serverPath;
82ASP.NET Ajax实现图片剪裁    }

83ASP.NET Ajax实现图片剪裁
84ASP.NET Ajax实现图片剪裁    private string GetFileName(string fullname)
85ASP.NET Ajax实现图片剪裁    {
86ASP.NET Ajax实现图片剪裁        // Validation of string is not implemented temperarily
87ASP.NET Ajax实现图片剪裁        int index = fullname.LastIndexOf("\\");
88ASP.NET Ajax实现图片剪裁        string filename = fullname.Substring(index + 1);
89ASP.NET Ajax实现图片剪裁
90ASP.NET Ajax实现图片剪裁        return filename;
91ASP.NET Ajax实现图片剪裁    }

92ASP.NET Ajax实现图片剪裁}

93 ASP.NET Ajax实现图片剪裁

XmlHelper类中用到的主要方法
 1 ASP.NET Ajax实现图片剪裁 public   void  StoreImagePath( string  img)
 2 ASP.NET Ajax实现图片剪裁     {
 3ASP.NET Ajax实现图片剪裁        try
 4ASP.NET Ajax实现图片剪裁        {
 5ASP.NET Ajax实现图片剪裁            if (_xdoc == null)
 6ASP.NET Ajax实现图片剪裁            {
 7ASP.NET Ajax实现图片剪裁                _xdoc = XDocument.Load(XmlPath);
 8ASP.NET Ajax实现图片剪裁            }

 9ASP.NET Ajax实现图片剪裁
10ASP.NET Ajax实现图片剪裁            _xdoc.Root.Descendants().Remove();
11ASP.NET Ajax实现图片剪裁            _xdoc.Root.Add(new XElement("path", img));
12ASP.NET Ajax实现图片剪裁            _xdoc.Save(this.XmlPath);
13ASP.NET Ajax实现图片剪裁        }

14ASP.NET Ajax实现图片剪裁        catch
15ASP.NET Ajax实现图片剪裁        {
16ASP.NET Ajax实现图片剪裁            throw new Exception("Error occured in adding image path.");
17ASP.NET Ajax实现图片剪裁        }

18ASP.NET Ajax实现图片剪裁    }

19 ASP.NET Ajax实现图片剪裁
20 ASP.NET Ajax实现图片剪裁     public   string  GetImagepath()
21 ASP.NET Ajax实现图片剪裁     {
22ASP.NET Ajax实现图片剪裁        string imagePath = string.Empty;
23ASP.NET Ajax实现图片剪裁
24ASP.NET Ajax实现图片剪裁        try
25ASP.NET Ajax实现图片剪裁        {
26ASP.NET Ajax实现图片剪裁            if (_xdoc == null)
27ASP.NET Ajax实现图片剪裁            {
28ASP.NET Ajax实现图片剪裁                _xdoc = XDocument.Load(XmlPath);
29ASP.NET Ajax实现图片剪裁            }

30ASP.NET Ajax实现图片剪裁
31ASP.NET Ajax实现图片剪裁            imagePath = _xdoc.Root.Descendants().First().Value.ToString();
32ASP.NET Ajax实现图片剪裁        }

33ASP.NET Ajax实现图片剪裁        catch
34ASP.NET Ajax实现图片剪裁        {
35ASP.NET Ajax实现图片剪裁            throw new Exception("Error occured in getting image path.");
36ASP.NET Ajax实现图片剪裁        }

37ASP.NET Ajax实现图片剪裁
38ASP.NET Ajax实现图片剪裁        return imagePath;
39ASP.NET Ajax实现图片剪裁    }

之后就是一个很重要的方法了。剪裁图片的方法,放在ImageHelper类中。
 1 ASP.NET Ajax实现图片剪裁 public   static   string  CropImage( string  originamImgPath,  string  imgPath,  int  width,  int  height,  int  x,  int  y)
 2 ASP.NET Ajax实现图片剪裁     {
 3ASP.NET Ajax实现图片剪裁        string filename = DateTime.Now.ToString("yyyyMMddHHmmss"+ ".jpg";
 4ASP.NET Ajax实现图片剪裁        byte[] CropImage = Crop(originamImgPath, width, height, x, y);
 5ASP.NET Ajax实现图片剪裁        using (MemoryStream ms = new MemoryStream(CropImage, 0, CropImage.Length))
 6ASP.NET Ajax实现图片剪裁        {
 7ASP.NET Ajax实现图片剪裁            ms.Write(CropImage, 0, CropImage.Length);
 8ASP.NET Ajax实现图片剪裁            using (System.Drawing.Image CroppedImage = System.Drawing.Image.FromStream(ms, true))
 9ASP.NET Ajax实现图片剪裁            {
10ASP.NET Ajax实现图片剪裁                string SaveTo = imgPath + filename;
11ASP.NET Ajax实现图片剪裁                CroppedImage.Save(SaveTo, CroppedImage.RawFormat);
12ASP.NET Ajax实现图片剪裁            }

13ASP.NET Ajax实现图片剪裁        }

14ASP.NET Ajax实现图片剪裁
15ASP.NET Ajax实现图片剪裁        return filename;
16ASP.NET Ajax实现图片剪裁    }

17 ASP.NET Ajax实现图片剪裁
18 ASP.NET Ajax实现图片剪裁     private   static   byte [] Crop( string  Img,  int  Width,  int  Height,  int  X,  int  Y)
19 ASP.NET Ajax实现图片剪裁     {
20ASP.NET Ajax实现图片剪裁        try
21ASP.NET Ajax实现图片剪裁        {
22ASP.NET Ajax实现图片剪裁            using (Image OriginalImage = Image.FromFile(Img))
23ASP.NET Ajax实现图片剪裁            {
24ASP.NET Ajax实现图片剪裁                using (Bitmap bmp = new Bitmap(Width, Height, OriginalImage.PixelFormat))
25ASP.NET Ajax实现图片剪裁                {
26ASP.NET Ajax实现图片剪裁                    bmp.SetResolution(OriginalImage.HorizontalResolution, OriginalImage.VerticalResolution);
27ASP.NET Ajax实现图片剪裁                    using (Graphics Graphic = Graphics.FromImage(bmp))
28ASP.NET Ajax实现图片剪裁                    {
29ASP.NET Ajax实现图片剪裁                        Graphic.SmoothingMode = SmoothingMode.AntiAlias;
30ASP.NET Ajax实现图片剪裁                        Graphic.InterpolationMode = InterpolationMode.HighQualityBicubic;
31ASP.NET Ajax实现图片剪裁                        Graphic.PixelOffsetMode = PixelOffsetMode.HighQuality;
32ASP.NET Ajax实现图片剪裁                        Graphic.DrawImage(OriginalImage, new Rectangle(00, Width, Height), X, Y, Width, Height, GraphicsUnit.Pixel);
33ASP.NET Ajax实现图片剪裁                        MemoryStream ms = new MemoryStream();
34ASP.NET Ajax实现图片剪裁                        bmp.Save(ms, OriginalImage.RawFormat);
35ASP.NET Ajax实现图片剪裁                        return ms.GetBuffer();
36ASP.NET Ajax实现图片剪裁                    }

37ASP.NET Ajax实现图片剪裁                }

38ASP.NET Ajax实现图片剪裁            }

39ASP.NET Ajax实现图片剪裁        }

40ASP.NET Ajax实现图片剪裁        catch (Exception Ex)
41ASP.NET Ajax实现图片剪裁        {
42ASP.NET Ajax实现图片剪裁            throw (Ex);
43ASP.NET Ajax实现图片剪裁        }

44ASP.NET Ajax实现图片剪裁    }

看下效果,demo阶段先不做优化了。
开始
ASP.NET Ajax实现图片剪裁

显示上传的图片
ASP.NET Ajax实现图片剪裁

图片剪裁
ASP.NET Ajax实现图片剪裁

ASP.NET Ajax实现图片剪裁

就写到这里了,希望这篇对大家有帮助!

你可能感兴趣的:(asp.net)