ScummVM API documentation
tga.h
1/* ScummVM - Graphic Adventure Engine
2 *
3 * ScummVM is the legal property of its developers, whose names
4 * are too numerous to list here. Please refer to the COPYRIGHT
5 * file distributed with this source distribution.
6 *
7 * This program is free software: you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation, either version 3 of the License, or
10 * (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program. If not, see <http://www.gnu.org/licenses/>.
19 *
20 */
21
22/* Based on code from eos https://github.com/DrMcCoy/xoreos/
23 * relicensed under GPLv2+ with permission from DrMcCoy and clone2727
24 */
25
26/*
27 * TGA decoder used in engines:
28 * - gob
29 * - titanic
30 * - wintermute
31 * - zvision
32 */
33
34#ifndef IMAGE_TGA_H
35#define IMAGE_TGA_H
36
37#include "graphics/palette.h"
38#include "graphics/surface.h"
39#include "image/image_decoder.h"
40
41namespace Common {
42class SeekableReadStream;
43}
44
45namespace Image {
46
67class TGADecoder : public ImageDecoder {
68public:
69 TGADecoder();
70 virtual ~TGADecoder();
71 void destroy() override;
72 const Graphics::Surface *getSurface() const override { return &_surface; }
73 const Graphics::Palette &getPalette() const override { return _colorMap; }
74 bool loadStream(Common::SeekableReadStream &stream) override;
75private:
76 // Format-spec from:
77 // https://www.ludorg.net/amnesia/TGA_File_Format_Spec.html
78 enum {
79 TYPE_CMAP = 1,
80 TYPE_TRUECOLOR = 2,
81 TYPE_BW = 3,
82 TYPE_RLE_CMAP = 9,
83 TYPE_RLE_TRUECOLOR = 10,
84 TYPE_RLE_BW = 11
85 };
86
87 // Color-map:
88 bool _colorMapSize;
89 Graphics::Palette _colorMap;
90 int16 _colorMapOrigin;
91 int16 _colorMapLength;
92 byte _colorMapEntryLength;
93
94 // Origin may be at the top, or bottom
95 bool _originTop;
96
98 Graphics::Surface _surface;
99 // Loading helpers
100 bool readHeader(Common::SeekableReadStream &tga, byte &imageType, byte &pixelDepth);
101 bool readData(Common::SeekableReadStream &tga, byte imageType, byte pixelDepth);
102 bool readDataColorMapped(Common::SeekableReadStream &tga, byte imageType, byte indexDepth);
103 bool readDataRLE(Common::SeekableReadStream &tga, byte imageType, byte pixelDepth);
104 bool readColorMap(Common::SeekableReadStream &tga, byte imageType, byte pixelDepth);
105};
107} // End of namespace Image
108
109#endif
Definition: stream.h:745
Simple class for handling a palette data.
Definition: palette.h:61
Definition: image_decoder.h:53
Definition: tga.h:67
const Graphics::Palette & getPalette() const override
Definition: tga.h:73
void destroy() override
const Graphics::Surface * getSurface() const override
Definition: tga.h:72
bool loadStream(Common::SeekableReadStream &stream) override
Definition: algorithm.h:29
Definition: pixelformat.h:138
Definition: surface.h:67