From 640bc7546d4d8ad5228e09ed2d280ea12b0690e9 Mon Sep 17 00:00:00 2001 From: nyamatongwe Date: Sat, 25 Jun 2011 07:58:03 +1000 Subject: Initial implementation of RGBA images. --- src/XPM.h | 49 +++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 47 insertions(+), 2 deletions(-) (limited to 'src/XPM.h') diff --git a/src/XPM.h b/src/XPM.h index cb05aae3e..8b72ef08d 100644 --- a/src/XPM.h +++ b/src/XPM.h @@ -24,6 +24,7 @@ class XPM { char codeTransparent; char *codes; ColourPair *colours; + ColourDesired ColourDesiredFromCode(int ch) const; ColourAllocated ColourFromCode(int ch) const; void FillRun(Surface *surface, int code, int startX, int y, int x); char **lines; @@ -46,6 +47,7 @@ public: int GetId() const { return pid; } int GetHeight() const { return height; } int GetWidth() const { return width; } + void PixelAt(int x, int y, ColourDesired &colour, bool &transparent) const; static const char **LinesFormFromTextForm(const char *textForm); }; @@ -64,15 +66,58 @@ public: /// Remove all XPMs. void Clear(); /// Add a XPM. - void Add(int id, const char *textForm); + void Add(int ident, const char *textForm); /// Get XPM by id. - XPM *Get(int id); + XPM *Get(int ident); /// Give the largest height of the set. int GetHeight(); /// Give the largest width of the set. int GetWidth(); }; +/** + * An translucent image stoed as a sequence of RGBA bytes. + */ +class RGBAImage { + // Private so RGBAImage objects can not be copied + RGBAImage(const RGBAImage &); + RGBAImage &operator=(const RGBAImage &); + int height; + int width; + std::vector pixelBytes; +public: + RGBAImage(int width_, int height_, const unsigned char *pixels_); + RGBAImage(const XPM &xpm); + virtual ~RGBAImage(); + int GetHeight() const { return height; } + int GetWidth() const { return width; } + int CountBytes() const; + const unsigned char *Pixels() const; +}; + +/** + * A collection of RGBAImage pixmaps indexed by integer id. + */ +class RGBAImageSet { + typedef std::map ImageMap; + ImageMap images; + mutable int height; ///< Memorize largest height of the set. + mutable int width; ///< Memorize largest width of the set. +public: + RGBAImageSet(); + ~RGBAImageSet(); + /// Remove all images. + void Clear(); + /// Add an image. + void Add(int ident, RGBAImage *image); + /// Get image by id. + RGBAImage *Get(int ident); + /// Give the largest height of the set. + int GetHeight() const; + /// Give the largest width of the set. + int GetWidth() const; +}; + #ifdef SCI_NAMESPACE } #endif -- cgit v1.2.3