]> git.lizzy.rs Git - irrlicht.git/blob - source/Irrlicht/CImageLoaderTGA.h
d8f7368b734b4f4cd3327b752af942ba60a2728d
[irrlicht.git] / source / Irrlicht / CImageLoaderTGA.h
1 // Copyright (C) 2002-2012 Nikolaus Gebhardt\r
2 // This file is part of the "Irrlicht Engine".\r
3 // For conditions of distribution and use, see copyright notice in irrlicht.h\r
4 \r
5 #ifndef __C_IMAGE_LOADER_TGA_H_INCLUDED__\r
6 #define __C_IMAGE_LOADER_TGA_H_INCLUDED__\r
7 \r
8 #include "IrrCompileConfig.h"\r
9 \r
10 #include "IImageLoader.h"\r
11 \r
12 \r
13 namespace irr\r
14 {\r
15 namespace video\r
16 {\r
17 \r
18 #if defined(_IRR_COMPILE_WITH_TGA_LOADER_) || defined(_IRR_COMPILE_WITH_TGA_WRITER_)\r
19 \r
20 // byte-align structures\r
21 #include "irrpack.h"\r
22 \r
23         // these structs are also used in the TGA writer\r
24         struct STGAHeader{\r
25                 u8 IdLength;\r
26                 u8 ColorMapType;\r
27                 u8 ImageType;\r
28                 u8 FirstEntryIndex[2];\r
29                 u16 ColorMapLength;\r
30                 u8 ColorMapEntrySize;\r
31                 u8 XOrigin[2];\r
32                 u8 YOrigin[2];\r
33                 u16 ImageWidth;\r
34                 u16 ImageHeight;\r
35                 u8 PixelDepth;\r
36                 u8 ImageDescriptor;\r
37         } PACK_STRUCT;\r
38 \r
39         struct STGAFooter\r
40         {\r
41                 u32 ExtensionOffset;\r
42                 u32 DeveloperOffset;\r
43                 c8  Signature[18];\r
44         } PACK_STRUCT;\r
45 \r
46 // Default alignment\r
47 #include "irrunpack.h"\r
48 \r
49 #endif // compiled with loader or reader\r
50 \r
51 #ifdef _IRR_COMPILE_WITH_TGA_LOADER_\r
52 \r
53 /*!\r
54         Surface Loader for targa images\r
55 */\r
56 class CImageLoaderTGA : public IImageLoader\r
57 {\r
58 public:\r
59 \r
60         //! returns true if the file maybe is able to be loaded by this class\r
61         //! based on the file extension (e.g. ".tga")\r
62         bool isALoadableFileExtension(const io::path& filename) const override;\r
63 \r
64         //! returns true if the file maybe is able to be loaded by this class\r
65         bool isALoadableFileFormat(io::IReadFile* file) const override;\r
66 \r
67         //! creates a surface from the file\r
68         IImage* loadImage(io::IReadFile* file) const override;\r
69 \r
70 private:\r
71 \r
72         //! loads a compressed tga. Was written and sent in by Jon Pry, thank you very much!\r
73         u8* loadCompressedImage(io::IReadFile *file, const STGAHeader& header) const;\r
74 };\r
75 \r
76 #endif // compiled with loader\r
77 \r
78 } // end namespace video\r
79 } // end namespace irr\r
80 \r
81 #endif\r
82 \r