Image.pkg 2.8 KB

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