refactor(重构代码): 提升代码水平
build.yaml / build (push) Successful in 33s

This commit is contained in:
2026-07-09 11:10:47 +08:00
parent fa3260c108
commit 9eb9104380
5 changed files with 119 additions and 40 deletions
+6
View File
@@ -85,6 +85,9 @@ func imageWithAlpha(img image.Image, alpha *int) image.Image {
return img
}
a := clampColor(*alpha)
if a == 255 {
return img
}
bounds := img.Bounds()
out := image.NewNRGBA(bounds)
for y := bounds.Min.Y; y < bounds.Max.Y; y++ {
@@ -109,6 +112,9 @@ func imageWithTransparentEdge(img image.Image) (image.Image, int) {
if w == 0 || h == 0 {
return img, 0
}
if opaque, ok := img.(interface{ Opaque() bool }); ok && opaque.Opaque() {
return img, 0
}
src := image.NewNRGBA(image.Rect(0, 0, w, h))
hasZero, hasVisible := false, false
for y := 0; y < h; y++ {