31 #ifndef AGS_SHARED_GFX_ALLEGRO_BITMAP_H 32 #define AGS_SHARED_GFX_ALLEGRO_BITMAP_H 34 #include "graphics/screen.h" 35 #include "ags/lib/allegro.h" 36 #include "ags/shared/core/types.h" 37 #include "ags/shared/gfx/bitmap.h" 38 #include "ags/shared/util/string.h" 47 Bitmap(
int width,
int height,
int color_depth = 0);
59 bool Create(
int width,
int height,
int color_depth = 0);
61 bool CreateTransparent(
int width,
int height,
int color_depth = 0);
65 bool CreateSubBitmap(
Bitmap *src,
const Rect &rc);
67 bool ResizeSubBitmap(
int width,
int height);
70 bool CreateCopy(
Bitmap *src,
int color_depth = 0);
73 bool WrapAllegroBitmap(
BITMAP *al_bmp,
bool shared_data);
77 bool LoadFromFile(
const String &filename) {
78 return LoadFromFile(filename.GetCStr());
80 bool LoadFromFile(
const char *filename);
82 bool SaveToFile(
const String &filename,
const void *palette) {
83 return SaveToFile(filename.GetCStr(), palette);
86 bool SaveToFile(
const char *filename,
const void *palette);
90 inline BITMAP *GetAllegroBitmap() {
95 inline bool IsMemoryBitmap()
const {
99 inline bool IsVideoBitmap()
const {
103 inline bool IsLinearBitmap()
const {
108 inline bool isSubBitmap()
const {
109 return _alBitmap->isSubBitmap();
113 inline bool IsSameBitmap(
Bitmap *other)
const {
114 return is_same_bitmap(_alBitmap, other->_alBitmap) != 0;
118 inline bool IsNull()
const {
122 inline bool IsEmpty()
const {
123 return GetWidth() == 0 || GetHeight() == 0;
125 inline int GetWidth()
const {
128 inline int GetHeight()
const {
131 inline Size GetSize()
const {
132 return Size(_alBitmap->w, _alBitmap->h);
135 inline Point GetSubOffset()
const {
139 inline int GetColorDepth()
const {
140 return bitmap_color_depth(_alBitmap);
143 inline int GetBPP()
const {
144 return (GetColorDepth() + 7) / 8;
148 inline int GetDataSize()
const {
149 return GetWidth() * GetHeight() * GetBPP();
152 inline int GetLineLength()
const {
153 return GetWidth() * GetBPP();
159 inline const unsigned char *GetData()
const {
160 return _alBitmap->getPixels();
164 inline const unsigned char *GetScanLine(
int index)
const {
165 assert(index >= 0 && index < GetHeight());
166 return _alBitmap->getBasePtr(0, index);
168 inline unsigned char *GetScanLine(
int index) {
169 assert(index >= 0 && index < GetHeight());
170 return (
unsigned char *)_alBitmap->getBasePtr(0, index);
174 inline color_t GetMaskColor()
const {
175 return bitmap_mask_color(_alBitmap);
182 color_t GetCompatibleColor(color_t
color);
188 void SetClip(
const Rect &rc);
190 Rect GetClip()
const;
196 void Blit(
Bitmap *src,
int dst_x = 0,
int dst_y = 0, BitmapMaskOption mask = kBitmap_Copy);
197 void Blit(
Bitmap *src,
int src_x,
int src_y,
int dst_x,
int dst_y,
int width,
int height, BitmapMaskOption mask = kBitmap_Copy);
199 void MaskedBlit(
Bitmap *src,
int dst_x,
int dst_y);
201 void StretchBlt(
Bitmap *src,
const Rect &dst_rc, BitmapMaskOption mask = kBitmap_Copy);
202 void StretchBlt(
Bitmap *src,
const Rect &src_rc,
const Rect &dst_rc, BitmapMaskOption mask = kBitmap_Copy);
204 void AAStretchBlt(
Bitmap *src,
const Rect &dst_rc, BitmapMaskOption mask = kBitmap_Copy);
205 void AAStretchBlt(
Bitmap *src,
const Rect &src_rc,
const Rect &dst_rc, BitmapMaskOption mask = kBitmap_Copy);
208 void TransBlendBlt(
Bitmap *src,
int dst_x,
int dst_y);
210 void LitBlendBlt(
Bitmap *src,
int dst_x,
int dst_y,
int light_amount);
212 void FlipBlt(
Bitmap *src,
int dst_x,
int dst_y, GraphicFlip flip);
213 void RotateBlt(
Bitmap *src,
int dst_x,
int dst_y, fixed_t angle);
214 void RotateBlt(
Bitmap *src,
int dst_x,
int dst_y,
int pivot_x,
int pivot_y, fixed_t angle);
220 void Clear(color_t color = 0);
221 void ClearTransparent();
226 void PutPixel(
int x,
int y, color_t color);
227 int GetPixel(
int x,
int y)
const;
232 void DrawLine(
const Line &ln, color_t color);
233 void DrawTriangle(
const Triangle &tr, color_t color);
234 void DrawRect(
const Rect &rc, color_t color);
235 void FillRect(
const Rect &rc, color_t color);
236 void FillCircle(
const Circle &circle, color_t color);
238 void Fill(color_t color);
239 void FillTransparent();
241 void FloodFill(
int x,
int y, color_t color);
248 inline unsigned char *GetScanLineForWriting(
int index) {
249 assert(index >= 0 && index < GetHeight());
250 return _alBitmap->line[index];
252 inline unsigned char *GetDataForWriting() {
253 return _alBitmap->line[0];
256 void SetScanLine(
int index,
unsigned char *data,
int data_size = -1);
265 namespace BitmapHelper {
Definition: achievements_tables.h:27
Definition: allegro_bitmap.h:44
Definition: geometry.h:87
Definition: geometry.h:314
Definition: geometry.h:118
Definition: geometry.h:219
int16 x
Definition: rect.h:46
Definition: geometry.h:148
Definition: geometry.h:341
int16 y
Definition: rect.h:47