使用cropper.js裁切图片模糊

在使用cropper.js做裁剪是发现裁切的图片不够清晰,主要是由于canvas画图像素问题

解决方法:
context = canvas.getContext('2d'),
改为 context = canvas.getContext('2d').translate(0.5,0.5),即可

cropper.js代码位置

 function getSourceCanvas(image, data) {
    var canvas = $('')[0],
       context = canvas.getContext('2d').translate(0.5,0.5),
        width = data.naturalWidth,
        height = data.naturalHeight,
        rotate = data.rotate,
        rotated = getRotatedSizes({
          width: width,
          height: height,
          degree: rotate
        });

你可能感兴趣的:(使用cropper.js裁切图片模糊)