From 701d1ab638b23c24877fc41824add66232446676 Mon Sep 17 00:00:00 2001 From: Christopher Speller Date: Thu, 2 Feb 2017 09:32:00 -0500 Subject: Updating server dependancies (#5249) --- vendor/github.com/disintegration/imaging/resize.go | 38 ++++++++++++---------- 1 file changed, 20 insertions(+), 18 deletions(-) (limited to 'vendor/github.com/disintegration/imaging/resize.go') diff --git a/vendor/github.com/disintegration/imaging/resize.go b/vendor/github.com/disintegration/imaging/resize.go index 3c792e904..b21eed544 100644 --- a/vendor/github.com/disintegration/imaging/resize.go +++ b/vendor/github.com/disintegration/imaging/resize.go @@ -128,20 +128,21 @@ func resizeHorizontal(src *image.NRGBA, width int, filter ResampleFilter) *image parallel(dstH, func(partStart, partEnd int) { for dstY := partStart; dstY < partEnd; dstY++ { for dstX := 0; dstX < dstW; dstX++ { - var c [4]int32 + var c [4]int64 for _, iw := range weights[dstX].iwpairs { i := dstY*src.Stride + iw.i*4 - c[0] += int32(src.Pix[i+0]) * iw.w - c[1] += int32(src.Pix[i+1]) * iw.w - c[2] += int32(src.Pix[i+2]) * iw.w - c[3] += int32(src.Pix[i+3]) * iw.w + a := int64(src.Pix[i+3]) * int64(iw.w) + c[0] += int64(src.Pix[i+0]) * a + c[1] += int64(src.Pix[i+1]) * a + c[2] += int64(src.Pix[i+2]) * a + c[3] += a } j := dstY*dst.Stride + dstX*4 sum := weights[dstX].wsum - dst.Pix[j+0] = clampint32(int32(float32(c[0])/float32(sum) + 0.5)) - dst.Pix[j+1] = clampint32(int32(float32(c[1])/float32(sum) + 0.5)) - dst.Pix[j+2] = clampint32(int32(float32(c[2])/float32(sum) + 0.5)) - dst.Pix[j+3] = clampint32(int32(float32(c[3])/float32(sum) + 0.5)) + dst.Pix[j+0] = clampint32(int32(float64(c[0])/float64(c[3]) + 0.5)) + dst.Pix[j+1] = clampint32(int32(float64(c[1])/float64(c[3]) + 0.5)) + dst.Pix[j+2] = clampint32(int32(float64(c[2])/float64(c[3]) + 0.5)) + dst.Pix[j+3] = clampint32(int32(float64(c[3])/float64(sum) + 0.5)) } } }) @@ -165,20 +166,21 @@ func resizeVertical(src *image.NRGBA, height int, filter ResampleFilter) *image. for dstX := partStart; dstX < partEnd; dstX++ { for dstY := 0; dstY < dstH; dstY++ { - var c [4]int32 + var c [4]int64 for _, iw := range weights[dstY].iwpairs { i := iw.i*src.Stride + dstX*4 - c[0] += int32(src.Pix[i+0]) * iw.w - c[1] += int32(src.Pix[i+1]) * iw.w - c[2] += int32(src.Pix[i+2]) * iw.w - c[3] += int32(src.Pix[i+3]) * iw.w + a := int64(src.Pix[i+3]) * int64(iw.w) + c[0] += int64(src.Pix[i+0]) * a + c[1] += int64(src.Pix[i+1]) * a + c[2] += int64(src.Pix[i+2]) * a + c[3] += a } j := dstY*dst.Stride + dstX*4 sum := weights[dstY].wsum - dst.Pix[j+0] = clampint32(int32(float32(c[0])/float32(sum) + 0.5)) - dst.Pix[j+1] = clampint32(int32(float32(c[1])/float32(sum) + 0.5)) - dst.Pix[j+2] = clampint32(int32(float32(c[2])/float32(sum) + 0.5)) - dst.Pix[j+3] = clampint32(int32(float32(c[3])/float32(sum) + 0.5)) + dst.Pix[j+0] = clampint32(int32(float64(c[0])/float64(c[3]) + 0.5)) + dst.Pix[j+1] = clampint32(int32(float64(c[1])/float64(c[3]) + 0.5)) + dst.Pix[j+2] = clampint32(int32(float64(c[2])/float64(c[3]) + 0.5)) + dst.Pix[j+3] = clampint32(int32(float64(c[3])/float64(sum) + 0.5)) } } -- cgit v1.2.3-1-g7c22