stbi: add LoadParams to load_from_memory() as well (#19268)

This commit is contained in:
Peyton Creery 2023-09-04 01:24:34 -05:00 committed by GitHub
parent 18e60e77de
commit d04a3e52e3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -135,14 +135,13 @@ pub fn load(path string, params LoadParams) !Image {
} }
// load_from_memory load an image from a memory buffer // load_from_memory load an image from a memory buffer
pub fn load_from_memory(buf &u8, bufsize int) !Image { pub fn load_from_memory(buf &u8, bufsize int, params LoadParams) !Image {
mut res := Image{ mut res := Image{
ok: true ok: true
data: 0 data: 0
} }
flag := C.STBI_rgb_alpha
res.data = C.stbi_load_from_memory(buf, bufsize, &res.width, &res.height, &res.nr_channels, res.data = C.stbi_load_from_memory(buf, bufsize, &res.width, &res.height, &res.nr_channels,
flag) params.desired_channels)
if isnil(res.data) { if isnil(res.data) {
return error('stbi_image failed to load from memory') return error('stbi_image failed to load from memory')
} }