diff options
author | Bertram <bertram@cegetel.net> | 2009-07-26 22:34:34 +0200 |
---|---|---|
committer | Bertram <bertram@cegetel.net> | 2009-07-26 22:34:34 +0200 |
commit | 7bc30f545784b26594803b559f1d76d5434027ea (patch) | |
tree | 134d20a14c0fec6c49c1ae72edbc2955c34204bd /src/resources | |
parent | c98665d62a089c978189662c3f526464365f08fa (diff) | |
download | mana-client-7bc30f545784b26594803b559f1d76d5434027ea.tar.gz mana-client-7bc30f545784b26594803b559f1d76d5434027ea.tar.bz2 mana-client-7bc30f545784b26594803b559f1d76d5434027ea.tar.xz mana-client-7bc30f545784b26594803b559f1d76d5434027ea.zip |
Fixed a '+' string operation, and attempt to resolve the Mantis 427.
Diffstat (limited to 'src/resources')
-rw-r--r-- | src/resources/image.cpp | 47 | ||||
-rw-r--r-- | src/resources/image.h | 6 |
2 files changed, 41 insertions, 12 deletions
diff --git a/src/resources/image.cpp b/src/resources/image.cpp index dafc3e87..3f9f645a 100644 --- a/src/resources/image.cpp +++ b/src/resources/image.cpp @@ -299,18 +299,6 @@ bool Image::isAnOpenGLOne() const #endif } -Image *Image::getSubImage(int x, int y, int width, int height) -{ - // Create a new clipped sub-image -#ifdef USE_OPENGL - if (mUseOpenGL) - return new SubImage(this, mGLImage, x, y, width, height, - mTexWidth, mTexHeight); -#endif - - return new SubImage(this, mImage, x, y, width, height); -} - void Image::setAlpha(float a) { if (mAlpha == a) @@ -405,6 +393,29 @@ float Image::getAlpha() const return mAlpha; } +Image* Image::getColoredPattern(Uint8 red, Uint8 green, Uint8 blue) +{ + // A simple pattern used for pattern operations... + SDL_Surface* tmpSurface = SDL_CreateRGBSurface(SDL_SWSURFACE, + 2, 2, 32, 0, 0, 0, 0); + + Image* patternImage = NULL; + + if(tmpSurface) + { + //Fill the surface white + SDL_FillRect(tmpSurface, + &tmpSurface->clip_rect, + SDL_MapRGB(tmpSurface->format, red, green, blue)); + + + patternImage = Image::load(tmpSurface); + } + SDL_FreeSurface(tmpSurface); + + return patternImage; +} + Image* Image::SDLgetScaledImage(int width, int height) { // No scaling on incorrect new values. @@ -458,6 +469,18 @@ int Image::powerOfTwo(int input) } #endif +Image *Image::getSubImage(int x, int y, int width, int height) +{ + // Create a new clipped sub-image +#ifdef USE_OPENGL + if (mUseOpenGL) + return new SubImage(this, mGLImage, x, y, width, height, + mTexWidth, mTexHeight); +#endif + + return new SubImage(this, mImage, x, y, width, height); +} + //============================================================================ // SubImage Class //============================================================================ diff --git a/src/resources/image.h b/src/resources/image.h index 25339e68..c67686e6 100644 --- a/src/resources/image.h +++ b/src/resources/image.h @@ -138,6 +138,12 @@ class Image : public Resource */ float getAlpha() const; + /** + * Returns a 2x2 image filled with the desired color. + * Useful for pattern operations. + */ + static Image* getColoredPattern(Uint8 red, Uint8 green, Uint8 blue); + #ifdef USE_OPENGL /** * Sets the target image format. Use <code>false</code> for SDL and |