From d4ae3cbcae507c2065afca9337b7da0791fce0d9 Mon Sep 17 00:00:00 2001 From: xiaoqidun Date: Sat, 12 Sep 2026 02:52:21 +0800 Subject: [PATCH] =?UTF-8?q?refactor(=E9=87=8D=E6=9E=84=E6=8F=90=E5=8D=87):?= =?UTF-8?q?=20=E4=BC=98=E5=8C=96=E5=9B=BE=E5=83=8F=E8=A3=81=E5=89=AA?= =?UTF-8?q?=E6=80=A7=E8=83=BD=EF=BC=8C=E4=BF=9D=E6=8C=81=E6=B8=B2=E6=9F=93?= =?UTF-8?q?=E7=BB=93=E6=9E=9C=E4=B8=80=E8=87=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ofdgo_renderer_image.go | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/ofdgo_renderer_image.go b/ofdgo_renderer_image.go index a09fb2f..9612d5f 100644 --- a/ofdgo_renderer_image.go +++ b/ofdgo_renderer_image.go @@ -194,6 +194,18 @@ func imageWithClip(img image.Image, clipPath *canvas.Path, m canvas.Matrix) imag } source := imagePixelSource(img) out := image.NewNRGBA(bounds) + if src, ok := source.(*image.NRGBA); ok { + 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) + } + } + return out + } 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)