Image.pkg 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  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 SetSize(int width, int height, unsigned components);
  19. bool SetSize(int width, int height, int depth, unsigned components);
  20. void SetPixel(int x, int y, const Color& color);
  21. void SetPixel(int x, int y, int z, const Color& color);
  22. bool LoadColorLUT(Deserializer& source);
  23. tolua_outside bool ImageLoadColorLUT @ LoadColorLUT(const String fileName);
  24. void FlipVertical();
  25. bool Resize(int width, int height);
  26. void Clear(const Color& color);
  27. bool SaveBMP(const String fileName) const;
  28. bool SavePNG(const String fileName) const;
  29. bool SaveTGA(const String fileName) const;
  30. bool SaveJPG(const String fileName, int quality) const;
  31. Color GetPixel(int x, int y) const;
  32. Color GetPixel(int x, int y, int z) const;
  33. Color GetPixelBilinear(float x, float y) const;
  34. Color GetPixelTrilinear(float x, float y, float z) const;
  35. int GetWidth() const;
  36. int GetHeight() const;
  37. int GetDepth() const;
  38. unsigned GetComponents() const;
  39. bool IsCompressed() const;
  40. CompressedFormat GetCompressedFormat() const;
  41. unsigned GetNumCompressedLevels() const;
  42. CompressedLevel GetCompressedLevel(unsigned index) const;
  43. Image* GetSubimage(const IntRect& rect) const;
  44. tolua_readonly tolua_property__get_set int width;
  45. tolua_readonly tolua_property__get_set int height;
  46. tolua_readonly tolua_property__get_set int depth;
  47. tolua_readonly tolua_property__get_set unsigned components;
  48. tolua_readonly tolua_property__is_set bool compressed;
  49. tolua_readonly tolua_property__get_set CompressedFormat compressedFormat;
  50. tolua_readonly tolua_property__get_set unsigned numCompressedLevels;
  51. };
  52. ${
  53. #define TOLUA_DISABLE_tolua_ResourceLuaAPI_Image_new00
  54. static int tolua_ResourceLuaAPI_Image_new00(lua_State* tolua_S)
  55. {
  56. return ToluaNewObject<Image>(tolua_S);
  57. }
  58. #define TOLUA_DISABLE_tolua_ResourceLuaAPI_Image_new00_local
  59. static int tolua_ResourceLuaAPI_Image_new00_local(lua_State* tolua_S)
  60. {
  61. return ToluaNewObjectGC<Image>(tolua_S);
  62. }
  63. static bool ImageLoadColorLUT(Image* image, const String& fileName)
  64. {
  65. if (!image)
  66. return false;
  67. File file(image->GetContext());
  68. if (!file.Open(fileName, FILE_READ))
  69. return false;
  70. return image->LoadColorLUT(file);
  71. }
  72. $}