From b7170d13fd71fb624c06c4536974a7cd3f77591b Mon Sep 17 00:00:00 2001 From: Bjørn Lindeijer Date: Fri, 14 Jan 2005 15:43:26 +0000 Subject: Rewrote Spriteset to work with Image* instead of BITMAP* --- src/resources/image.h | 44 ++++++++++++++++++++++++++++++-------------- 1 file changed, 30 insertions(+), 14 deletions(-) (limited to 'src/resources/image.h') diff --git a/src/resources/image.h b/src/resources/image.h index 8f956324..0452cd4a 100644 --- a/src/resources/image.h +++ b/src/resources/image.h @@ -28,10 +28,9 @@ //#include #include -/** - * A clipped version of a larger image. - */ +// Forward declarations class SubImage; +class ScaledImage; /** * Defines a class for loading and storing images. @@ -60,24 +59,29 @@ class Image : public Resource /** * Frees the resources created by SDL. */ - void unload(); + virtual void unload(); /** * Returns the width of the image. */ - int getWidth(); + virtual int getWidth() const; /** * Returns the height of the image. */ - int getHeight(); + virtual int getHeight() const; /** * Creates a new image with the desired clipping rectangle. * @return NULL if creation failed and a valid * object otherwise. */ - Image* createSubImage(int x, int y, int width, int height); + virtual Image* getSubImage(int x, int y, int width, int height); + + /** + * Creates a scaled version of this image. + */ + virtual Image* getScaledInstance(int width, int height); /** * Blits the internal image onto the screen. @@ -85,12 +89,12 @@ class Image : public Resource * @return true if the image was blitted properly * false otherwise. */ - bool draw(BITMAP *screen, int x, int y); + virtual bool draw(BITMAP *screen, int x, int y); /** * Does a pattern fill on the given area. */ - void drawPattern(BITMAP *screen, int x, int y, int w, int h); + virtual void drawPattern(BITMAP *screen, int x, int y, int w, int h); protected: //SDL_Rect screenRect; @@ -116,11 +120,6 @@ class SubImage : public Image */ ~SubImage(); - /** - * Redefines unload to not do anything. - */ - void unload(); - /** * Draws the clipped image onto the screen. * @return true if drawing was succesful @@ -138,4 +137,21 @@ class SubImage : public Image //unsigned int referenceCount; }; +/** + * A scaled version of an image. + */ +class ScaledImage : public Image +{ + public: + /** + * Constructor. + */ + ScaledImage(Image *parent, BITMAP *image, int width, int height); + + /** + * Destructor. + */ + ~ScaledImage(); +}; + #endif -- cgit v1.2.3-70-g09d2