| 1 | #cxx . . $ `<file>/dokidoki-support/lua_stb_image.c`/include <lua.h> |
| 2 | #include <lauxlib.h> |
| 3 | #include <lualib.h> |
| 4 | |
| 5 | #define STBI_NO_WRITEcxx . . $ `dokidoki-support/lua_stb_image.c:5:9`! |
| 6 | #define STBI_NO_HDRcxx . . $ `dokidoki-support/lua_stb_image.c:6:9`! |
| 7 | #include "stb_image.c"cxx . . $ `<file>/dokidoki-support/stb_image.c`/ |
| 8 | |
| 9 | static int check_req_compcxx . . $ check_req_comp(95e3aa3a3b4bb934).(lua_Statecxx . . $ lua_State# *L, int index) |
| 10 | { |
| 11 | int req_comp = luaL_optintcxx . . $ `<external>/18095755238171912061/lauxlib.h:105:9`!(L, 2, 0); |
| 12 | luaL_argcheckcxx . . $ `<external>/18095755238171912061/lauxlib.h:100:9`!(L, 0 <= req_comp && req_comp <= 4, 2, |
| 13 | "invalid requested component count"); |
| 14 | return req_comp; |
| 15 | } |
| 16 | |
| 17 | static int return_imagecxx . . $ return_image(d88b2741f351bdb9).(lua_Statecxx . . $ lua_State# *L, unsigned char * image, int x, int y, |
| 18 | int comp, int req_comp) |
| 19 | { |
| 20 | if(req_comp == 0) req_comp = comp; |
| 21 | |
| 22 | if(image) |
| 23 | { |
| 24 | lua_pushlstringcxx . . $ lua_pushlstring(4429e063edbae36f).(L, (char *)image, x * y * req_comp); |
| 25 | lua_pushintegercxx . . $ lua_pushinteger(724ba90635c12ff0).(L, x); |
| 26 | lua_pushintegercxx . . $ lua_pushinteger(724ba90635c12ff0).(L, y); |
| 27 | lua_pushintegercxx . . $ lua_pushinteger(724ba90635c12ff0).(L, comp); |
| 28 | stbi_image_freecxx . . $ stbi_image_free(5d22bdacc48458e8).(image); |
| 29 | return 4; |
| 30 | } |
| 31 | else |
| 32 | { |
| 33 | lua_pushnilcxx . . $ lua_pushnil(f6fa9609f70d70d8).(L); |
| 34 | lua_pushstringcxx . . $ lua_pushstring(2c01a949aef328b).(L, stbi_failure_reasoncxx . . $ stbi_failure_reason(41208ce6ca65dd58).()); |
| 35 | return 2; |
| 36 | } |
| 37 | } |
| 38 | |
| 39 | static int stb_image_loadcxx . . $ stb_image_load(e4b172c3fcff213).(lua_Statecxx . . $ lua_State# *L) |
| 40 | { |
| 41 | const char * filename = luaL_checkstringcxx . . $ `<external>/18095755238171912061/lauxlib.h:102:9`!(L, 1); |
| 42 | int req_comp = check_req_compcxx . . $ check_req_comp(95e3aa3a3b4bb934).(L, 2); |
| 43 | |
| 44 | int x, y, comp; |
| 45 | unsigned char * image = stbi_loadcxx . . $ stbi_load(d2227ffa4e954804).(filename, &x, &y, &comp, req_comp); |
| 46 | |
| 47 | return return_imagecxx . . $ return_image(d88b2741f351bdb9).(L, image, x, y, comp, req_comp); |
| 48 | } |
| 49 | |
| 50 | static int stb_image_load_from_stringcxx . . $ stb_image_load_from_string(e4b172c3fcff213).(lua_Statecxx . . $ lua_State# *L) |
| 51 | { |
| 52 | size_t source_len; |
| 53 | const char * source = luaL_checklstringcxx . . $ luaL_checklstring(b7fc0e19ca28968a).(L, 1, &source_len); |
| 54 | int req_comp = check_req_compcxx . . $ check_req_comp(95e3aa3a3b4bb934).(L, 2); |
| 55 | |
| 56 | int x, y, comp; |
| 57 | unsigned char * image = stbi_load_from_memorycxx . . $ stbi_load_from_memory(1e6d922d42471b6a).( |
| 58 | (unsigned char *)source, source_len, &x, &y, &comp, req_comp); |
| 59 | |
| 60 | return return_imagecxx . . $ return_image(d88b2741f351bdb9).(L, image, x, y, comp, req_comp); |
| 61 | } |
| 62 | |
| 63 | static const luaL_Regcxx . . $ luaL_Reg# stb_image_libcxx . . $ stb_image_lib.[] = |
| 64 | { |
| 65 | {"load", stb_image_loadcxx . . $ stb_image_load(e4b172c3fcff213).}, |
| 66 | {"load_from_string", stb_image_load_from_stringcxx . . $ stb_image_load_from_string(e4b172c3fcff213).}, |
| 67 | {NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!} |
| 68 | }; |
| 69 | |
| 70 | int luaopen_stb_imagecxx . . $ luaopen_stb_image(e4b172c3fcff213).(lua_Statecxx . . $ lua_State# *L) |
| 71 | { |
| 72 | lua_newtablecxx . . $ `<external>/15848857005865937740/lua.h:256:9`!(L); |
| 73 | luaL_registercxx . . $ luaL_register(78d27bf8f6419b9e).(L, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!, stb_image_libcxx . . $ stb_image_lib.); |
| 74 | return 1; |
| 75 | } |