PageRenderTime 92ms CodeModel.GetById 22ms 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
Possible License(s): LGPL-2.1
  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. #ifndef LL_LLIMAGETGA_H
  27. #define LL_LLIMAGETGA_H
  28. #include "llimage.h"
  29. // This class compresses and decompressed TGA (targa) files
  30. class LLImageTGA : public LLImageFormatted
  31. {
  32. protected:
  33. virtual ~LLImageTGA();
  34. public:
  35. LLImageTGA();
  36. LLImageTGA(const std::string& file_name);
  37. /*virtual*/ std::string getExtension() { return std::string("tga"); }
  38. /*virtual*/ BOOL updateData();
  39. /*virtual*/ BOOL decode(LLImageRaw* raw_image, F32 decode_time=0.0);
  40. /*virtual*/ BOOL encode(const LLImageRaw* raw_image, F32 encode_time=0.0);
  41. BOOL decodeAndProcess(LLImageRaw* raw_image, F32 domain, F32 weight);
  42. private:
  43. BOOL decodeTruecolor( LLImageRaw* raw_image, BOOL rle, BOOL flipped );
  44. BOOL decodeTruecolorRle8( LLImageRaw* raw_image );
  45. BOOL decodeTruecolorRle15( LLImageRaw* raw_image );
  46. BOOL decodeTruecolorRle24( LLImageRaw* raw_image );
  47. BOOL decodeTruecolorRle32( LLImageRaw* raw_image, BOOL &alpha_opaque );
  48. void decodeTruecolorPixel15( U8* dst, const U8* src );
  49. BOOL decodeTruecolorNonRle( LLImageRaw* raw_image, BOOL &alpha_opaque );
  50. BOOL decodeColorMap( LLImageRaw* raw_image, BOOL rle, BOOL flipped );
  51. void decodeColorMapPixel8(U8* dst, const U8* src);
  52. void decodeColorMapPixel15(U8* dst, const U8* src);
  53. void decodeColorMapPixel24(U8* dst, const U8* src);
  54. void decodeColorMapPixel32(U8* dst, const U8* src);
  55. bool loadFile(const std::string& file_name);
  56. private:
  57. // Class specific data
  58. U32 mDataOffset; // Offset from start of data to the actual header.
  59. // Data from header
  60. U8 mIDLength; // Length of identifier string
  61. U8 mColorMapType; // 0 = No Map
  62. U8 mImageType; // Supported: 2 = Uncompressed true color, 3 = uncompressed monochrome without colormap
  63. U8 mColorMapIndexLo; // First color map entry (low order byte)
  64. U8 mColorMapIndexHi; // First color map entry (high order byte)
  65. U8 mColorMapLengthLo; // Color map length (low order byte)
  66. U8 mColorMapLengthHi; // Color map length (high order byte)
  67. U8 mColorMapDepth; // Size of color map entry (15, 16, 24, or 32 bits)
  68. U8 mXOffsetLo; // X offset of image (low order byte)
  69. U8 mXOffsetHi; // X offset of image (hi order byte)
  70. U8 mYOffsetLo; // Y offset of image (low order byte)
  71. U8 mYOffsetHi; // Y offset of image (hi order byte)
  72. U8 mWidthLo; // Width (low order byte)
  73. U8 mWidthHi; // Width (hi order byte)
  74. U8 mHeightLo; // Height (low order byte)
  75. U8 mHeightHi; // Height (hi order byte)
  76. U8 mPixelSize; // 8, 16, 24, 32 bits per pixel
  77. U8 mAttributeBits; // 4 bits: number of attributes per pixel
  78. U8 mOriginRightBit; // 1 bit: origin, 0 = left, 1 = right
  79. U8 mOriginTopBit; // 1 bit: origin, 0 = bottom, 1 = top
  80. U8 mInterleave; // 2 bits: interleaved flag, 0 = none, 1 = interleaved 2, 2 = interleaved 4
  81. U8* mColorMap;
  82. S32 mColorMapStart;
  83. S32 mColorMapLength;
  84. S32 mColorMapBytesPerEntry;
  85. BOOL mIs15Bit;
  86. static const U8 s5to8bits[32];
  87. };
  88. #endif