From 1432562c6f11cf9fbde50c4c955f72cfa470d45c Mon Sep 17 00:00:00 2001 From: xiaoqidun Date: Fri, 16 Oct 2026 00:48:56 +0800 Subject: [PATCH] =?UTF-8?q?feat(=E5=9B=BE=E5=83=8F=E5=A4=84=E7=90=86):=20?= =?UTF-8?q?=E4=BC=98=E5=8C=96=E5=9B=BE=E5=83=8F=E9=87=8D=E9=87=87=E6=A0=B7?= =?UTF-8?q?=E6=80=A7=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- internal/base/image/scale.go | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/internal/base/image/scale.go b/internal/base/image/scale.go index c3bf1af..2fac6a4 100644 --- a/internal/base/image/scale.go +++ b/internal/base/image/scale.go @@ -189,11 +189,8 @@ func rasterImageHorizontal(row []rasterImagePixel, src image.RGBA64Image, sample clear(row) first, last := samples[0], samples[len(samples)-1] reversed := first.first > last.first || first.first == last.first && len(first.weights) > len(last.weights) - start, end := samples[0].first, samples[0].first+len(samples[0].weights) - for _, sample := range samples[1:] { - start = min(start, sample.first) - end = max(end, sample.first+len(sample.weights)) - } + start := min(first.first, last.first) + end := max(first.first+len(first.weights), last.first+len(last.weights)) active, next := 0, 0 for x := start; x < end; x++ { for next < len(samples) { @@ -217,6 +214,7 @@ func rasterImageHorizontal(row []rasterImagePixel, src image.RGBA64Image, sample active++ } p := src.RGBA64At(x, y) + r, g, b, a := float64(p.R), float64(p.G), float64(p.B), float64(p.A) for column := active; column < next; column++ { index := column if reversed { @@ -226,10 +224,10 @@ func rasterImageHorizontal(row []rasterImagePixel, src image.RGBA64Image, sample weight := sample.weights[x-sample.first] if weight != 0 { value := &row[index] - value.r += float64(p.R) * weight - value.g += float64(p.G) * weight - value.b += float64(p.B) * weight - value.a += float64(p.A) * weight + value.r += r * weight + value.g += g * weight + value.b += b * weight + value.a += a * weight } } }