sahooz / oh-crop

OpenHarmony/HarmonyOS上的简单的图片剪裁库
MIT License
7 stars 0 forks source link

checkImageAdapt方法在处理缩放后大小不足填满取景框时有瑕疵 #4

Open duaiyun1314 opened 4 weeks ago

duaiyun1314 commented 4 weeks ago
if (this.model.frameWidth > showWidth || this.model.getFrameHeight() > showHeight) { // 图片缩放后,大小不足以填满取景框
      let xScale = this.model.frameWidth / showWidth;
      let yScale = this.model.getFrameHeight() / showHeight;
      let newScale = Math.max(xScale, yScale);
      this.model.scale = this.model.scale * newScale;
      hilog.error(0, "CropView", `Image new show0 at (${showX}, ${showY})   new scale:${this.model.scale} frameX:${frameX}`)
      showX *= newScale;
      showY *= newScale;
      hilog.error(0, "CropView", `Image new show at (${showX}, ${showY})   new scale:${this.model.scale} frameX:${frameX}`)
}

这块代码执行后model.scale发生改变,与之相关的showWidth、showHeight、imageX、imageY,scale等变量都应该重新计算下,否则后面使用这些变量的地方都将不准

sahooz commented 4 weeks ago

确实可能有这个问题,等这段时间忙完再来完善下