mirror of https://github.com/Wox-launcher/Wox
fix(windows): validate extracted icon content in `convertIconToImage`
* Added a check to ensure the extracted icon is not empty or fully transparent. * This prevents issues with displaying icons that do not have valid visual content.
This commit is contained in:
parent
250f3607f6
commit
fe23eed7b6
|
@ -383,6 +383,22 @@ func (a *WindowsRetriever) convertIconToImage(ctx context.Context, hIcon win.HIC
|
|||
}
|
||||
}
|
||||
|
||||
// Validate that the image has actual content (not just transparent pixels)
|
||||
hasContent := false
|
||||
bounds := img.Bounds()
|
||||
for y := bounds.Min.Y; y < bounds.Max.Y && !hasContent; y++ {
|
||||
for x := bounds.Min.X; x < bounds.Max.X && !hasContent; x++ {
|
||||
r, g, b, a := img.At(x, y).RGBA()
|
||||
if a > 0 && (r > 0 || g > 0 || b > 0) {
|
||||
hasContent = true
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if !hasContent {
|
||||
return nil, fmt.Errorf("extracted icon is empty or fully transparent")
|
||||
}
|
||||
|
||||
return img, nil
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue