diff options
author | Thorbjørn Lindeijer <bjorn@lindeijer.nl> | 2009-08-06 21:26:54 +0200 |
---|---|---|
committer | Thorbjørn Lindeijer <bjorn@lindeijer.nl> | 2009-08-06 21:28:05 +0200 |
commit | 5f35db151850a9ac318743bccfeb20711af5de8d (patch) | |
tree | 596b5b9cbf934a594ec4785d7afcab04259911e6 /src/resources | |
parent | 1bb0f3699b269e0064bb4397ff4d1ddc6b38c1fa (diff) | |
download | mana-client-5f35db151850a9ac318743bccfeb20711af5de8d.tar.gz mana-client-5f35db151850a9ac318743bccfeb20711af5de8d.tar.bz2 mana-client-5f35db151850a9ac318743bccfeb20711af5de8d.tar.xz mana-client-5f35db151850a9ac318743bccfeb20711af5de8d.zip |
Use fillRectangle instead of tiling a colored image
Diffstat (limited to 'src/resources')
-rw-r--r-- | src/resources/image.cpp | 35 | ||||
-rw-r--r-- | src/resources/image.h | 10 |
2 files changed, 8 insertions, 37 deletions
diff --git a/src/resources/image.cpp b/src/resources/image.cpp index 3f9f645a..9af3059a 100644 --- a/src/resources/image.cpp +++ b/src/resources/image.cpp @@ -343,7 +343,7 @@ Image* Image::merge(Image *image, int x, int y) cur_pix = ((Uint32*) mImage->pixels)[current_offset]; // Retreiving each channel of the pixel using pixel format - r = (Uint8)(((surface_pix & surface_fmt->Rmask) >> + r = (Uint8)(((surface_pix & surface_fmt->Rmask) >> surface_fmt->Rshift) << surface_fmt->Rloss); g = (Uint8)(((surface_pix & surface_fmt->Gmask) >> surface_fmt->Gshift) << surface_fmt->Gloss); @@ -358,14 +358,14 @@ Image* Image::merge(Image *image, int x, int y) // new pixel with no alpha or nothing on previous pixel if (a == SDL_ALPHA_OPAQUE || (p_a == 0 && a > 0)) - ((Uint32 *)(surface->pixels))[current_offset] = + ((Uint32 *)(surface->pixels))[current_offset] = SDL_MapRGBA(current_fmt, r, g, b, a); - else if (a > 0) + else if (a > 0) { // alpha is lower => merge color with previous value f_a = (double) a / 255.0; f_ca = 1.0 - f_a; f_pa = (double) p_a / 255.0; - p_r = (Uint8)(((cur_pix & current_fmt->Rmask) >> + p_r = (Uint8)(((cur_pix & current_fmt->Rmask) >> current_fmt->Rshift) << current_fmt->Rloss); p_g = (Uint8)(((cur_pix & current_fmt->Gmask) >> current_fmt->Gshift) << current_fmt->Gloss); @@ -393,42 +393,19 @@ 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. if (width == 0 || height == 0) return NULL; - + // No scaling when there is ... no different given size ... if (width == getWidth() && height == getHeight()) return NULL; Image* scaledImage = NULL; SDL_Surface* scaledSurface = NULL; - + if (mImage) { scaledSurface = _SDLzoomSurface(mImage, diff --git a/src/resources/image.h b/src/resources/image.h index c67686e6..f497f608 100644 --- a/src/resources/image.h +++ b/src/resources/image.h @@ -89,12 +89,12 @@ class Image : public Resource /** * Gets an scaled instance of an image. - * + * * @param width The desired width of the scaled image. * @param height The desired height of the scaled image. * * @return A new Image* object. - */ + */ Image* SDLgetScaledImage(int width, int height); /** @@ -138,12 +138,6 @@ 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 |