1
0
mirror of https://github.com/vlang/v.git synced 2023-08-10 21:13:21 +03:00

gg: always use 4 channels in init_sokol_image (#16564)

This commit is contained in:
Larpon
2022-12-01 16:54:37 +01:00
committed by GitHub
parent 161847ed1a
commit 6e24f7e13a
2 changed files with 16 additions and 8 deletions

View File

@ -117,14 +117,9 @@ pub fn load(path string) !Image {
ext: ext
data: 0
}
// flag := if ext == 'png' { C.STBI_rgb_alpha } else { 0 }
desired_channels := if ext in ['png', 'jpg', 'jpeg'] { 4 } else { 0 }
res.data = C.stbi_load(&char(path.str), &res.width, &res.height, &res.nr_channels,
desired_channels)
if desired_channels == 4 && res.nr_channels == 3 {
// Fix an alpha png bug
res.nr_channels = 4
}
C.STBI_rgb_alpha)
if isnil(res.data) {
return error('stbi_image failed to load from "${path}"')
}