stbi: fixed panic when trying to load JPG (#13724)

pull/13728/head
Adam Oates 2022-03-13 07:57:34 +00:00 committed by GitHub
parent 27f9bc9ba0
commit 424ef0b2b8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 1 additions and 1 deletions

View File

@ -93,7 +93,7 @@ pub fn load(path string) ?Image {
data: 0
}
// flag := if ext == 'png' { C.STBI_rgb_alpha } else { 0 }
desired_channels := if ext == 'png' { 4 } 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 {