diff options
Diffstat (limited to '')
-rw-r--r-- | libraries/irrlicht-1.8/source/Irrlicht/CImageLoaderRGB.h | 330 |
1 files changed, 165 insertions, 165 deletions
diff --git a/libraries/irrlicht-1.8/source/Irrlicht/CImageLoaderRGB.h b/libraries/irrlicht-1.8/source/Irrlicht/CImageLoaderRGB.h index 1fe6454..f1693e5 100644 --- a/libraries/irrlicht-1.8/source/Irrlicht/CImageLoaderRGB.h +++ b/libraries/irrlicht-1.8/source/Irrlicht/CImageLoaderRGB.h | |||
@@ -1,165 +1,165 @@ | |||
1 | // Copyright (C) 2009-2012 Gary Conway | 1 | // Copyright (C) 2009-2012 Gary Conway |
2 | // This file is part of the "Irrlicht Engine". | 2 | // This file is part of the "Irrlicht Engine". |
3 | // For conditions of distribution and use, see copyright notice in irrlicht.h | 3 | // For conditions of distribution and use, see copyright notice in irrlicht.h |
4 | 4 | ||
5 | 5 | ||
6 | /* | 6 | /* |
7 | Author: Gary Conway (Viper) - co-author of the ZIP file format, Feb 1989, | 7 | Author: Gary Conway (Viper) - co-author of the ZIP file format, Feb 1989, |
8 | see the story at http://www.idcnet.us/ziphistory.html | 8 | see the story at http://www.idcnet.us/ziphistory.html |
9 | Website: http://idcnet.us | 9 | Website: http://idcnet.us |
10 | Email: codeslinger@vipergc.com | 10 | Email: codeslinger@vipergc.com |
11 | Created: March 1, 2009 | 11 | Created: March 1, 2009 |
12 | Version: 1.0 | 12 | Version: 1.0 |
13 | Updated: | 13 | Updated: |
14 | */ | 14 | */ |
15 | 15 | ||
16 | #ifndef __C_IMAGE_LOADER_RGB_H_INCLUDED__ | 16 | #ifndef __C_IMAGE_LOADER_RGB_H_INCLUDED__ |
17 | #define __C_IMAGE_LOADER_RGB_H_INCLUDED__ | 17 | #define __C_IMAGE_LOADER_RGB_H_INCLUDED__ |
18 | 18 | ||
19 | // define _IRR_RGB_FILE_INVERTED_IMAGE_ to preserve the inverted format of the RGB file | 19 | // define _IRR_RGB_FILE_INVERTED_IMAGE_ to preserve the inverted format of the RGB file |
20 | // commenting this out will invert the inverted image,resulting in the image being upright | 20 | // commenting this out will invert the inverted image,resulting in the image being upright |
21 | #define _IRR_RGB_FILE_INVERTED_IMAGE_ | 21 | #define _IRR_RGB_FILE_INVERTED_IMAGE_ |
22 | 22 | ||
23 | #include "IrrCompileConfig.h" | 23 | #include "IrrCompileConfig.h" |
24 | 24 | ||
25 | #ifdef _IRR_COMPILE_WITH_RGB_LOADER_ | 25 | #ifdef _IRR_COMPILE_WITH_RGB_LOADER_ |
26 | 26 | ||
27 | #include "IImageLoader.h" | 27 | #include "IImageLoader.h" |
28 | 28 | ||
29 | namespace irr | 29 | namespace irr |
30 | { | 30 | { |
31 | namespace video | 31 | namespace video |
32 | { | 32 | { |
33 | 33 | ||
34 | // byte-align structures | 34 | // byte-align structures |
35 | #include "irrpack.h" | 35 | #include "irrpack.h" |
36 | 36 | ||
37 | // the RGB image file header structure | 37 | // the RGB image file header structure |
38 | 38 | ||
39 | struct SRGBHeader | 39 | struct SRGBHeader |
40 | { | 40 | { |
41 | u16 Magic; // IRIS image file magic number | 41 | u16 Magic; // IRIS image file magic number |
42 | u8 Storage; // Storage format | 42 | u8 Storage; // Storage format |
43 | u8 BPC; // Number of bytes per pixel channel | 43 | u8 BPC; // Number of bytes per pixel channel |
44 | u16 Dimension; // Number of dimensions | 44 | u16 Dimension; // Number of dimensions |
45 | u16 Xsize; // X size in pixels | 45 | u16 Xsize; // X size in pixels |
46 | u16 Ysize; // Y size in pixels | 46 | u16 Ysize; // Y size in pixels |
47 | u16 Zsize; // Z size in pixels | 47 | u16 Zsize; // Z size in pixels |
48 | u32 Pixmin; // Minimum pixel value | 48 | u32 Pixmin; // Minimum pixel value |
49 | u32 Pixmax; // Maximum pixel value | 49 | u32 Pixmax; // Maximum pixel value |
50 | u32 Dummy1; // ignored | 50 | u32 Dummy1; // ignored |
51 | char Imagename[80];// Image name | 51 | char Imagename[80];// Image name |
52 | u32 Colormap; // Colormap ID | 52 | u32 Colormap; // Colormap ID |
53 | // char Dummy2[404];// Ignored | 53 | // char Dummy2[404];// Ignored |
54 | } PACK_STRUCT; | 54 | } PACK_STRUCT; |
55 | 55 | ||
56 | // Default alignment | 56 | // Default alignment |
57 | #include "irrunpack.h" | 57 | #include "irrunpack.h" |
58 | 58 | ||
59 | // this structure holds context specific data about the file being loaded. | 59 | // this structure holds context specific data about the file being loaded. |
60 | 60 | ||
61 | typedef struct _RGBdata | 61 | typedef struct _RGBdata |
62 | { | 62 | { |
63 | u8 *tmp, | 63 | u8 *tmp, |
64 | *tmpR, | 64 | *tmpR, |
65 | *tmpG, | 65 | *tmpG, |
66 | *tmpB, | 66 | *tmpB, |
67 | *tmpA; | 67 | *tmpA; |
68 | 68 | ||
69 | 69 | ||
70 | u32 *StartTable; // compressed data table, holds file offsets | 70 | u32 *StartTable; // compressed data table, holds file offsets |
71 | u32 *LengthTable; // length for the above data, hold lengths for above | 71 | u32 *LengthTable; // length for the above data, hold lengths for above |
72 | u32 TableLen; // len of above tables | 72 | u32 TableLen; // len of above tables |
73 | 73 | ||
74 | SRGBHeader Header; // define the .rgb file header | 74 | SRGBHeader Header; // define the .rgb file header |
75 | u32 ImageSize; | 75 | u32 ImageSize; |
76 | u8 *rgbData; | 76 | u8 *rgbData; |
77 | 77 | ||
78 | public: | 78 | public: |
79 | _RGBdata() : tmp(0), tmpR(0), tmpG(0), tmpB(0), tmpA(0), | 79 | _RGBdata() : tmp(0), tmpR(0), tmpG(0), tmpB(0), tmpA(0), |
80 | StartTable(0), LengthTable(0), TableLen(0), ImageSize(0), rgbData(0) | 80 | StartTable(0), LengthTable(0), TableLen(0), ImageSize(0), rgbData(0) |
81 | { | 81 | { |
82 | } | 82 | } |
83 | 83 | ||
84 | ~_RGBdata() | 84 | ~_RGBdata() |
85 | { | 85 | { |
86 | delete [] tmp; | 86 | delete [] tmp; |
87 | delete [] tmpR; | 87 | delete [] tmpR; |
88 | delete [] tmpG; | 88 | delete [] tmpG; |
89 | delete [] tmpB; | 89 | delete [] tmpB; |
90 | delete [] tmpA; | 90 | delete [] tmpA; |
91 | delete [] StartTable; | 91 | delete [] StartTable; |
92 | delete [] LengthTable; | 92 | delete [] LengthTable; |
93 | delete [] rgbData; | 93 | delete [] rgbData; |
94 | } | 94 | } |
95 | 95 | ||
96 | bool allocateTemps() | 96 | bool allocateTemps() |
97 | { | 97 | { |
98 | tmp = tmpR = tmpG = tmpB = tmpA = 0; | 98 | tmp = tmpR = tmpG = tmpB = tmpA = 0; |
99 | tmp = new u8 [Header.Xsize * 256 * Header.BPC]; | 99 | tmp = new u8 [Header.Xsize * 256 * Header.BPC]; |
100 | if (!tmp) | 100 | if (!tmp) |
101 | return false; | 101 | return false; |
102 | 102 | ||
103 | if (Header.Zsize >= 1) | 103 | if (Header.Zsize >= 1) |
104 | { | 104 | { |
105 | tmpR = new u8[Header.Xsize * Header.BPC]; | 105 | tmpR = new u8[Header.Xsize * Header.BPC]; |
106 | if (!tmpR) | 106 | if (!tmpR) |
107 | return false; | 107 | return false; |
108 | } | 108 | } |
109 | if (Header.Zsize >= 2) | 109 | if (Header.Zsize >= 2) |
110 | { | 110 | { |
111 | tmpG = new u8[Header.Xsize * Header.BPC]; | 111 | tmpG = new u8[Header.Xsize * Header.BPC]; |
112 | if (!tmpG) | 112 | if (!tmpG) |
113 | return false; | 113 | return false; |
114 | } | 114 | } |
115 | if (Header.Zsize >= 3) | 115 | if (Header.Zsize >= 3) |
116 | { | 116 | { |
117 | tmpB = new u8[Header.Xsize * Header.BPC]; | 117 | tmpB = new u8[Header.Xsize * Header.BPC]; |
118 | if (!tmpB) | 118 | if (!tmpB) |
119 | return false; | 119 | return false; |
120 | } | 120 | } |
121 | if (Header.Zsize >= 4) | 121 | if (Header.Zsize >= 4) |
122 | { | 122 | { |
123 | tmpA = new u8[Header.Xsize * Header.BPC]; | 123 | tmpA = new u8[Header.Xsize * Header.BPC]; |
124 | if (!tmpA) | 124 | if (!tmpA) |
125 | return false; | 125 | return false; |
126 | } | 126 | } |
127 | return true; | 127 | return true; |
128 | } | 128 | } |
129 | } rgbStruct; | 129 | } rgbStruct; |
130 | 130 | ||
131 | 131 | ||
132 | //! Surface Loader for Silicon Graphics RGB files | 132 | //! Surface Loader for Silicon Graphics RGB files |
133 | class CImageLoaderRGB : public IImageLoader | 133 | class CImageLoaderRGB : public IImageLoader |
134 | { | 134 | { |
135 | public: | 135 | public: |
136 | 136 | ||
137 | //! constructor | 137 | //! constructor |
138 | CImageLoaderRGB(); | 138 | CImageLoaderRGB(); |
139 | 139 | ||
140 | //! returns true if the file maybe is able to be loaded by this class | 140 | //! returns true if the file maybe is able to be loaded by this class |
141 | //! based on the file extension (e.g. ".tga") | 141 | //! based on the file extension (e.g. ".tga") |
142 | virtual bool isALoadableFileExtension(const io::path& filename) const; | 142 | virtual bool isALoadableFileExtension(const io::path& filename) const; |
143 | 143 | ||
144 | //! returns true if the file maybe is able to be loaded by this class | 144 | //! returns true if the file maybe is able to be loaded by this class |
145 | virtual bool isALoadableFileFormat(io::IReadFile* file) const; | 145 | virtual bool isALoadableFileFormat(io::IReadFile* file) const; |
146 | 146 | ||
147 | //! creates a surface from the file | 147 | //! creates a surface from the file |
148 | virtual IImage* loadImage(io::IReadFile* file) const; | 148 | virtual IImage* loadImage(io::IReadFile* file) const; |
149 | 149 | ||
150 | private: | 150 | private: |
151 | 151 | ||
152 | bool readHeader(io::IReadFile* file, rgbStruct& rgb) const; | 152 | bool readHeader(io::IReadFile* file, rgbStruct& rgb) const; |
153 | void readRGBrow(u8 *buf, int y, int z, io::IReadFile* file, rgbStruct& rgb) const; | 153 | void readRGBrow(u8 *buf, int y, int z, io::IReadFile* file, rgbStruct& rgb) const; |
154 | void processFile(io::IReadFile *file, rgbStruct& rgb) const; | 154 | void processFile(io::IReadFile *file, rgbStruct& rgb) const; |
155 | bool checkFormat(io::IReadFile *file, rgbStruct& rgb) const; | 155 | bool checkFormat(io::IReadFile *file, rgbStruct& rgb) const; |
156 | bool readOffsetTables(io::IReadFile* file, rgbStruct& rgb) const; | 156 | bool readOffsetTables(io::IReadFile* file, rgbStruct& rgb) const; |
157 | void converttoARGB(u32* in, const u32 size) const; | 157 | void converttoARGB(u32* in, const u32 size) const; |
158 | }; | 158 | }; |
159 | 159 | ||
160 | } // end namespace video | 160 | } // end namespace video |
161 | } // end namespace irr | 161 | } // end namespace irr |
162 | 162 | ||
163 | #endif // _IRR_COMPILE_WITH_RGB_LOADER_ | 163 | #endif // _IRR_COMPILE_WITH_RGB_LOADER_ |
164 | #endif // __C_IMAGE_LOADER_RGB_H_INCLUDED__ | 164 | #endif // __C_IMAGE_LOADER_RGB_H_INCLUDED__ |
165 | 165 | ||