MCPcopy Create free account
hub / github.com/BZFlag-Dev/bzflag / PushImageData

Function PushImageData

src/lua/LuaCallOuts.cpp:995–1019  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

993
994
995static int PushImageData(lua_State* L, PNGImageFile& image) {
996 if (!image.isOpen()) {
997 return luaL_pushnil(L);
998 }
999
1000 const int width = image.getWidth();
1001 const int height = image.getHeight();
1002 const int channels = image.getNumChannels();
1003
1004 const int bufSize = width * height * channels;
1005 char* buf = new char[bufSize];
1006 if (!image.read(buf)) {
1007 delete[] buf;
1008 return luaL_pushnil(L);
1009 }
1010
1011 lua_pushinteger(L, width);
1012 lua_pushinteger(L, height);
1013 lua_pushinteger(L, channels);
1014 lua_pushlstring(L, buf, bufSize);
1015
1016 delete[] buf;
1017
1018 return 4;
1019}
1020
1021
1022int LuaCallOuts::ReadImageData(lua_State* L) {

Callers 2

ReadImageDataMethod · 0.85
ReadImageFileMethod · 0.85

Calls 8

luaL_pushnilFunction · 0.85
lua_pushintegerFunction · 0.50
lua_pushlstringFunction · 0.50
isOpenMethod · 0.45
getWidthMethod · 0.45
getHeightMethod · 0.45
getNumChannelsMethod · 0.45
readMethod · 0.45

Tested by

no test coverage detected