CImageLoaderTEX.h 3.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. #pragma once
  2. #include <irrlicht/irrlicht.h>
  3. using namespace irr;
  4. using namespace irr::video;
  5. namespace WallpaperEngine::Irrlicht
  6. {
  7. //! Surface Loader for PNG files
  8. class CImageLoaderTex : public IImageLoader
  9. {
  10. public:
  11. //! returns true if the file maybe is able to be loaded by this class
  12. //! based on the file extension (e.g. ".png")
  13. virtual bool isALoadableFileExtension(const io::path& filename) const;
  14. //! returns true if the file maybe is able to be loaded by this class
  15. virtual bool isALoadableFileFormat(io::IReadFile* file) const;
  16. //! creates a surface from the file
  17. virtual IImage* loadImage(io::IReadFile* input) const;
  18. virtual void loadImageFromARGB8Data (IImage* output, const char* input, u32 width, u32 height, u32 mipmap_width) const;
  19. virtual void loadImageFromDXT1 (IImage* output, const char* input, u32 destination_width, u32 destination_height, u32 origin_width, u32 origin_height) const;
  20. virtual void loadImageFromDXT5 (IImage* output, const char* input, u32 destination_width, u32 destination_height, u32 origin_width, u32 origin_height) const;
  21. private:
  22. void BlockDecompressImageDXT1(unsigned long width, unsigned long height, const unsigned char *blockStorage, unsigned long *image) const;
  23. void DecompressBlockDXT1(unsigned long x, unsigned long y, unsigned long width, const unsigned char *blockStorage, unsigned long *image) const;
  24. unsigned long PackRGBA(unsigned char r, unsigned char g, unsigned char b, unsigned char a) const;
  25. void BlockDecompressImageDXT5(unsigned long width, unsigned long height, const unsigned char *blockStorage, unsigned long *image) const;
  26. void DecompressBlockDXT5(unsigned long x, unsigned long y, unsigned long width, const unsigned char *blockStorage, unsigned long *image) const;
  27. enum TextureFormat
  28. {
  29. ARGB8888,
  30. RA88,
  31. A8,
  32. DXT5,
  33. DXT3,
  34. DXT1
  35. };
  36. // extracted from the free image library
  37. enum FREE_IMAGE_FORMAT
  38. {
  39. FIF_UNKNOWN = -1,
  40. FIF_BMP = 0,
  41. FIF_ICO = 1,
  42. FIF_JPEG = 2,
  43. FIF_JNG = 3,
  44. FIF_KOALA = 4,
  45. FIF_LBM = 5,
  46. FIF_IFF = FIF_LBM,
  47. FIF_MNG = 6,
  48. FIF_PBM = 7,
  49. FIF_PBMRAW = 8,
  50. FIF_PCD = 9,
  51. FIF_PCX = 10,
  52. FIF_PGM = 11,
  53. FIF_PGMRAW = 12,
  54. FIF_PNG = 13,
  55. FIF_PPM = 14,
  56. FIF_PPMRAW = 15,
  57. FIF_RAS = 16,
  58. FIF_TARGA = 17,
  59. FIF_TIFF = 18,
  60. FIF_WBMP = 19,
  61. FIF_PSD = 20,
  62. FIF_CUT = 21,
  63. FIF_XBM = 22,
  64. FIF_XPM = 23,
  65. FIF_DDS = 24,
  66. FIF_GIF = 25,
  67. FIF_HDR = 26,
  68. FIF_FAXG3 = 27,
  69. FIF_SGI = 28,
  70. FIF_EXR = 29,
  71. FIF_J2K = 30,
  72. FIF_JP2 = 31,
  73. FIF_PFM = 32,
  74. FIF_PICT = 33,
  75. FIF_RAW = 34,
  76. FIF_WEBP = 35,
  77. FIF_JXR = 36
  78. };
  79. };
  80. }