32 #include "scalefactors.h" 91 void entry(
int index,
const Colour &col) {_palette[index] = col;};
103 int size()
const {
return _size;};
137 unsigned char *
data()
const {
return _table;};
140 int initialise(
int mode);
143 unsigned char *_table;
153 SF_Colour2dpi90x45 = 0,
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
189 return (colours << 27) | (horzDpi << 1) | (vertDpi << 14) | 1;
197 std::string _message;
208 const std::string &
what()
const {
return _message;}
236 SpriteArea(OsSpriteAreaPtr data,
bool ownsarea =
false);
242 void set(OsSpriteAreaPtr data,
bool ownsarea =
false);
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;
255 int free_space()
const;
256 bool resize(
int new_size);
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);
267 OsSpriteAreaPtr
pointer()
const {
return _area;};
269 bool rename(
UserSprite &sprite,
const std::string &newname);
271 bool erase(
const std::string name);
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);
282 UserSprite get_sprite(OsSpritePtr sprite_ptr);
285 OsSpriteAreaPtr _area;
293 SPA_INVERT, SPA_NONE, SPA_AND_NOT, SPA_OR_NOT, SPA_USE_MASK};
305 virtual void plot(
int x,
int y)
const;
306 virtual void plot(
const Point &pos)
const;
315 virtual void plot_raw(
const Point &pos,
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;
363 virtual void plot_screen(
int x,
int y,
int code = SPA_USE_MASK)
const = 0;
370 virtual std::string name()
const = 0;
375 virtual int area_id()
const = 0;
388 virtual bool info(
Size *pixel_size,
int *mode = NULL,
bool *mask = NULL)
const = 0;
421 int mode()
const {
int m; info(NULL, &m);
return m;};
427 bool has_mask()
const {
bool m; info(NULL, NULL, &m);
return m;};
435 virtual void get_wimp_scale(
ScaleFactors &factor)
const = 0;
469 bool is_valid()
const {
return _area != 0 && _offset != 0;}
470 bool rename(
const std::string &name);
472 virtual void plot_raw(
const Point &pos,
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;
477 virtual void plot_screen(
int x,
int y,
int code = SPA_USE_MASK)
const;
479 virtual std::string name()
const;
480 virtual bool info(
Size *pixel_size,
int *mode = NULL,
bool *mask = NULL)
const;
484 bool create_palette(
bool col256 =
false);
486 bool remove_palette();
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;
495 bool mask_pixel(
int x,
int y)
const;
496 void mask_pixel(
int x,
int y,
bool on);
511 OsSpritePtr
pointer()
const {
return (OsSpritePtr)((
char *)(_area->pointer()) + _offset);};
517 virtual int area_id()
const {
return (
int)(_area->pointer());}
524 virtual void get_wimp_scale(
ScaleFactors &factor)
const;
634 WimpSprite(
int file_type, std::string leafname);
640 virtual void plot_raw(
const Point &pos,
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 ;
645 virtual void plot_screen(
int x,
int y,
int code = SPA_USE_MASK)
const;
647 virtual std::string
name()
const {
return _name;}
648 virtual bool info(
Size *pixel_size,
int *mode = NULL,
bool *mask = NULL)
const;
650 virtual void get_wimp_scale(
ScaleFactors &factor)
const;
660 bool has_palette()
const;
bool has_mask() const
Check if the sprite has a mask.
Definition: sprite.h:427
A library for creating RISC OS toolbox applications.
Definition: abouttobeshownlistener.cc:34
int * OsSpriteAreaPtr
Type for pointer to underlying RISC OS Sprite area.
Definition: sprite.h:214
const std::string & what() const
Return the error message for the exception.
Definition: sprite.h:208
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
OsSpritePtr pointer() const
Return pointer to underlying RISC OS sprite.
Definition: sprite.h:511
Colour entry(int index) const
Return the colour for the specified index.
Definition: sprite.h:98
const Colour & operator[](int index) const
Get constant reference to colour in the palette.
Definition: sprite.h:83
bool is_valid() const
Returns true if area is valid.
Definition: sprite.h:247
Size pixel_size() const
Get size of the sprite in pixels.
Definition: sprite.h:415
WimpSprite(const std::string &sname)
Construct a WIMP sprite.
Definition: sprite.h:619
SpriteArea * _area
Sprite area containing this sprite.
Definition: sprite.h:529
iterator operator++(int)
Move to next sprite in the area.
Definition: sprite.h:551
bool has_palette() const
Returns true if this sprite has a palette.
Definition: sprite.h:522
void resize(int new_size)
Resize the colour palette.
Definition: sprite.cc:1496
Sprite from a user sprite area.
Definition: sprite.h:447
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
int size() const
Return the size of the palette.
Definition: sprite.h:103
A class to hold a list of Colours for the a colour palette.
Definition: sprite.h:55
iterator operator++()
Move to next sprite in the area.
Definition: sprite.h:546
Base class image classes providing a consistent interface to plot the to the screen.
Definition: image.h:44
virtual std::string name() const
Get the name of the sprite.
Definition: sprite.h:647
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
SpriteFormat
Standard sprite formats (colour <= 256)
Definition: sprite.h:152
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
bool operator!=(const ColourPalette &other)
Check if two palette have one or more colours different.
Definition: sprite.cc:1564
unsigned char * data() const
Return a pointer to the translation table data.
Definition: sprite.h:137
OsSpriteAreaPtr pointer() const
Return pointer to underlying sprite are that can be used when using low-level area manipulation...
Definition: sprite.h:267
Colour & operator[](int index)
Get reference to colour in the palette.
Definition: sprite.h:76
TranslationTable()
Construct an empty translation table.
Definition: sprite.h:127
int _offset
offset of sprite within the sprite area
Definition: sprite.h:530
const OsSpriteAreaPtr WIMP_SPRITEAREA
Constant representing the WIMP sprite area.
Definition: sprite.h:219
bool operator==(const ColourPalette &other)
Check if two palettes contain all the same colours.
Definition: sprite.cc:1548
SpriteColours
Sprite colour constant.
Definition: sprite.h:170
Class for sprite ScaleFactors.
Definition: scalefactors.h:45
const int SPRITE_NAMELEN
Maximum length of a sprite name including a terminating character 0.
Definition: sprite.h:48
bool operator!=(const iterator &other) const
See if iterators are not equal.
Definition: sprite.h:567
Class for a sprite colour translation table.
Definition: sprite.h:121
bool operator!=(const UserSprite &other) const
Check if two sprite classes DO NOT refer to the same underlying sprite.
Definition: sprite.h:464
SpriteArea * get_sprite_area() const
Return SpriteArea this sprite is from.
Definition: sprite.h:501
Iterator class for iterating through UserSprites in a sprite area.
Definition: sprite.h:536
int mode() const
Get the mode of the sprite.
Definition: sprite.h:421
Class to represent a RGB colour.
Definition: colour.h:43
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
const Colour * address() const
Get a pointer to the array of colours.
Definition: sprite.h:107
bool is_capturing()
Check if this capture is capturing to the sprite.
Definition: sprite.h:594
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
bool is_valid() const
Check this sprite object is valid.
Definition: sprite.h:469
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
int sprite_mode(SpriteColours colours, int horzDpi=90, int vertDpi=90)
Return new format sprite mode.
Definition: sprite.h:187
bool operator==(const iterator &other) const
See if iterators are equal.
Definition: sprite.h:561
int offset() const
Return offset of this sprite in the sprite area.
Definition: sprite.h:506
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
bool operator==(const UserSprite &other) const
Check if two sprite classes refer to the same underlying sprite.
Definition: sprite.h:460
ColourPalette(int size=0)
Construct a colour palette of a specified size.
Definition: sprite.cc:1458
void desktop_palette()
Convert this palette to the current desktop palette.
Definition: sprite.cc:1507