/*****************************************************************************\ image:GetPalette() \*****************************************************************************/ static int imluaImageGetPalette (lua_State *L) { imImage *image = imlua_checkimage(L, 1); long* color = malloc(sizeof(long) * 256); memcpy(color, image->palette, sizeof(long) * 256); imlua_pushpalette(L, color, 256); return 1; }
/*****************************************************************************\ file:GetPalette() \*****************************************************************************/ static int imluaFileGetPalette (lua_State *L) { imFile *ifile = imlua_checkfile(L, 1); long* palette = imPaletteNew(256); int count; imFileGetPalette(ifile, palette, &count); imlua_pushpalette(L, palette, count); return 1; }
/***************************************************************************\ * Creates a palette as a "imPalette" userdata. A palette can be * * considered and treated as a color table. * * im.PaletteCreate(count: number) -> (palette: "imPalette") * \***************************************************************************/ static int imluaPaletteCreate(lua_State *L) { long* color; int count = luaL_optint(L, 1, 256); if (count < 1 || count > 256) luaL_argerror(L, 1, "palette count should be a positive integer and less then 256"); color = (long*)malloc(256*sizeof(long)); memset(color, 0, 256*sizeof(long)); imlua_pushpalette(L, color, count); return 1; }
/*****************************************************************************\ im.PaletteUniform \*****************************************************************************/ static int imluaPaletteUniform (lua_State *L) { imlua_pushpalette(L, imPaletteUniform(), 256); return 1; }
/*****************************************************************************\ im.PaletteHighContrast \*****************************************************************************/ static int imluaPaletteHighContrast (lua_State *L) { imlua_pushpalette(L, imPaletteHighContrast(), 256); return 1; }
/*****************************************************************************\ im.PaletteBlackBody \*****************************************************************************/ static int imluaPaletteBlackBody (lua_State *L) { imlua_pushpalette(L, imPaletteBlackBody(), 256); return 1; }
/*****************************************************************************\ im.PaletteHotIron \*****************************************************************************/ static int imluaPaletteHotIron (lua_State *L) { imlua_pushpalette(L, imPaletteHotIron(), 256); return 1; }
/*****************************************************************************\ im.PaletteBlueIce \*****************************************************************************/ static int imluaPaletteBlueIce (lua_State *L) { imlua_pushpalette(L, imPaletteBlueIce(), 256); return 1; }
/*****************************************************************************\ im.PaletteRainbow \*****************************************************************************/ static int imluaPaletteRainbow (lua_State *L) { imlua_pushpalette(L, imPaletteRainbow(), 256); return 1; }
/*****************************************************************************\ im.PaletteMagenta \*****************************************************************************/ static int imluaPaletteMagenta (lua_State *L) { imlua_pushpalette(L, imPaletteMagenta(), 256); return 1; }
static int imluaPaletteLinear(lua_State *L) { imlua_pushpalette(L, imPaletteLinear(), 256); return 1; }