static LuaValue bwImageToLua(final BWImage img) { new LuaTable l; l.set("w", Lua.value(img.getWidth())); l.set("h", Lua.value(img.getHeight())); l.set("getBrightness", new TwoArgFunction { BWImage theimg = img; // << queryable by reflection public LuaValue call(LuaValue x, LuaValue y) { ret LuaValue.valueOf(img.getPixel(x.toint(), y.toint())); } }); ret l; }