From 773846d8038b43cbc5b5c21abff816d1c8a80b66 Mon Sep 17 00:00:00 2001 From: xiaoqidun Date: Mon, 14 Sep 2026 00:11:20 +0800 Subject: [PATCH] =?UTF-8?q?feat(=E5=86=85=E5=AD=98=E5=8D=A0=E7=94=A8):=20?= =?UTF-8?q?=E4=BC=98=E5=8C=96=E5=9B=BE=E7=89=87=E8=A3=81=E5=89=AA=EF=BC=8C?= =?UTF-8?q?=E9=99=8D=E4=BD=8E=E5=86=85=E5=AD=98=E5=88=86=E9=85=8D=E4=B8=8E?= =?UTF-8?q?=E5=A4=84=E7=90=86=E5=BC=80=E9=94=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ofdgo_renderer_image.go | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/ofdgo_renderer_image.go b/ofdgo_renderer_image.go index c4a72de..ea0aa40 100644 --- a/ofdgo_renderer_image.go +++ b/ofdgo_renderer_image.go @@ -208,20 +208,19 @@ func imageWithClip(img image.Image, clipPath *canvas.Path, m canvas.Matrix) imag return img } source := imagePixelSource(img) + out := &image.NRGBA{Pix: mask.Pix, Stride: mask.Stride, Rect: bounds} if src, ok := source.(*image.NRGBA); ok { - out := image.NewNRGBA(bounds) for y := 0; y < h; y++ { offset := src.PixOffset(bounds.Min.X, bounds.Min.Y+y) row := out.Pix[y*out.Stride : y*out.Stride+w*4] - alpha := mask.Pix[y*mask.Stride : y*mask.Stride+w*4] - copy(row, src.Pix[offset:offset+w*4]) - for x := 3; x < len(row); x += 4 { - row[x] = uint8(int(row[x]) * int(alpha[x]) / 255) + pixels := src.Pix[offset : offset+w*4] + for x := 0; x < len(row); x += 4 { + copy(row[x:x+3], pixels[x:x+3]) + row[x+3] = uint8(int(pixels[x+3]) * int(row[x+3]) / 255) } } return out } - out := &image.NRGBA{Pix: mask.Pix, Stride: mask.Stride, Rect: bounds} for y := bounds.Min.Y; y < bounds.Max.Y; y++ { for x := bounds.Min.X; x < bounds.Max.X; x++ { c := imageNRGBAAt(source, x, y)