aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/linden/indra/llimage/llimagetga.h
diff options
context:
space:
mode:
Diffstat (limited to 'linden/indra/llimage/llimagetga.h')
-rw-r--r--linden/indra/llimage/llimagetga.h108
1 files changed, 108 insertions, 0 deletions
diff --git a/linden/indra/llimage/llimagetga.h b/linden/indra/llimage/llimagetga.h
new file mode 100644
index 0000000..9575b4d
--- /dev/null
+++ b/linden/indra/llimage/llimagetga.h
@@ -0,0 +1,108 @@
1/**
2 * @file llimagetga.h
3 * @brief Image implementation to compresses and decompressed TGA files.
4 *
5 * Copyright (c) 2001-2007, Linden Research, Inc.
6 *
7 * The source code in this file ("Source Code") is provided by Linden Lab
8 * to you under the terms of the GNU General Public License, version 2.0
9 * ("GPL"), unless you have obtained a separate licensing agreement
10 * ("Other License"), formally executed by you and Linden Lab. Terms of
11 * the GPL can be found in doc/GPL-license.txt in this distribution, or
12 * online at http://secondlife.com/developers/opensource/gplv2
13 *
14 * There are special exceptions to the terms and conditions of the GPL as
15 * it is applied to this Source Code. View the full text of the exception
16 * in the file doc/FLOSS-exception.txt in this software distribution, or
17 * online at http://secondlife.com/developers/opensource/flossexception
18 *
19 * By copying, modifying or distributing this software, you acknowledge
20 * that you have read and understood your obligations described above,
21 * and agree to abide by those obligations.
22 *
23 * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO
24 * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY,
25 * COMPLETENESS OR PERFORMANCE.
26 */
27
28#ifndef LL_LLIMAGETGA_H
29#define LL_LLIMAGETGA_H
30
31#include "llimage.h"
32
33// This class compresses and decompressed TGA (targa) files
34
35class LLImageTGA : public LLImageFormatted
36{
37protected:
38 virtual ~LLImageTGA();
39
40public:
41 LLImageTGA();
42 LLImageTGA(const LLString& file_name);
43
44 /*virtual*/ BOOL updateData();
45 /*virtual*/ BOOL decode(LLImageRaw* raw_image, F32 decode_time=0.0);
46 /*virtual*/ BOOL encode(const LLImageRaw* raw_image, F32 encode_time=0.0);
47
48 BOOL decodeAndProcess(LLImageRaw* raw_image, F32 domain, F32 weight);
49
50private:
51 BOOL decodeTruecolor( LLImageRaw* raw_image, BOOL rle, BOOL flipped );
52
53 BOOL decodeTruecolorRle8( LLImageRaw* raw_image );
54 BOOL decodeTruecolorRle15( LLImageRaw* raw_image );
55 BOOL decodeTruecolorRle24( LLImageRaw* raw_image );
56 BOOL decodeTruecolorRle32( LLImageRaw* raw_image, BOOL &alpha_opaque );
57
58 void decodeTruecolorPixel15( U8* dst, const U8* src );
59
60 BOOL decodeTruecolorNonRle( LLImageRaw* raw_image, BOOL &alpha_opaque );
61
62 BOOL decodeColorMap( LLImageRaw* raw_image, BOOL rle, BOOL flipped );
63
64 void decodeColorMapPixel8(U8* dst, const U8* src);
65 void decodeColorMapPixel15(U8* dst, const U8* src);
66 void decodeColorMapPixel24(U8* dst, const U8* src);
67 void decodeColorMapPixel32(U8* dst, const U8* src);
68
69 bool loadFile(const LLString& file_name);
70
71private:
72 // Class specific data
73 U32 mDataOffset; // Offset from start of data to the actual header.
74
75 // Data from header
76 U8 mIDLength; // Length of identifier string
77 U8 mColorMapType; // 0 = No Map
78 U8 mImageType; // Supported: 2 = Uncompressed true color, 3 = uncompressed monochrome without colormap
79 U8 mColorMapIndexLo; // First color map entry (low order byte)
80 U8 mColorMapIndexHi; // First color map entry (high order byte)
81 U8 mColorMapLengthLo; // Color map length (low order byte)
82 U8 mColorMapLengthHi; // Color map length (high order byte)
83 U8 mColorMapDepth; // Size of color map entry (15, 16, 24, or 32 bits)
84 U8 mXOffsetLo; // X offset of image (low order byte)
85 U8 mXOffsetHi; // X offset of image (hi order byte)
86 U8 mYOffsetLo; // Y offset of image (low order byte)
87 U8 mYOffsetHi; // Y offset of image (hi order byte)
88 U8 mWidthLo; // Width (low order byte)
89 U8 mWidthHi; // Width (hi order byte)
90 U8 mHeightLo; // Height (low order byte)
91 U8 mHeightHi; // Height (hi order byte)
92 U8 mPixelSize; // 8, 16, 24, 32 bits per pixel
93 U8 mAttributeBits; // 4 bits: number of attributes per pixel
94 U8 mOriginRightBit; // 1 bit: origin, 0 = left, 1 = right
95 U8 mOriginTopBit; // 1 bit: origin, 0 = bottom, 1 = top
96 U8 mInterleave; // 2 bits: interleaved flag, 0 = none, 1 = interleaved 2, 2 = interleaved 4
97
98 U8* mColorMap;
99 S32 mColorMapStart;
100 S32 mColorMapLength;
101 S32 mColorMapBytesPerEntry;
102
103 BOOL mIs15Bit;
104
105 static const U8 s5to8bits[32];
106};
107
108#endif