mirror of
https://github.com/vlang/v.git
synced 2025-09-11 16:36:20 -04:00
Revert "stbi: fix loading image from memory (#15981); breaks UI's rectangle example on macos, probably others too"
This reverts commit 07d5612347b408b0933a02c893d6122135f2b374.
This commit is contained in:
parent
8fc166d5a3
commit
3c25f506ed
@ -227,9 +227,8 @@ pub fn (mut ctx Context) create_image_from_memory(buf &u8, bufsize int) Image {
|
|||||||
ok: stb_img.ok
|
ok: stb_img.ok
|
||||||
data: stb_img.data
|
data: stb_img.data
|
||||||
ext: stb_img.ext
|
ext: stb_img.ext
|
||||||
|
id: ctx.image_cache.len
|
||||||
}
|
}
|
||||||
img.init_sokol_image()
|
|
||||||
img.id = ctx.image_cache.len
|
|
||||||
ctx.image_cache << img
|
ctx.image_cache << img
|
||||||
return img
|
return img
|
||||||
}
|
}
|
||||||
|
@ -108,21 +108,13 @@ pub fn load(path string) ?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) ?Image {
|
||||||
return load_from_memory_with_channels(buf, bufsize, 0)
|
|
||||||
}
|
|
||||||
|
|
||||||
// load_from_memory_with_channels an image from a memory buffer, with user-defined number of image channels
|
|
||||||
pub fn load_from_memory_with_channels(buf &u8, bufsize int, desired_channels int) ?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,
|
||||||
desired_channels)
|
flag)
|
||||||
if desired_channels == 4 && res.nr_channels == 3 {
|
|
||||||
// Fix an alpha png bug
|
|
||||||
res.nr_channels = 4
|
|
||||||
}
|
|
||||||
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')
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user