Exemplo n.º 1
0
/*****************************************************************************\
 file:WriteImageData(data)
\*****************************************************************************/
static int imluaFileWriteImageData (lua_State *L)
{
  imFile *ifile = imlua_checkfile(L, 1);
  void* data = lua_touserdata(L, 2);
  imlua_pusherror(L, imFileWriteImageData(ifile, data));
  return 1;
}
Exemplo n.º 2
0
/*****************************************************************************\
 file:SaveImage()
\*****************************************************************************/
static int imluaFileSaveImage (lua_State *L)
{
  imFile *ifile = imlua_checkfile(L, 1);
  imImage *image = imlua_checkimage(L, 2);

  imlua_pusherror(L, imFileSaveImage(ifile, image));
  return 1;
}
Exemplo n.º 3
0
/*****************************************************************************\
 file:ReadImageData(data)
\*****************************************************************************/
static int imluaFileReadImageData (lua_State *L)
{
  imFile *ifile = imlua_checkfile(L, 1);
  void* data = lua_touserdata(L, 2);
  int convert2bitmap = lua_toboolean(L, 3);
  int color_mode_flags = luaL_checkinteger(L, 4);
  imlua_pusherror(L, imFileReadImageData(ifile, data, convert2bitmap, color_mode_flags));
  return 1;
}
Exemplo n.º 4
0
/*****************************************************************************\
 image:Save(filename, format)
\*****************************************************************************/
static int imluaImageSave (lua_State *L)
{
  imImage *image = imlua_checkimage(L, 1);
  const char *file_name = luaL_checkstring(L, 2);
  const char *format = imlua_checkformat(L, 3);

  imlua_pusherror(L, imFileImageSave(file_name, format, image));
  return 1;
}
Exemplo n.º 5
0
/*****************************************************************************\
 file:WriteImageInfo(width, height, user_color_mode, user_data_type)
\*****************************************************************************/
static int imluaFileWriteImageInfo (lua_State *L)
{
  imFile *ifile = imlua_checkfile(L, 1);
  int width = luaL_checkinteger(L, 2);
  int height = luaL_checkinteger(L, 3);
  int user_color_mode = luaL_checkinteger(L, 4);
  int user_data_type = luaL_checkinteger(L, 5);

  imlua_pusherror(L, imFileWriteImageInfo(ifile, width, height, user_color_mode, user_data_type));
  return 1;
}
Exemplo n.º 6
0
/*****************************************************************************\
 file:LoadBitmapFrame()
\*****************************************************************************/
static int imluaFileLoadBitmapFrame (lua_State *L)
{
  imFile *ifile = imlua_checkfile(L, 1);
  int index = luaL_checkinteger(L, 2);
  imImage *image = imlua_checkimage(L, 3);
  int error;

  imFileLoadBitmapFrame(ifile, index, image, &error);
  imlua_pusherror(L, error);

  return 1;
}
Exemplo n.º 7
0
static int imluaFormatInfoExtra (lua_State *L)
{
  char extra[50];

  int error = imFormatInfoExtra(luaL_checkstring(L, 1), extra);

  imlua_pusherror(L, error);
  if (error)
    return 1;

  lua_pushstring(L, extra);

  return 2;
}
Exemplo n.º 8
0
int imlua_pushimageerror(lua_State *L, imImage* image, int error)
{
  if (error)
  {
    lua_pushnil(L);  /* one for the image */
    imlua_pusherror(L, error);  /* one for the error */
    return 2;
  }
  else
  {
    imlua_pushimage(L, image);
    return 1;   /* the error will be nil */
  }
}
Exemplo n.º 9
0
static int imlua_pushifileerror(lua_State *L, imFile* ifile, int error)
{
  if (error)
  {
    lua_pushnil(L);
    imlua_pusherror(L, error);
    return 2;
  }
  else
  {
    imFile** ifile_p = (imFile**) lua_newuserdata(L, sizeof(imFile*));
    *ifile_p = ifile;
    luaL_getmetatable(L, "imFile");
    lua_setmetatable(L, -2);
    return 1;
  }
}
Exemplo n.º 10
0
/*****************************************************************************\
 im.FormatInfo(format)
\*****************************************************************************/
static int imluaFormatInfo (lua_State *L)
{
  char desc[50];
  char ext[50];
  int can_sequence;

  int error = imFormatInfo(luaL_checkstring(L, 1), desc, ext, &can_sequence);

  imlua_pusherror(L, error);
  if (error)
    return 1;

  lua_pushstring(L, desc);
  lua_pushstring(L, ext);
  lua_pushboolean(L, can_sequence);

  return 4;
}
Exemplo n.º 11
0
/*****************************************************************************\
 file:ReadImageInfo()
\*****************************************************************************/
static int imluaFileReadImageInfo (lua_State *L)
{
  int width, height;
  int file_color_mode, file_data_type;
  int error;

  imFile *ifile = imlua_checkfile(L, 1);
  int index = luaL_optinteger(L, 2, 0);

  error = imFileReadImageInfo(ifile, index, &width, &height, &file_color_mode, &file_data_type);

  imlua_pusherror(L, error);
  if (error)
    return 1;

  lua_pushnumber(L, width);
  lua_pushnumber(L, height);
  lua_pushnumber(L, file_color_mode);
  lua_pushnumber(L, file_data_type);
  return 5;
}
Exemplo n.º 12
0
/*****************************************************************************\
 im.FormatCompressions(format)
\*****************************************************************************/
static int imluaFormatCompressions (lua_State *L)
{
  int i, comp_count;
  int error;
  char *comp[50];

  int color_mode = luaL_optint(L, 2, -1);
  int data_type = luaL_optint(L, 3, -1);

  error = imFormatCompressions(luaL_checkstring(L, 1), comp, &comp_count, color_mode, data_type);

  imlua_pusherror(L, error);
  if (error)
    return 1;

  lua_newtable(L);
  for (i = 0; i < comp_count; i++)
  {
    lua_pushstring(L, comp[i]);
    lua_settable(L, -2);
  }

  return 2;
}