2
0

CImageLoaderTGA.h 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. // Copyright (C) 2002-2012 Nikolaus Gebhardt
  2. // This file is part of the "Irrlicht Engine".
  3. // For conditions of distribution and use, see copyright notice in irrlicht.h
  4. #pragma once
  5. #include "IImageLoader.h"
  6. namespace irr
  7. {
  8. namespace video
  9. {
  10. // byte-align structures
  11. #include "irrpack.h"
  12. // these structs are also used in the TGA writer
  13. struct STGAHeader
  14. {
  15. u8 IdLength;
  16. u8 ColorMapType;
  17. u8 ImageType;
  18. u8 FirstEntryIndex[2];
  19. u16 ColorMapLength;
  20. u8 ColorMapEntrySize;
  21. u8 XOrigin[2];
  22. u8 YOrigin[2];
  23. u16 ImageWidth;
  24. u16 ImageHeight;
  25. u8 PixelDepth;
  26. u8 ImageDescriptor;
  27. } PACK_STRUCT;
  28. struct STGAFooter
  29. {
  30. u32 ExtensionOffset;
  31. u32 DeveloperOffset;
  32. c8 Signature[18];
  33. } PACK_STRUCT;
  34. // Default alignment
  35. #include "irrunpack.h"
  36. /*!
  37. Surface Loader for targa images
  38. */
  39. class CImageLoaderTGA : public IImageLoader
  40. {
  41. public:
  42. //! returns true if the file maybe is able to be loaded by this class
  43. //! based on the file extension (e.g. ".tga")
  44. bool isALoadableFileExtension(const io::path &filename) const override;
  45. //! returns true if the file maybe is able to be loaded by this class
  46. bool isALoadableFileFormat(io::IReadFile *file) const override;
  47. //! creates a surface from the file
  48. IImage *loadImage(io::IReadFile *file) const override;
  49. private:
  50. //! loads a compressed tga. Was written and sent in by Jon Pry, thank you very much!
  51. u8 *loadCompressedImage(io::IReadFile *file, const STGAHeader &header) const;
  52. };
  53. } // end namespace video
  54. } // end namespace irr