Image.pkg 2.8 KB

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