PageRenderTime 34ms CodeModel.GetById 16ms app.highlight 15ms RepoModel.GetById 1ms app.codeStats 0ms

/indra/llimage/llimagetga.h

https://bitbucket.org/lindenlab/viewer-beta/
C++ Header | 108 lines | 60 code | 20 blank | 28 comment | 0 complexity | ab9d082a4443ed801affe882d367bea4 MD5 | raw file
  1/** 
  2 * @file llimagetga.h
  3 * @brief Image implementation to compresses and decompressed TGA files.
  4 *
  5 * $LicenseInfo:firstyear=2001&license=viewerlgpl$
  6 * Second Life Viewer Source Code
  7 * Copyright (C) 2010, Linden Research, Inc.
  8 * 
  9 * This library is free software; you can redistribute it and/or
 10 * modify it under the terms of the GNU Lesser General Public
 11 * License as published by the Free Software Foundation;
 12 * version 2.1 of the License only.
 13 * 
 14 * This library is distributed in the hope that it will be useful,
 15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 17 * Lesser General Public License for more details.
 18 * 
 19 * You should have received a copy of the GNU Lesser General Public
 20 * License along with this library; if not, write to the Free Software
 21 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
 22 * 
 23 * Linden Research, Inc., 945 Battery Street, San Francisco, CA  94111  USA
 24 * $/LicenseInfo$
 25 */
 26
 27#ifndef LL_LLIMAGETGA_H
 28#define LL_LLIMAGETGA_H
 29
 30#include "llimage.h"
 31
 32// This class compresses and decompressed TGA (targa) files
 33
 34class LLImageTGA : public LLImageFormatted
 35{
 36protected:
 37	virtual ~LLImageTGA();
 38	
 39public:
 40	LLImageTGA();
 41	LLImageTGA(const std::string& file_name);
 42
 43	/*virtual*/ std::string getExtension() { return std::string("tga"); }
 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 std::string& 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