stbi: change Image.data from voidptr to &u8, to reduce casts (#21977)

This commit is contained in:
Delyan Angelov 2024-08-01 09:02:38 +03:00 committed by GitHub
parent ef0457d6e3
commit fdd0dab1c3
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -42,7 +42,7 @@ pub mut:
height int
nr_channels int
ok bool
data voidptr
data &u8 = unsafe { nil }
ext string
}
@ -124,7 +124,6 @@ pub fn load(path string, params LoadParams) !Image {
mut res := Image{
ok: true
ext: ext
data: 0
}
res.data = C.stbi_load(&char(path.str), &res.width, &res.height, &res.nr_channels,
params.desired_channels)
@ -139,7 +138,6 @@ pub fn load(path string, params LoadParams) !Image {
pub fn load_from_memory(buf &u8, bufsize int, params LoadParams) !Image {
mut res := Image{
ok: true
data: 0
}
res.data = C.stbi_load_from_memory(buf, bufsize, &res.width, &res.height, &res.nr_channels,
params.desired_channels)
@ -162,7 +160,6 @@ pub fn resize_uint8(img &Image, output_w int, output_h int) !Image {
mut res := Image{
ok: true
ext: img.ext
data: 0
width: output_w
height: output_h
nr_channels: img.nr_channels