Browse Source

love.image.newImageData(w, h, format, rawbytes) can accept a Data object.

--HG--
branch : minor
Alex Szpakowski 8 years ago
parent
commit
9b6aa777ad
1 changed files with 7 additions and 1 deletions
  1. 7 1
      src/modules/image/wrap_Image.cpp

+ 7 - 1
src/modules/image/wrap_Image.cpp

@@ -56,7 +56,13 @@ int w_newImageData(lua_State *L)
 		size_t numbytes = 0;
 		size_t numbytes = 0;
 		const char *bytes = nullptr;
 		const char *bytes = nullptr;
 
 
-		if (!lua_isnoneornil(L, 4))
+		if (luax_istype(L, 4, Data::type))
+		{
+			Data *data = luax_checkdata(L, 4);
+			bytes = (const char *) data->getData();
+			numbytes = data->getSize();
+		}
+		else if (!lua_isnoneornil(L, 4))
 			bytes = luaL_checklstring(L, 4, &numbytes);
 			bytes = luaL_checklstring(L, 4, &numbytes);
 
 
 		ImageData *t = nullptr;
 		ImageData *t = nullptr;