C# 使用c在asp.net中裁剪图像#

C# 使用c在asp.net中裁剪图像#,c#,jquery,asp.net,image,crop,C#,Jquery,Asp.net,Image,Crop,我正在使用c#开发asp.net。我必须通过拍摄图像的一部分来调整图像。 我想从中间裁剪一部分图像,如下图所示 有人能帮我吗。如果你是在服务器上做的,我建议使用System.Drawing,而不是直接使用System.Drawing 我的 自动 new ImageJob(source,dest,new ResizeSettings("width=200;height=200;mode=crop;anchor=middlecenter")).Build(); 手动(按百分比) 手动(在源图

我正在使用c#开发asp.net。我必须通过拍摄图像的一部分来调整图像。 我想从中间裁剪一部分图像,如下图所示


有人能帮我吗。

如果你是在服务器上做的,我建议使用System.Drawing,而不是直接使用System.Drawing

我的

自动

new ImageJob(source,dest,new 
 ResizeSettings("width=200;height=200;mode=crop;anchor=middlecenter")).Build();
手动(按百分比)

手动(在源图像坐标中)


如果您在服务器上执行此操作,我建议使用,而不是直接使用System.Drawing

我的

自动

new ImageJob(source,dest,new 
 ResizeSettings("width=200;height=200;mode=crop;anchor=middlecenter")).Build();
手动(按百分比)

手动(在源图像坐标中)


我通过Jquery获取图像部分的坐标来完成这项工作

jQuery(function($) {
        $('#target').Jcrop({
            onChange: showCoords,
            onSelect: showCoords,
            onRelease: clearCoords
        });
    });
    function showCoords(c) {
        $('#xaxis').val(c.x);
        $('#yaxis').val(c.y);
        $('#x2').val(c.x2);
        $('#y2').val(c.y2);
        $('#xwidth').val(c.w);
        $('#div_width').val(c.w);
        $('#yheight').val(c.h);
        $('#div_height').val(c.h);
    };
    function clearCoords() {
        $('#coords input').val('0');
        $('#yheight').css({ color: 'red' });
        window.setTimeout(function() {
            $('#yheight').css({ color: 'inherit' });
        }, 500);
    };
然后我用这些坐标裁剪出C#like的图像


这很好

我通过Jquery获取图像部分的坐标来完成这项工作

jQuery(function($) {
        $('#target').Jcrop({
            onChange: showCoords,
            onSelect: showCoords,
            onRelease: clearCoords
        });
    });
    function showCoords(c) {
        $('#xaxis').val(c.x);
        $('#yaxis').val(c.y);
        $('#x2').val(c.x2);
        $('#y2').val(c.y2);
        $('#xwidth').val(c.w);
        $('#div_width').val(c.w);
        $('#yheight').val(c.h);
        $('#div_height').val(c.h);
    };
    function clearCoords() {
        $('#coords input').val('0');
        $('#yheight').css({ color: 'red' });
        window.setTimeout(function() {
            $('#yheight').css({ color: 'inherit' });
        }, 500);
    };
然后我用这些坐标裁剪出C#like的图像


那很好

你试过什么?你为什么不试试谷歌搜索呢?你试过什么?你为什么不试试谷歌搜索呢?GenerateCroppedThumbNail做什么?为什么你不把它作为你答案的一部分,因为它似乎是我同意@Link64的最重要的一部分?GenerateCroppedThumbNail做什么?你为什么不把它作为你答案的一部分,因为它似乎是我同意@link64的最重要的部分
String savedFileName = uploadProfileImage(profileImageName, new System.Drawing.Rectangle(Int32.Parse(xaxis), Int32.Parse(yaxis), Int32.Parse(xwidth), Int32.Parse(yheight)));

public String uploadProfileImage(string profileImageName, System.Drawing.Rectangle rectangle)
    {
        try
        {
            String retFileName = "";
            if (profileImageName != null || profileImageName != "")
            {
                GenerateCroppedThumbNail(profileImageName, rectangle);
            }
            return retFileName;
        }
        catch (Exception)
        {
            return String.Empty;
        }
    }