static void write_image_or_node(lua_State * L, wrtype_e writetype) { image *a, **aa; image_dict *ad; halfword n; if (lua_gettop(L) != 1) luaL_error(L, "%s needs exactly 1 argument", wrtype_s[writetype]); if (lua_istable(L, 1)) (void) l_new_image(L); /* image --- if everything worked well */ aa = (image **) luaL_checkudata(L, 1, TYPE_IMG); /* image */ a = *aa; ad = img_dict(a); setup_image(static_pdf, a, writetype); switch (writetype) { case WR_WRITE: n = img_to_node(a); tail_append(n); break; /* image */ case WR_IMMEDIATEWRITE: write_img(static_pdf, ad); break; /* image */ case WR_NODE: /* image */ lua_pop(L, 1); /* - */ n = img_to_node(a); lua_nodelib_push_fast(L, n); break; /* node */ default: assert(0); } if (img_state(ad) < DICT_REFERED) img_state(ad) = DICT_REFERED; }
static void write_image_or_node(lua_State * L, wrtype_e writetype) { image *a, **aa; image_dict *ad; halfword n; if (lua_gettop(L) != 1) luaL_error(L, "%s expects an argument", wrtype_s[writetype]); if (lua_istable(L, 1)) (void) l_new_image(L); aa = (image **) luaL_checkudata(L, 1, TYPE_IMG); a = *aa; ad = img_dict(a); setup_image(static_pdf, a, writetype); switch (writetype) { case WR_WRITE: n = img_to_node(L, a); tail_append(n); break; case WR_IMMEDIATEWRITE: write_img(static_pdf, ad); break; case WR_NODE: lua_pop(L, 1); /* - */ n = img_to_node(L, a); lua_nodelib_push_fast(L, n); break; default: luaL_error(L, "%s expects an valid image", wrtype_s[writetype]); } if (img_state(ad) < DICT_REFERED) img_state(ad) = DICT_REFERED; }
static int l_copy_image(lua_State * L) { if (lua_gettop(L) != 1) luaL_error(L, "img.copy() needs exactly 1 argument"); if (lua_istable(L, 1)) (void) l_new_image(L); /* image --- if everything worked well */ else (void) copy_image(L, 1.0); /* image */ return 1; /* image */ }
static int l_copy_image(lua_State * L) { if (lua_gettop(L) != 1) { luaL_error(L, "img.copy needs an image as argument"); } else if (lua_istable(L, 1)) { (void) l_new_image(L); } else { (void) copy_image(L, 1.0); } return 1; }
static int l_scan_image(lua_State * L) { image *a, **aa; if (lua_gettop(L) != 1) luaL_error(L, "img.scan needs exactly 1 argument"); if (lua_istable(L, 1)) (void) l_new_image(L); aa = (image **) luaL_checkudata(L, 1, TYPE_IMG); a = *aa; check_o_mode(static_pdf, "img.scan", 1 << OMODE_PDF, false); read_scale_img(a); return 1; }
static int l_scan_image(lua_State * L) { image *a, **aa; if (lua_gettop(L) != 1) luaL_error(L, "img.scan() needs exactly 1 argument"); if (lua_istable(L, 1)) (void) l_new_image(L); /* image --- if everything worked well */ aa = (image **) luaL_checkudata(L, 1, TYPE_IMG); /* image */ a = *aa; check_o_mode(static_pdf, "img.scan()", 1 << OMODE_PDF, false); /* flush_str(last_tex_string); *//* ?? */ read_scale_img(a); return 1; /* image */ }