mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
Revert "stbi: fix loading image from memory (#15981); breaks UI's rectangle example on macos, probably others too"
This reverts commit 07d5612347
.
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
|
||||
data: stb_img.data
|
||||
ext: stb_img.ext
|
||||
id: ctx.image_cache.len
|
||||
}
|
||||
img.init_sokol_image()
|
||||
img.id = ctx.image_cache.len
|
||||
ctx.image_cache << img
|
||||
return img
|
||||
}
|
||||
|
@ -108,21 +108,13 @@ pub fn load(path string) ?Image {
|
||||
|
||||
// load_from_memory load an image from a memory buffer
|
||||
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{
|
||||
ok: true
|
||||
data: 0
|
||||
}
|
||||
flag := C.STBI_rgb_alpha
|
||||
res.data = C.stbi_load_from_memory(buf, bufsize, &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
|
||||
}
|
||||
flag)
|
||||
if isnil(res.data) {
|
||||
return error('stbi_image failed to load from memory')
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user