diff --git a/lib/generate_functions.py b/lib/generate_functions.py index 4e38f16..2fb26e4 100755 --- a/lib/generate_functions.py +++ b/lib/generate_functions.py @@ -122,6 +122,8 @@ def add_namespace_to_type(t: str) -> str: def make_return_cast(source_type: str, dest_type: str, inner: str) -> str: if source_type == dest_type: return inner + if "ExportImageToMemory" in inner: + return f"{inner}[0..@as(usize, @intCast(fileSize.*))]" if source_type in ["[*c]const u8", "[*c]u8"]: return f"std.mem.span({inner})" diff --git a/lib/raylib.zig b/lib/raylib.zig index f03dc08..1603144 100644 --- a/lib/raylib.zig +++ b/lib/raylib.zig @@ -3838,7 +3838,7 @@ pub fn exportImage(image: Image, fileName: [:0]const u8) bool { /// Export image to memory buffer pub fn exportImageToMemory(image: Image, fileType: [:0]const u8, fileSize: *i32) [:0]u8 { - return std.mem.span(cdef.ExportImageToMemory(image, @as([*c]const u8, @ptrCast(fileType)), @as([*c]c_int, @ptrCast(fileSize)))); + return cdef.ExportImageToMemory(image, @as([*c]const u8, @ptrCast(fileType)), @as([*c]c_int, @ptrCast(fileSize)))[0..@as(usize, @intCast(fileSize.*))]; } /// Export image as code file defining an array of bytes, returns true on success