ScummVM API documentation
bitmap.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 DIRECTOR_CASTMEMBER_BITMAP_H
23 #define DIRECTOR_CASTMEMBER_BITMAP_H
24 
25 #include "director/castmember/castmember.h"
26 
27 namespace Image {
28 class ImageDecoder;
29 }
30 
31 namespace Director {
32 
33 class BitmapCastMember : public CastMember {
34 public:
35  BitmapCastMember(Cast *cast, uint16 castId);
36  BitmapCastMember(Cast *cast, uint16 castId, Common::SeekableReadStreamEndian &stream, uint32 castTag, uint16 version, uint8 flags1 = 0);
37  BitmapCastMember(Cast *cast, uint16 castId, Image::ImageDecoder *img, uint8 flags1 = 0);
38  BitmapCastMember(Cast *cast, uint16 castId, BitmapCastMember &source);
40 
41  CastMember *duplicate(Cast *cast, uint16 castId) override { return (CastMember *)(new BitmapCastMember(cast, castId, *this)); }
42 
43  Graphics::MacWidget *createWidget(Common::Rect &bbox, Channel *channel, SpriteType spriteType) override;
44 
45  bool isModified() override;
46  void createMatte(const Common::Rect &bbox);
47  Graphics::Surface *getMatte(const Common::Rect &bbox);
48  Graphics::Surface *getDitherImg();
49 
50  bool hasField(int field) override;
51  Datum getField(int field) override;
52  void setField(int field, const Datum &value) override;
53 
54  Common::String formatInfo() override;
55 
56  void load() override;
57  void unload() override;
58 
59  PictureReference *getPicture() const;
60  void setPicture(PictureReference &picture);
61  void setPicture(Image::ImageDecoder &image, bool adjustSize);
62 
63  Common::Point getRegistrationOffset() override;
64  Common::Point getRegistrationOffset(int16 width, int16 height) override;
65 
66  CollisionTest isWithin(const Common::Rect &bbox, const Common::Point &pos, InkType ink) override;
67 
68  void writeCastData(Common::SeekableWriteStream *writeStream) override;
69  uint32 writeBITDResource(Common::SeekableWriteStream *writeStream, uint32 offset);
70 
71  uint32 getCastDataSize() override; // This is the size of the data in the 'CASt' resource
72  uint32 getBITDResourceSize();
73 
74  Picture *_picture = nullptr;
75  Graphics::Surface *_ditheredImg;
76  Graphics::Surface *_matte;
77 
78  int _version;
79 
80  uint16 _flags2;
81  uint16 _bytes;
82  CastMemberID _clut;
83  CastMemberID _ditheredTargetClut;
84 
85  uint32 _tag;
86  bool _noMatte;
87  bool _external;
88 
89  // D4 stucture:
90  // uint16 _pitch;
91  // _initialRect // 2
92  // _boundingRect // 10
93  // int16 _regY; // 18
94  // int16 _regX; // 20
95  // uint8 _bitsPerPixel; // 22 when _pitch & 0x8000
96 
97  // D6+ structure
98  uint16 _pitch;
99  // _initialRect // 2
100  // _boundingRect // 10 D%-
101  byte _alphaThreshold; // 10 D7+
102  // padding
103  uint16 _editVersion; // 12 D6+
104  Common::Point _scrollPoint; // 14
105  int16 _regY; // 18
106  int16 _regX; // 20
107  byte _updateFlags; // 21
108 
109  uint8 _bitsPerPixel; // 22 when _pitch & 0x8000
110 
111  // These sit in _flags1
112  enum {
113  kFlagCenterRegPointD4 = 0x01, // centerRegPoint property
114  kFlagMatteD4 = 0x20, // double check value
115  };
116 
117  enum {
118  kFlagDither = 0x01, // Bitmap needs dithering
119  kFlagRemapPalette = 0x02, // Bitmap needs palette remap
120  kFlagSyncPalette = 0x04, // When bitmap comes from outside, sync its palette castmember
121  kFlagDitherOnUpdate = 0x08, // Forced dither
122 
123  // D7+
124  kFlagFollowAlpha = 0x10, // Alpha channel for 32-bit images must be followed
125  kFlagCenterRegPoint = 0x20, // centerRegPoint property
126  kFlagMatte = 0x40, // it is used for matte image
127  kFlagNoAutoCrop = 0x80, // do not automatically crop the image
128  };
129 
130 };
131 
132 } // End of namespace Director
133 
134 #endif
Definition: cast.h:87
Definition: image_decoder.h:53
Definition: str.h:59
Definition: surface.h:67
Definition: channel.h:40
Definition: picture.h:33
Definition: rect.h:524
Definition: archive.h:36
Definition: lingo.h:215
Definition: rect.h:144
Definition: macwidget.h:39
Definition: lingo.h:130
Definition: stream.h:351
Definition: stream.h:944
Definition: bitmap.h:33
Definition: movie_decoder.h:32
Definition: castmember.h:48
Definition: types.h:423