From c5abb3667a4f49367c80655a1816c43ddd870fa9 Mon Sep 17 00:00:00 2001 From: xiaoqidun Date: Sat, 12 Sep 2026 03:57:59 +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=E9=80=8F=E6=98=8E=E5=BA=A6?= =?UTF-8?q?=E5=A4=84=E7=90=86=E6=80=A7=E8=83=BD=EF=BC=8C=E4=BF=9D=E6=8C=81?= =?UTF-8?q?=E6=B8=B2=E6=9F=93=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 | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/ofdgo_renderer_image.go b/ofdgo_renderer_image.go index 8a89827..aaf4763 100644 --- a/ofdgo_renderer_image.go +++ b/ofdgo_renderer_image.go @@ -289,6 +289,17 @@ func imageWithAlpha(img image.Image, alpha *int) image.Image { bounds := img.Bounds() out := image.NewNRGBA(bounds) source := imagePixelSource(img) + if src, ok := source.(*image.NRGBA); ok { + for y := 0; y < bounds.Dy(); y++ { + offset := src.PixOffset(bounds.Min.X, bounds.Min.Y+y) + row := out.Pix[y*out.Stride : (y+1)*out.Stride] + copy(row, src.Pix[offset:offset+len(row)]) + for x := 3; x < len(row); x += 4 { + row[x] = uint8(int(row[x]) * a / 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)