diff options
author | Thorbjørn Lindeijer <thorbjorn@lindeijer.nl> | 2012-01-22 20:54:38 +0100 |
---|---|---|
committer | Thorbjørn Lindeijer <thorbjorn@lindeijer.nl> | 2012-01-24 19:07:50 +0100 |
commit | 59c5d1ef260736225ba3ba486f40532949cc293b (patch) | |
tree | 1245fcda33ab2cde58868874cfcb72c7a673465d /src | |
parent | dd1386684b6430337d3b270bec1ca53fa69f9593 (diff) | |
download | mana-59c5d1ef260736225ba3ba486f40532949cc293b.tar.gz mana-59c5d1ef260736225ba3ba486f40532949cc293b.tar.bz2 mana-59c5d1ef260736225ba3ba486f40532949cc293b.tar.xz mana-59c5d1ef260736225ba3ba486f40532949cc293b.zip |
Removed unused function Image::SDLmerge
Reviewed-by: Yohann Ferreira
Diffstat (limited to 'src')
-rw-r--r-- | src/resources/image.cpp | 78 | ||||
-rw-r--r-- | src/resources/image.h | 9 |
2 files changed, 0 insertions, 87 deletions
diff --git a/src/resources/image.cpp b/src/resources/image.cpp index 7f14a73e..31e6a913 100644 --- a/src/resources/image.cpp +++ b/src/resources/image.cpp @@ -326,84 +326,6 @@ void Image::setAlpha(float alpha) } } -Image* Image::SDLmerge(Image *image, int x, int y) -{ - if (!mSDLSurface) - return NULL; - - SDL_Surface* surface = new SDL_Surface(*(image->mSDLSurface)); - - Uint32 surface_pix, cur_pix; - Uint8 r, g, b, a, p_r, p_g, p_b, p_a; - double f_a, f_ca, f_pa; - SDL_PixelFormat *current_fmt = mSDLSurface->format; - SDL_PixelFormat *surface_fmt = surface->format; - int current_offset, surface_offset; - int offset_x, offset_y; - - SDL_LockSurface(surface); - SDL_LockSurface(mSDLSurface); - // for each pixel lines of a source image - for (offset_x = (x > 0 ? 0 : -x); offset_x < image->getWidth() && - x + offset_x < getWidth(); offset_x++) - { - for (offset_y = (y > 0 ? 0 : -y); offset_y < image->getHeight() - && y + offset_y < getHeight(); offset_y++) - { - // Computing offset on both images - current_offset = (y + offset_y) * getWidth() + x + offset_x; - surface_offset = offset_y * surface->w + offset_x; - - // Retrieving a pixel to merge - surface_pix = ((Uint32*) surface->pixels)[surface_offset]; - cur_pix = ((Uint32*) mSDLSurface->pixels)[current_offset]; - - // Retreiving each channel of the pixel using pixel format - 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); - b = (Uint8)(((surface_pix & surface_fmt->Bmask) >> - surface_fmt->Bshift) << surface_fmt->Bloss); - a = (Uint8)(((surface_pix & surface_fmt->Amask) >> - surface_fmt->Ashift) << surface_fmt->Aloss); - - // Retreiving previous alpha value - p_a = (Uint8)(((cur_pix & current_fmt->Amask) >> - current_fmt->Ashift) << current_fmt->Aloss); - - // 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] = - SDL_MapRGBA(current_fmt, r, g, b, a); - 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) >> - current_fmt->Rshift) << current_fmt->Rloss); - p_g = (Uint8)(((cur_pix & current_fmt->Gmask) >> - current_fmt->Gshift) << current_fmt->Gloss); - p_b = (Uint8)(((cur_pix & current_fmt->Bmask) >> - current_fmt->Bshift) << current_fmt->Bloss); - r = (Uint8)((double) p_r * f_ca * f_pa + (double)r * f_a); - g = (Uint8)((double) p_g * f_ca * f_pa + (double)g * f_a); - b = (Uint8)((double) p_b * f_ca * f_pa + (double)b * f_a); - a = (a > p_a ? a : p_a); - ((Uint32 *)(surface->pixels))[current_offset] = - SDL_MapRGBA(current_fmt, r, g, b, a); - } - } - } - SDL_UnlockSurface(surface); - SDL_UnlockSurface(mSDLSurface); - - Image *newImage = new Image(surface); - - return newImage; -} - Image* Image::SDLgetScaledImage(int width, int height) { // No scaling on incorrect new values. diff --git a/src/resources/image.h b/src/resources/image.h index 85db0c17..3ec42ace 100644 --- a/src/resources/image.h +++ b/src/resources/image.h @@ -157,15 +157,6 @@ class Image : public Resource Image* SDLgetScaledImage(int width, int height); /** - * Merges two image SDL_Surfaces together. This is for SDL use only, as - * reducing the number of surfaces that SDL has to render can cut down - * on the number of blit operations necessary, which in turn can help - * improve overall framerates. Don't use unless you are using it to - * reduce the number of overall layers that need to be drawn through SDL. - */ - Image *SDLmerge(Image *image, int x, int y); - - /** * Get the alpha Channel of a SDL surface. */ Uint8 *SDLgetAlphaChannel() const |