diff options
author | chai <chaifix@163.com> | 2018-09-07 13:30:44 +0800 |
---|---|---|
committer | chai <chaifix@163.com> | 2018-09-07 13:30:44 +0800 |
commit | e72188433348c270a54879da9f086f1b527b580f (patch) | |
tree | b2cb92b37579c6f9cff77f52fc591426eb2d8286 /src/lua/modules/graphics/bitmap.cpp | |
parent | 28ca1f570d417671904a25c2a9c589fdb1eb7a03 (diff) |
*update
Diffstat (limited to 'src/lua/modules/graphics/bitmap.cpp')
-rw-r--r-- | src/lua/modules/graphics/bitmap.cpp | 26 |
1 files changed, 20 insertions, 6 deletions
diff --git a/src/lua/modules/graphics/bitmap.cpp b/src/lua/modules/graphics/bitmap.cpp index 81c36f1..6067442 100644 --- a/src/lua/modules/graphics/bitmap.cpp +++ b/src/lua/modules/graphics/bitmap.cpp @@ -20,7 +20,6 @@ namespace lua static int l_gc(lua_State* L) { - printf("collect bitmap\n"); BitmapRef ref = checkBitmap(L); ref.release(); return 0; @@ -70,14 +69,29 @@ namespace lua BitmapRef ref = checkBitmap(L); int x = luax_checkinteger(L, 2); int y = luax_checkinteger(L, 3); - unsigned char r = luax_checkinteger(L, 4); - unsigned char g = luax_checkinteger(L, 5); - unsigned char b = luax_checkinteger(L, 6); - unsigned char a = luax_checkinteger(L, 7); + if (!luax_istable(L, 4)) + { + luax_typerror(L, 4, "table"); + return 1; + } + unsigned int r = luax_rawgetnumber(L, 4, 1); + unsigned int g = luax_rawgetnumber(L, 4, 2); + unsigned int b = luax_rawgetnumber(L, 4, 3); + unsigned int a = luax_rawgetnumber(L, 4, 4); ref->setPixel(Color(r, g, b, a), x, y); return 0; } + static int l_clone(lua_State* L) + { + BitmapRef ref = checkBitmap(L); + Bitmap* bitmap = ref.getObject(); + Bitmap* b = Bitmap::clone(bitmap); + Proxy* proxy = (Proxy*)luax_newinstance(L, JIN_GRAPHICS_BITMAP, sizeof(Proxy)); + proxy->bind(new Ref<Bitmap>(b, JIN_GRAPHICS_BITMAP)); + return 1; + } + static const luaL_Reg f[] = { { "__gc", l_gc }, { "getWidth", l_getWidth }, @@ -85,6 +99,7 @@ namespace lua { "getSize", l_getSize }, { "getPixel", l_getPixel }, { "setPixel", l_setPixel }, + { "clone", l_clone }, { 0, 0 } }; @@ -94,6 +109,5 @@ namespace lua return 0; } - } }
\ No newline at end of file |