ResidualVM logo ResidualVM website - Forums - Contact us BuildBot - Doxygen - Wiki curved edge

tga.h

Go to the documentation of this file.
00001 /* ScummVM - Graphic Adventure Engine
00002  *
00003  * ScummVM is the legal property of its developers, whose names
00004  * are too numerous to list here. Please refer to the COPYRIGHT
00005  * file distributed with this source distribution.
00006  *
00007  * This program is free software; you can redistribute it and/or
00008  * modify it under the terms of the GNU General Public License
00009  * as published by the Free Software Foundation; either version 2
00010  * of the License, or (at your option) any later version.
00011  *
00012  * This program is distributed in the hope that it will be useful,
00013  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00014  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00015  * GNU General Public License for more details.
00016  *
00017  * You should have received a copy of the GNU General Public License
00018  * along with this program; if not, write to the Free Software
00019  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
00020  *
00021  */
00022 
00023 /* Based on code from eos https://github.com/DrMcCoy/xoreos/
00024  * relicensed under GPLv2+ with permission from DrMcCoy and clone2727
00025  */
00026 
00027 /*
00028  * TGA decoder used in engines:
00029  *  - titanic
00030  *  - wintermute
00031  *  - zvision
00032  */
00033 
00034 #ifndef IMAGE_TGA_H
00035 #define IMAGE_TGA_H
00036 
00037 #include "graphics/surface.h"
00038 #include "image/image_decoder.h"
00039 
00040 namespace Common {
00041 class SeekableReadStream;
00042 }
00043 
00044 namespace Image {
00045 
00058 class TGADecoder : public ImageDecoder {
00059 public:
00060     TGADecoder();
00061     virtual ~TGADecoder();
00062     virtual void destroy();
00063     virtual const Graphics::Surface *getSurface() const { return &_surface; }
00064     virtual const byte *getPalette() const { return _colorMap; }
00065     virtual uint16 getPaletteColorCount() const { return _colorMapLength; }
00066     virtual bool loadStream(Common::SeekableReadStream &stream);
00067 private:
00068     // Format-spec from:
00069     //http://www.ludorg.net/amnesia/TGA_File_Format_Spec.html
00070     enum {
00071         TYPE_CMAP = 1,
00072         TYPE_TRUECOLOR = 2,
00073         TYPE_BW = 3,
00074         TYPE_RLE_CMAP = 9,
00075         TYPE_RLE_TRUECOLOR = 10,
00076         TYPE_RLE_BW = 11
00077     };
00078 
00079     // Color-map:
00080     bool _colorMapSize;
00081     byte *_colorMap;
00082     int16 _colorMapOrigin;
00083     int16 _colorMapLength;
00084     byte _colorMapEntryLength;
00085 
00086     // Origin may be at the top, or bottom
00087     bool _originTop;
00088 
00089     Graphics::PixelFormat _format;
00090     Graphics::Surface _surface;
00091     // Loading helpers
00092     bool readHeader(Common::SeekableReadStream &tga, byte &imageType, byte &pixelDepth);
00093     bool readData(Common::SeekableReadStream &tga, byte imageType, byte pixelDepth);
00094     bool readDataColorMapped(Common::SeekableReadStream &tga, byte imageType, byte indexDepth);
00095     bool readDataRLE(Common::SeekableReadStream &tga, byte imageType, byte pixelDepth);
00096     bool readColorMap(Common::SeekableReadStream &tga, byte imageType, byte pixelDepth);
00097 };
00098 
00099 } // End of namespace Image
00100 
00101 #endif


Generated on Sat Mar 16 2019 05:01:56 for ResidualVM by doxygen 1.7.1
curved edge   curved edge