소스 검색

Improve the way the new canvas size is calculated

If both dimensions are given, always use those dimensions, avoiding roundoff
error.

If only one dimension is given, slightly prefer rounding the other dimension
up, to rounding it down.
Jason Summers 13 년 전
부모
커밋
cdbd68f34f
1개의 변경된 파일1개의 추가작업 그리고 1개의 파일을 삭제
  1. 1 1
      resize.go

+ 1 - 1
resize.go

@@ -64,7 +64,7 @@ func Resize(width, height uint, img image.Image, interp InterpolationFunction) i
 	scaleX, scaleY := calcFactors(width, height, oldWidth, oldHeight)
 	t := Trans2{scaleX, 0, float32(oldBounds.Min.X), 0, scaleY, float32(oldBounds.Min.Y)}
 
-	resizedImg := image.NewRGBA64(image.Rect(0, 0, int(oldWidth/scaleX), int(oldHeight/scaleY)))
+	resizedImg := image.NewRGBA64(image.Rect(0, 0, int(0.7+oldWidth/scaleX), int(0.7+oldHeight/scaleY)))
 	b := resizedImg.Bounds()
 
 	n := numJobs(b.Dy())