tbx  0.7.3
sprite.h
1 /*
2  * tbx RISC OS toolbox library
3  *
4  * Copyright (C) 2010 Alan Buckley All Rights Reserved.
5  *
6  * Permission is hereby granted, free of charge, to any person obtaining a
7  * copy of this software and associated documentation files (the "Software"),
8  * to deal in the Software without restriction, including without limitation
9  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
10  * and/or sell copies of the Software, and to permit persons to whom the
11  * Software is furnished to do so, subject to the following conditions:
12  *
13  * The above copyright notice and this permission notice shall be included
14  * in all copies or substantial portions of the Software.
15  *
16  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19  * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22  * THE SOFTWARE.
23  */
24 
25 #ifndef tbx_sprite_h
26 #define tbx_sprite_h
27 
28 #include "colour.h"
29 #include "image.h"
30 #include "point.h"
31 #include "size.h"
32 #include "scalefactors.h"
33 
34 #include <string>
35 #include <map>
36 
37 namespace tbx
38 {
39  class SpriteArea;
40  class Sprite;
41  class UserSprite;
42  class WimpSprite;
43 
48  const int SPRITE_NAMELEN = 13;
49 
56  {
57  public:
58  ColourPalette(int size = 0);
59  ColourPalette(const ColourPalette &other);
60  ~ColourPalette();
61 
62  void resize(int new_size);
63 
64  void desktop_palette();
65 
66  ColourPalette &operator=(const ColourPalette &other);
67  bool operator==(const ColourPalette &other);
68  bool operator!=(const ColourPalette &other);
69 
76  Colour &operator[](int index) {return _palette[index];}
83  const Colour &operator[](int index) const {return _palette[index];}
84 
91  void entry(int index, const Colour &col) {_palette[index] = col;};
98  Colour entry(int index) const {return _palette[index];};
99 
103  int size() const {return _size;};
107  const Colour *address() const {return &_palette[0];};
108 
109  private:
110  int _size;
111  Colour *_palette;
112  };
113 
114 
122  {
123  public:
127  TranslationTable() {_table = 0;_size = 0;};
128 
129  bool create(int mode, const ColourPalette *pal = 0);
130  bool create(const UserSprite *s);
131  bool create(UserSprite *source, UserSprite *target);
132  bool create(const WimpSprite *s);
133 
137  unsigned char *data() const {return _table;};
138 
139  private:
140  int initialise(int mode);
141 
142  private:
143  unsigned char *_table;
144  int _size;
145  };
146 
147 
148 
153  SF_Colour2dpi90x45 = 0,
154  SF_Colour4dpi45 = 1,
155  SF_Colour2dpi45 = 4,
156  SF_Colour4dpi90x45 = 8,
157  SF_Colour16dpi45 = 9,
158  SF_Colour16dpi90x45 = 12,
159  SF_Colour256dpi45 = 13,
160  SF_Colour256dpi90x45 = 15,
161  SF_Colour2dpi90 = 18,
162  SF_Colour4dpi90 = 19,
163  SF_Colour16dpi90 = 20,
164  SF_Colour256dpi90 = 21
165  };
166 
171  SC_Colour2 = 1,
172  SC_Colour4 = 2,
173  SC_Colour16 = 3,
174  SC_Colour256 = 4,
175  SC_Colour32K = 5,
176  SC_Colour16M = 6
177  };
178 
187  inline int sprite_mode(SpriteColours colours, int horzDpi = 90, int vertDpi = 90)
188  {
189  return (colours << 27) | (horzDpi << 1) | (vertDpi << 14) | 1;
190  }
191 
196  {
197  std::string _message;
198  public:
204  SpriteException(const std::string &m) {_message = m;}
208  const std::string &what() const {return _message;}
209  };
210 
214  typedef int *OsSpriteAreaPtr;
215 
220 
224  typedef int *OsSpritePtr;
225 
232  {
233  public:
234  SpriteArea();
235  ~SpriteArea();
236  SpriteArea(OsSpriteAreaPtr data, bool ownsarea = false);
237  SpriteArea(int size);
238 
239  SpriteArea(const SpriteArea &other);
240  SpriteArea &operator=(const SpriteArea &other);
241 
242  void set(OsSpriteAreaPtr data, bool ownsarea = false);
243 
247  bool is_valid() const {return (_area != 0);}
248 
249  bool initialise(int size);
250  bool load(const std::string &file_name);
251  bool merge(const std::string &file_name);
252  bool save(const std::string &file_name) const;
253 
254  int size() const;
255  int free_space() const;
256  bool resize(int new_size);
257 
258  int sprite_count() const;
259  UserSprite get_sprite(const std::string &name);
260  UserSprite create_sprite(const std::string &name, int width, int height, int mode, bool palette = false);
261  UserSprite create_sprite_pixels(const std::string &name, int width, int height, int mode, bool palette = false);
262 
267  OsSpriteAreaPtr pointer() const {return _area;};
268 
269  bool rename(UserSprite &sprite, const std::string &newname);
270  bool erase(UserSprite &sprite);
271  bool erase(const std::string name);
272 
273  static int calculate_memory(int width, int height, int mode, bool withPalette);
274  static int calculate_mask_size(int width, int height, int mode);
275  static int get_bits_per_pixel(int mode);
276 
277  class iterator;
278 
279  iterator begin();
280  iterator end();
281 
282  UserSprite get_sprite(OsSpritePtr sprite_ptr);
283 
284  private:
285  OsSpriteAreaPtr _area;
286  bool _owns_area;
287  };
288 
292  enum sprite_plot_action {SPA_OVERWRITE, SPA_OR, SPA_AND, SPA_XOR,
293  SPA_INVERT, SPA_NONE, SPA_AND_NOT, SPA_OR_NOT, SPA_USE_MASK};
294 
299  class Sprite : public Image
300  {
301  public:
302  virtual ~Sprite() {};
303 
304  // Image overrides
305  virtual void plot(int x, int y) const;
306  virtual void plot(const Point &pos) const;
307 
315  virtual void plot_raw(const Point &pos, int code = SPA_USE_MASK) const = 0;
326  virtual void plot_scaled(const Point &pos, const ScaleFactors *sf, const TranslationTable *tt = 0, int code = SPA_USE_MASK) const = 0;
334  virtual void plot_screen(const Point &pos, int code = SPA_USE_MASK) const = 0;
342  virtual void plot_raw(int x, int y, int code = SPA_USE_MASK) const = 0;
354  virtual void plot_scaled(int x, int y, const ScaleFactors *sf, const TranslationTable *tt = 0, int code = SPA_USE_MASK) const = 0;
363  virtual void plot_screen(int x, int y, int code = SPA_USE_MASK) const = 0;
364 
370  virtual std::string name() const = 0;
375  virtual int area_id() const = 0;
376 
388  virtual bool info(Size *pixel_size, int *mode = NULL, bool *mask = NULL) const = 0;
389 
390  // Functions using a virtual call to the derived class
396  Size size() const;
402  int width() const;
408  int height() const;
409 
415  Size pixel_size() const {Size ps; info(&ps); return ps;};
421  int mode() const {int m; info(NULL, &m); return m;};
427  bool has_mask() const {bool m; info(NULL, NULL, &m); return m;};
428 
435  virtual void get_wimp_scale(ScaleFactors &factor) const = 0;
436  };
437 
447  class UserSprite : public Sprite
448  {
449  protected:
450  UserSprite(SpriteArea *area, int offset);
451 
452  public:
453  UserSprite();
454  UserSprite(SpriteArea *area, const std::string &name);
455  virtual ~UserSprite();
456 
460  bool operator==(const UserSprite &other) const {return _offset == other._offset && _area == other._area;}
464  bool operator!=(const UserSprite &other) const {return _offset != other._offset || _area != other._area;}
465 
469  bool is_valid() const {return _area != 0 && _offset != 0;}
470  bool rename(const std::string &name);
471 
472  virtual void plot_raw(const Point &pos, int code = SPA_USE_MASK) const;
473  virtual void plot_scaled(const Point &pos, const ScaleFactors *sf, const TranslationTable *tt = 0, int code = SPA_USE_MASK) const;
474  virtual void plot_screen(const Point &pos, int code = SPA_USE_MASK) const;
475  virtual void plot_raw(int x, int y, int code = SPA_USE_MASK) const;
476  virtual void plot_scaled(int x, int y, const ScaleFactors *sf, const TranslationTable *tt = 0, int code = SPA_USE_MASK) const;
477  virtual void plot_screen(int x, int y, int code = SPA_USE_MASK) const;
478 
479  virtual std::string name() const;
480  virtual bool info(Size *pixel_size, int *mode = NULL, bool *mask = NULL) const;
481 
482  bool get_palette(ColourPalette &pal) const;
483  bool set_palette(ColourPalette &pal);
484  bool create_palette(bool col256 = false);
485  bool create_palette(ColourPalette &pal);
486  bool remove_palette();
487  bool create_mask();
488  bool remove_mask();
489 
490  int pixel(int x, int y) const;
491  void pixel(int x, int y, int gcol);
492  void pixel(int x, int y, int gcol, int tint);
493  int pixel(int x, int y, int *tint) const;
494 
495  bool mask_pixel(int x, int y) const;
496  void mask_pixel(int x, int y, bool on);
497 
501  SpriteArea *get_sprite_area() const {return _area;};
502 
506  int offset() const {return _offset;}
507 
511  OsSpritePtr pointer() const {return (OsSpritePtr)((char *)(_area->pointer()) + _offset);};
512 
517  virtual int area_id() const {return (int)(_area->pointer());}
518 
522  bool has_palette() const {return (*(pointer() + 8) > 0x2C);};
523 
524  virtual void get_wimp_scale(ScaleFactors &factor) const;
525 
526  friend class SpriteArea;
527 
528  protected:
530  int _offset;
531  };
532 
537  {
538  UserSprite _sprite;
539  friend class SpriteArea;
540 
541  public:
546  iterator operator++() {next_sprite(); return *this;}
551  iterator operator++(int) {iterator tmp(*this); next_sprite(); return tmp;}
555  UserSprite operator*() {return _sprite;}
561  bool operator==(const iterator &other) const {return _sprite == other._sprite;}
567  bool operator!=(const iterator &other) const {return _sprite != other._sprite;}
568 
569  private:
570  void next_sprite();
571  };
572 
577  {
578  char *_save_area;
579  int _save_regs[4];
580  UserSprite *_sprite;
581  bool _capturing;
582 
583  public:
584  SpriteCapture(UserSprite *sprite, bool start_capture = false, bool to_mask = false);
585  ~SpriteCapture();
586 
587  bool capture();
588  bool release();
594  bool is_capturing() {return _capturing;}
595  };
596 
604  class WimpSprite : public Sprite
605  {
606  public:
619  WimpSprite(const std::string &sname) : _name(sname) {};
632  WimpSprite(const char *sname) : _name(sname) {};
633  WimpSprite(int file_type);
634  WimpSprite(int file_type, std::string leafname);
635 
636  virtual ~WimpSprite() {};
637 
638  bool exist() const;
639 
640  virtual void plot_raw(const Point &pos, int code = SPA_USE_MASK) const ;
641  virtual void plot_scaled(const Point &pos, const ScaleFactors *sf, const TranslationTable *tt = NULL, int code = SPA_USE_MASK) const;
642  virtual void plot_screen(const Point &pos, int code = SPA_USE_MASK) const;
643  virtual void plot_raw(int x, int y, int code = SPA_USE_MASK) const ;
644  virtual void plot_scaled(int x, int y, const ScaleFactors *sf, const TranslationTable *tt = NULL, int code = SPA_USE_MASK) const;
645  virtual void plot_screen(int x, int y, int code = SPA_USE_MASK) const;
646 
647  virtual std::string name() const {return _name;}
648  virtual bool info(Size *pixel_size, int *mode = NULL, bool *mask = NULL) const;
649 
650  virtual void get_wimp_scale(ScaleFactors &factor) const;
651 
658  virtual int area_id() const {return 1;}
659 
660  bool has_palette() const;
661 
662 
663  private:
664  std::string _name;
665  };
666 };
667 
668 #endif
static int get_bits_per_pixel(int mode)
Calculate the number of bits required for one pixel for the given mode.
Definition: sprite.cc:952
int size() const
Return the size of the palette.
Definition: sprite.h:103
int * OsSpriteAreaPtr
Type for pointer to underlying RISC OS Sprite area.
Definition: sprite.h:214
bool is_valid() const
Returns true if area is valid.
Definition: sprite.h:247
int * OsSpritePtr
Type for pointer to underlyin RISC OS sprite.
Definition: sprite.h:224
Class to represent a two-dimensional size.
Definition: size.h:34
bool operator!=(const iterator &other) const
See if iterators are not equal.
Definition: sprite.h:567
bool erase(UserSprite &sprite)
Erase a sprite from the sprite area.
Definition: sprite.cc:1224
bool operator==(const iterator &other) const
See if iterators are equal.
Definition: sprite.h:561
SpriteArea * get_sprite_area() const
Return SpriteArea this sprite is from.
Definition: sprite.h:501
bool merge(const std::string &file_name)
Merge a sprite area from a file into this sprite area.
Definition: sprite.cc:1089
UserSprite()
Construct an unassigned sprite.
Definition: sprite.cc:126
virtual void plot_scaled(const Point &pos, const ScaleFactors *sf, const TranslationTable *tt=0, int code=SPA_USE_MASK) const =0
Plot sprite scaled.
virtual std::string name() const =0
Get the name of the sprite.
virtual bool info(Size *pixel_size, int *mode=NULL, bool *mask=NULL) const =0
Get information about the sprite.
int size() const
Get the size of the sprite area.
Definition: sprite.cc:1142
~SpriteCapture()
Sprite capture destructor.
Definition: sprite.cc:1601
int height() const
Return the height of the sprite.
Definition: sprite.cc:106
virtual void get_wimp_scale(ScaleFactors &factor) const
Get the scale factors required to plot this sprite in the WIMP as its logical size.
Definition: sprite.cc:633
bool resize(int new_size)
Resize the sprite area.
Definition: sprite.cc:1163
virtual void plot_scaled(const Point &pos, const ScaleFactors *sf, const TranslationTable *tt=0, int code=SPA_USE_MASK) const
Plot this sprite scaled using the given colour translation.
Definition: sprite.cc:203
bool operator==(const UserSprite &other) const
Check if two sprite classes refer to the same underlying sprite.
Definition: sprite.h:460
virtual int area_id() const =0
Return sprite area id used for calls that take an area pointer or a special value for WIMP/System are...
int mode() const
Get the mode of the sprite.
Definition: sprite.h:421
bool mask_pixel(int x, int y) const
Check is mask pixel is set at given location.
Definition: sprite.cc:604
virtual void plot_raw(const Point &pos, int code=SPA_USE_MASK) const
Plot this sprite at the given position with no scaling or colour conversions.
Definition: sprite.cc:180
WimpSprite(const std::string &sname)
Construct a WIMP sprite.
Definition: sprite.h:619
SpriteArea()
Construct an uninitialised sprite area.
Definition: sprite.cc:648
const Colour & operator[](int index) const
Get constant reference to colour in the palette.
Definition: sprite.h:83
iterator end()
Return an iterator to the sprite after the last one in the sprite area.
Definition: sprite.cc:880
virtual void plot_raw(const Point &pos, int code=SPA_USE_MASK) const =0
Plot sprite with no scaling or colour translation.
SpriteArea * _area
Sprite area containing this sprite.
Definition: sprite.h:529
bool exist() const
Check if this sprite exists in the Wimp sprite area.
Definition: sprite.cc:1708
bool is_valid() const
Check this sprite object is valid.
Definition: sprite.h:469
iterator operator++(int)
Move to next sprite in the area.
Definition: sprite.h:551
Size size() const
Return the size of the sprite.
Definition: sprite.cc:70
UserSprite get_sprite(const std::string &name)
Get a sprite from this sprite area by name.
Definition: sprite.cc:747
virtual void plot_raw(const Point &pos, int code=SPA_USE_MASK) const
Plot this sprite at the given position with no scaling or colour conversions.
Definition: sprite.cc:1719
iterator begin()
Return an iterator to the first sprite in the sprite area.
Definition: sprite.cc:864
void resize(int new_size)
Resize the colour palette.
Definition: sprite.cc:1496
Sprite from a user sprite area.
Definition: sprite.h:447
bool save(const std::string &file_name) const
Save the sprite area to a file.
Definition: sprite.cc:1121
Class to capture screen output to a sprite.
Definition: sprite.h:576
ColourPalette & operator=(const ColourPalette &other)
Assign to a copy of another palette.
Definition: sprite.cc:1525
Exception thrown for sprite method failures.
Definition: sprite.h:195
bool has_palette() const
Returns true if this sprite has a palette.
Definition: sprite.h:522
bool set_palette(ColourPalette &pal)
Set the sprites palette.
Definition: sprite.cc:388
A class to hold a list of Colours for the a colour palette.
Definition: sprite.h:55
virtual bool info(Size *pixel_size, int *mode=NULL, bool *mask=NULL) const
Get information about the sprite.
Definition: sprite.cc:326
const Colour * address() const
Get a pointer to the array of colours.
Definition: sprite.h:107
int sprite_count() const
Return the number of sprites in the sprite area.
Definition: sprite.cc:1003
iterator operator++()
Move to next sprite in the area.
Definition: sprite.h:546
int pixel(int x, int y) const
Get pixel at given location.
Definition: sprite.cc:518
Base class image classes providing a consistent interface to plot the to the screen.
Definition: image.h:44
OsSpritePtr pointer() const
Return pointer to underlying RISC OS sprite.
Definition: sprite.h:511
bool initialise(int size)
Initialise a new user sprite area.
Definition: sprite.cc:1026
Class for handling sprites from the Wimp sprite pool.
Definition: sprite.h:604
void entry(int index, const Colour &col)
Set the specified index to the given colour.
Definition: sprite.h:91
Common base class for the UserSprite and WimpSprite classes.
Definition: sprite.h:299
bool create_palette(bool col256=false)
Create a palette for a sprite.
Definition: sprite.cc:415
bool release()
Release screen output from sprite.
Definition: sprite.cc:1636
SpriteFormat
Standard sprite formats (colour <= 256)
Definition: sprite.h:152
void set(OsSpriteAreaPtr data, bool ownsarea=false)
Assign this sprite area to a sprite area pointer.
Definition: sprite.cc:732
int offset() const
Return offset of this sprite in the sprite area.
Definition: sprite.h:506
Class to represent a position in two dimensional space.
Definition: point.h:36
sprite_plot_action
Enumeration of the plot actions for sprites.
Definition: sprite.h:292
virtual void plot_screen(const Point &pos, int code=SPA_USE_MASK) const =0
Plot sprite to screen calculating the correct colour translation and scaling.
bool operator!=(const ColourPalette &other)
Check if two palette have one or more colours different.
Definition: sprite.cc:1564
bool operator!=(const UserSprite &other) const
Check if two sprite classes DO NOT refer to the same underlying sprite.
Definition: sprite.h:464
static int calculate_mask_size(int width, int height, int mode)
Calculate the size required for a sprite mask.
Definition: sprite.cc:927
virtual void plot_screen(const Point &pos, int code=SPA_USE_MASK) const
Plot sprite to screen.
Definition: sprite.cc:1765
const std::string & what() const
Return the error message for the exception.
Definition: sprite.h:208
bool create(int mode, const ColourPalette *pal=0)
Create a colour translation table for the given screen mode and optional palette. ...
Definition: sprite.cc:1263
bool has_mask() const
Check if the sprite has a mask.
Definition: sprite.h:427
bool get_palette(ColourPalette &pal) const
Get palette (non-flashing colours only) for this sprite.
Definition: sprite.cc:364
Colour & operator[](int index)
Get reference to colour in the palette.
Definition: sprite.h:76
virtual std::string name() const
Get the name of the sprite.
Definition: sprite.h:647
TranslationTable()
Construct an empty translation table.
Definition: sprite.h:127
unsigned char * data() const
Return a pointer to the translation table data.
Definition: sprite.h:137
virtual void plot(int x, int y) const
Plot sprite to screen.
Definition: sprite.cc:55
int _offset
offset of sprite within the sprite area
Definition: sprite.h:530
virtual void get_wimp_scale(ScaleFactors &factor) const
Get the scale factors required to plot this sprite in the WIMP as its logical size.
Definition: sprite.cc:1842
const OsSpriteAreaPtr WIMP_SPRITEAREA
Constant representing the WIMP sprite area.
Definition: sprite.h:219
SpriteCapture(UserSprite *sprite, bool start_capture=false, bool to_mask=false)
Class to capture screen output to a sprite.
Definition: sprite.cc:1579
bool operator==(const ColourPalette &other)
Check if two palettes contain all the same colours.
Definition: sprite.cc:1548
Colour entry(int index) const
Return the colour for the specified index.
Definition: sprite.h:98
SpriteColours
Sprite colour constant.
Definition: sprite.h:170
Class for sprite ScaleFactors.
Definition: scalefactors.h:45
UserSprite create_sprite_pixels(const std::string &name, int width, int height, int mode, bool palette=false)
Create a new sprite, size measured in pixels.
Definition: sprite.cc:810
bool remove_palette()
Remove palette from a sprite.
Definition: sprite.cc:455
const int SPRITE_NAMELEN
Maximum length of a sprite name including a terminating character 0.
Definition: sprite.h:48
Class for a sprite colour translation table.
Definition: sprite.h:121
virtual void plot_screen(const Point &pos, int code=SPA_USE_MASK) const
Plot sprite to screen.
Definition: sprite.cc:226
~SpriteArea()
Destructor deletes the RISC OS sprite area if it owns it.
Definition: sprite.cc:685
OsSpriteAreaPtr pointer() const
Return pointer to underlying sprite are that can be used when using low-level area manipulation...
Definition: sprite.h:267
bool rename(const std::string &name)
Renames the sprite.
Definition: sprite.cc:169
Iterator class for iterating through UserSprites in a sprite area.
Definition: sprite.h:536
Size pixel_size() const
Get size of the sprite in pixels.
Definition: sprite.h:415
SpriteArea & operator=(const SpriteArea &other)
Deletes current area and replaces it with a copy of the given area.
Definition: sprite.cc:711
bool rename(UserSprite &sprite, const std::string &newname)
Rename a sprite in a sprite area.
Definition: sprite.cc:1200
Class to represent a RGB colour.
Definition: colour.h:43
int width() const
Return the width of the sprite.
Definition: sprite.cc:88
bool load(const std::string &file_name)
Load a sprite area from a file.
Definition: sprite.cc:1055
bool is_capturing()
Check if this capture is capturing to the sprite.
Definition: sprite.h:594
virtual int area_id() const
Return sprite area id used for calls that take an area pointer or a special value for WIMP/System are...
Definition: sprite.h:517
UserSprite create_sprite(const std::string &name, int width, int height, int mode, bool palette=false)
Create a new sprite.
Definition: sprite.cc:792
virtual void plot_scaled(const Point &pos, const ScaleFactors *sf, const TranslationTable *tt=NULL, int code=SPA_USE_MASK) const
Plot this sprite scaled using the given colour translation.
Definition: sprite.cc:1742
bool capture()
Capture screen output to sprite or sprites mask.
Definition: sprite.cc:1612
virtual int area_id() const
Return sprite area id used for calls that take an area pointer or a special value for WIMP/System are...
Definition: sprite.h:658
bool remove_mask()
Remove sprite mask.
Definition: sprite.cc:497
virtual ~UserSprite()
Destructor - not this does not delete the sprite from the sprite area as this class is just a referen...
Definition: sprite.cc:160
SpriteException(const std::string &m)
Construct exception with the given message.
Definition: sprite.h:204
A SpriteArea holds zero or more user sprites.
Definition: sprite.h:231
int sprite_mode(SpriteColours colours, int horzDpi=90, int vertDpi=90)
Return new format sprite mode.
Definition: sprite.h:187
virtual std::string name() const
Get the name of the sprite.
Definition: sprite.cc:310
bool create_mask()
Create a mask for the sprite.
Definition: sprite.cc:472
int free_space() const
Get the free space in the sprite area.
Definition: sprite.cc:1152
UserSprite operator*()
Get the sprite the iterator is pointing at.
Definition: sprite.h:555
WimpSprite(const char *sname)
Construct a WIMP sprite.
Definition: sprite.h:632
virtual void get_wimp_scale(ScaleFactors &factor) const =0
Get the scale factors required to plot this sprite in the WIMP as its logical size.
ColourPalette(int size=0)
Construct a colour palette of a specified size.
Definition: sprite.cc:1458
virtual bool info(Size *pixel_size, int *mode=NULL, bool *mask=NULL) const
Get information about the sprite.
Definition: sprite.cc:1876
bool has_palette() const
Check if WimpSprite is using a palette.
Definition: sprite.cc:1857
static int calculate_memory(int width, int height, int mode, bool withPalette)
Calculate the memory required to create a sprite.
Definition: sprite.cc:894
void desktop_palette()
Convert this palette to the current desktop palette.
Definition: sprite.cc:1507