~baltix/+junk/irrlicht-test

« back to all changes in this revision

Viewing changes to source/Irrlicht/CImageLoaderTGA.h

  • Committer: Mantas Kriaučiūnas
  • Date: 2011-07-18 13:06:25 UTC
  • Revision ID: mantas@akl.lt-20110718130625-c5pvifp61e7kj1ol
Included whole irrlicht SVN libraries to work around launchpad recipe issue with quilt, see https://answers.launchpad.net/launchpad/+question/165193

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
// Copyright (C) 2002-2011 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
 
 
5
#ifndef __C_IMAGE_LOADER_TGA_H_INCLUDED__
 
6
#define __C_IMAGE_LOADER_TGA_H_INCLUDED__
 
7
 
 
8
#include "IrrCompileConfig.h"
 
9
 
 
10
#include "IImageLoader.h"
 
11
 
 
12
 
 
13
namespace irr
 
14
{
 
15
namespace video
 
16
{
 
17
 
 
18
#if defined(_IRR_COMPILE_WITH_TGA_LOADER_) || defined(_IRR_COMPILE_WITH_TGA_WRITER_)
 
19
 
 
20
// byte-align structures
 
21
#if defined(_MSC_VER) ||  defined(__BORLANDC__) || defined (__BCPLUSPLUS__)
 
22
#       pragma pack( push, packing )
 
23
#       pragma pack( 1 )
 
24
#       define PACK_STRUCT
 
25
#elif defined( __GNUC__ )
 
26
#       define PACK_STRUCT      __attribute__((packed))
 
27
#else
 
28
#       define PACK_STRUCT
 
29
#endif
 
30
 
 
31
        // these structs are also used in the TGA writer
 
32
        struct STGAHeader{
 
33
                u8 IdLength;
 
34
                u8 ColorMapType;
 
35
                u8 ImageType;
 
36
                u8 FirstEntryIndex[2];
 
37
                u16 ColorMapLength;
 
38
                u8 ColorMapEntrySize;
 
39
                u8 XOrigin[2];
 
40
                u8 YOrigin[2];
 
41
                u16 ImageWidth;
 
42
                u16 ImageHeight;
 
43
                u8 PixelDepth;
 
44
                u8 ImageDescriptor;
 
45
        } PACK_STRUCT;
 
46
 
 
47
        struct STGAFooter
 
48
        {
 
49
                u32 ExtensionOffset;
 
50
                u32 DeveloperOffset;
 
51
                c8  Signature[18];
 
52
        } PACK_STRUCT;
 
53
 
 
54
// Default alignment
 
55
#if defined(_MSC_VER) ||  defined(__BORLANDC__) || defined (__BCPLUSPLUS__)
 
56
#       pragma pack( pop, packing )
 
57
#endif
 
58
 
 
59
#undef PACK_STRUCT
 
60
 
 
61
#endif // compiled with loader or reader
 
62
 
 
63
#ifdef _IRR_COMPILE_WITH_TGA_LOADER_
 
64
 
 
65
/*!
 
66
        Surface Loader for targa images
 
67
*/
 
68
class CImageLoaderTGA : public IImageLoader
 
69
{
 
70
public:
 
71
 
 
72
        //! returns true if the file maybe is able to be loaded by this class
 
73
        //! based on the file extension (e.g. ".tga")
 
74
        virtual bool isALoadableFileExtension(const io::path& filename) const;
 
75
 
 
76
        //! returns true if the file maybe is able to be loaded by this class
 
77
        virtual bool isALoadableFileFormat(io::IReadFile* file) const;
 
78
 
 
79
        //! creates a surface from the file
 
80
        virtual IImage* loadImage(io::IReadFile* file) const;
 
81
 
 
82
private:
 
83
 
 
84
        //! loads a compressed tga. Was written and sent in by Jon Pry, thank you very much!
 
85
        u8* loadCompressedImage(io::IReadFile *file, const STGAHeader& header) const;
 
86
};
 
87
 
 
88
#endif // compiled with loader
 
89
 
 
90
} // end namespace video
 
91
} // end namespace irr
 
92
 
 
93
#endif
 
94