ScummVM API documentation
te_image.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 #ifndef TETRAEDGE_TE_TE_IMAGE_H
23 #define TETRAEDGE_TE_TE_IMAGE_H
24 
25 #include "common/fs.h"
26 #include "common/ptr.h"
27 #include "common/stream.h"
28 #include "common/types.h"
29 #include "common/path.h"
30 
31 #include "graphics/managed_surface.h"
32 
33 #include "tetraedge/te/te_color.h"
34 #include "tetraedge/te/te_palette.h"
35 #include "tetraedge/te/te_vector2s32.h"
36 #include "tetraedge/te/te_resource.h"
37 
38 namespace Tetraedge {
39 
41 public:
42  TeImage();
43  TeImage(const TeImage &other);
44 
45  virtual ~TeImage() {
46  destroy();
47  };
48 
49  enum Format {
50  RGB8 = 5,
51  RGBA8 = 6,
52  // GREY8 = 0xd,
53  INVALID = 0xe
54  };
55  enum SaveType {
56  PNG
57  };
58 
59  void copy(TeImage &dest, const TeVector2s32 &vec1, const TeVector2s32 &vec2,
60  const TeVector2s32 &vec3) const;
61  uint64 countPixelsOfColor(const TeColor &col) const;
62  // void create(); // never used?
63  void createImg(uint xsize, uint ysize, Common::SharedPtr<TePalette> &palette, Format newformat) {
64  createImg(xsize, ysize, palette, newformat, xsize, ysize);
65  }
66  void createImg(uint xsize, uint ysize, Common::SharedPtr<TePalette> &pal,
67  Format format, uint bufxsize, uint bufysize);
68  void deserialize(Common::ReadStream &stream);
69  void destroy();
70  void drawPlot(int x, int y, const TeColor &col) {
71  drawPlot(getPixels(), x, y, bufSize(), col);
72  }
73  void drawPlot(void *outbuf, int x, int y, const TeVector2s32 &bufsize, const TeColor &col);
74  void fill(byte val);
75  void fill(byte r, byte g, byte b, byte a);
76  void getBuff(uint x, uint y, byte *pout, uint w, uint h);
77  bool isExtensionSupported(const Common::Path &path);
78  bool load(const Common::Path &path);
79  bool load(Common::SeekableReadStream &stream, const Common::String &type);
80  bool save(const Common::Path &path, enum SaveType type);
81  int serialize(Common::WriteStream &stream);
82  TeVector2s32 bufSize() const {
83  return TeVector2s32(pitch / format.bytesPerPixel, h);
84  }
85  Format teFormat() const { return _teFormat; }
86 
87 private:
88  Format _teFormat;
89 };
90 
91 } // end namespace Tetraedge
92 
93 #endif // TETRAEDGE_TE_TE_IMAGE_H
Definition: managed_surface.h:51
Definition: te_image.h:40
Definition: str.h:59
int16 & w
Definition: managed_surface.h:117
Definition: detection.h:27
Definition: stream.h:77
int32 & pitch
Definition: managed_surface.h:119
Definition: te_resource.h:31
Definition: te_color.h:30
Definition: path.h:52
Definition: stream.h:745
int16 & h
Definition: managed_surface.h:118
void * getPixels()
Definition: managed_surface.h:269
Definition: te_vector2s32.h:31
Definition: stream.h:385
PixelFormat & format
Definition: managed_surface.h:120
Definition: ptr.h:159