以base64格式返回图像,我有以下的代码来裁剪图像:无法加载资源:服务器500(内部服务器错误)的状态回应,同时从控制器
$.ajax({
type: "POST",
url: root("CropController/CropImage"),
data: {
imagePath: imagesrc,
cropPointX: parseInt(PointX),
cropPointY: parseInt(PointY),
imageCropWidth: parseInt(CropWidth),
imageCropHeight: parseInt(CropHeight)
}
}).done(function (dt) {
alert(dt.photo);
});
而控制器代码是:
public JsonResult CropImage(string imagePath, int? cropPointX, int? cropPointY, int? imageCropWidth, int? imageCropHeight)
{
string output = imagePath.Substring(imagePath.IndexOf(',') + 1);
byte[] imageBytes = Convert.FromBase64String(output);
//croppedImage will have the cropped part of the image.
byte[] croppedImage = ImageCroping.CropImage(imageBytes, cropPointX.Value, cropPointY.Value, imageCropWidth.Value, imageCropHeight.Value);
string photo = "data:image/jpeg;base64," + Convert.ToBase64String(croppedImage);
return Json(new { photoPath = photo }, JsonRequestBehavior.AllowGet);
}
如果种植面积较小,则在完成功能警报将被调用,但是当种植面积大,做功能不会触发它抛出的错误。任何人都可以帮助我这个。在此先感谢
你见过[这](http://stackoverflow.com/a/12278956/1429080 )回答? – user1429080