Image.pkg 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. $#include "Image.h"
  2. enum CompressedFormat
  3. {
  4. CF_NONE = 0,
  5. CF_DXT1,
  6. CF_DXT3,
  7. CF_DXT5,
  8. CF_ETC1,
  9. CF_PVRTC_RGB_2BPP,
  10. CF_PVRTC_RGBA_2BPP,
  11. CF_PVRTC_RGB_4BPP,
  12. CF_PVRTC_RGBA_4BPP,
  13. };
  14. class Image : public Resource
  15. {
  16. Image();
  17. ~Image();
  18. bool LoadColorLUT(Deserializer& source);
  19. tolua_outside bool ImageLoadColorLUT @ LoadColorLUT(const String& fileName);
  20. void FlipVertical();
  21. bool SaveBMP(const String fileName);
  22. bool SavePNG(const String fileName);
  23. bool SaveTGA(const String fileName);
  24. bool SaveJPG(const String fileName, int quality);
  25. int GetWidth() const;
  26. int GetHeight() const;
  27. int GetDepth() const;
  28. unsigned GetComponents() const;
  29. bool IsCompressed() const;
  30. CompressedFormat GetCompressedFormat() const;
  31. unsigned GetNumCompressedLevels() const;
  32. CompressedLevel GetCompressedLevel(unsigned index) const;
  33. tolua_readonly tolua_property__get_set int width;
  34. tolua_readonly tolua_property__get_set int height;
  35. tolua_readonly tolua_property__get_set int depth;
  36. tolua_readonly tolua_property__get_set unsigned components;
  37. tolua_readonly tolua_property__is_set bool compressed;
  38. tolua_readonly tolua_property__get_set CompressedFormat compressedFormat;
  39. tolua_readonly tolua_property__get_set unsigned numCompressedLevels;
  40. };
  41. ${
  42. #define TOLUA_DISABLE_tolua_ResourceLuaAPI_Image_new00
  43. static int tolua_ResourceLuaAPI_Image_new00(lua_State* tolua_S)
  44. {
  45. return ToluaNewObject<Image>(tolua_S);
  46. }
  47. #define TOLUA_DISABLE_tolua_ResourceLuaAPI_Image_new00_local
  48. static int tolua_ResourceLuaAPI_Image_new00_local(lua_State* tolua_S)
  49. {
  50. return ToluaNewObjectGC<Image>(tolua_S);
  51. }
  52. static bool ImageLoadColorLUT(Image* image, const String& fileName)
  53. {
  54. if (!image)
  55. return false;
  56. File file(image->GetContext());
  57. if (!file.Open(fileName, FILE_READ))
  58. return false;
  59. return image->LoadColorLUT(file);
  60. }
  61. $}