ScummVM API documentation
graphics.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 ASYLUM_SYSTEM_GRAPHICS_H
23 #define ASYLUM_SYSTEM_GRAPHICS_H
24 
25 #include "common/rect.h"
26 #include "common/array.h"
27 
28 #include "graphics/surface.h"
29 
30 #include "asylum/shared.h"
31 
32 namespace Asylum {
33 
34 class AsylumEngine;
35 
36 struct GraphicFrame {
37  int32 size;
38  int32 offset;
39 
40  int16 x;
41  int16 y;
42  Graphics::Surface surface;
43 
44  uint16 getWidth() { return surface.w; }
45  uint16 getHeight() { return surface.h; }
46 
47  GraphicFrame() {
48  size = offset = 0;
49  x = y = 0;
50  }
51 
52  Common::Rect getRect() {
53  return Common::Rect(x, y, x + getWidth(), y + getHeight());
54  }
55 };
56 
57 // Graphic resources can be sprites or images, with multiple frames
59 public:
60  struct ResourceData {
61  char tag[4];
62  uint32 flags;
63  // contentOffset
64  uint32 field_C;
65  uint32 field_10;
66  uint32 field_14;
67  // frameCount
68  uint16 maxWidth;
69  // Offsets
70 
71  ResourceData() {
72  memset(&tag, 0, sizeof(tag));
73  flags = 0;
74  field_C = 0;
75  field_10 = 0;
76  field_14 = 0;
77  maxWidth = 0;
78  }
79  };
80 
82  GraphicResource(AsylumEngine *engine, ResourceId id);
83  ~GraphicResource();
84 
85  bool load(ResourceId id);
86 
90  void copyFrameToDest(byte *dest, uint32 frame);
91 
95  void copySpriteToDest(byte *dest, uint32 frame);
96 
97  GraphicFrame *getFrame(uint32 frame);
98  ResourceId getResourceId() { return _resourceId; }
99  uint32 count() { return _frames.size(); }
100 
101  // FIXME: flags are coordinates for the sound origin!
102  ResourceData getData() { return _data; }
103 
104  // Helper functions
105  static uint32 getFrameCount(AsylumEngine *engine, ResourceId id);
106  static Common::Rect getFrameRect(AsylumEngine *engine, ResourceId id, uint32 index);
107 
108 private:
109  AsylumEngine *_vm;
110 
111  ResourceId _resourceId;
112  ResourceData _data;
114 
115  void init(byte *data, int32 size);
116  void clear();
117 };
118 
119 } // end of namespace Asylum
120 
121 #endif // ASYLUM_SYSTEM_GRAPHICS_H
Definition: surface.h:67
int16 h
Definition: surface.h:76
Definition: array.h:52
Definition: asylum.h:53
Definition: rect.h:144
Definition: asylum.h:73
int16 w
Definition: surface.h:71
Definition: graphics.h:60
Definition: graphics.h:36
Definition: graphics.h:58