diff options
author | Bertram <bertram@cegetel.net> | 2009-07-24 22:59:13 +0200 |
---|---|---|
committer | Bertram <bertram@cegetel.net> | 2009-07-24 22:59:13 +0200 |
commit | 8195e73cb801d56240beb966554a864729d9f20c (patch) | |
tree | f2a00036d15eaf70cb9abe4930b4199b1e5eae05 /src/graphics.cpp | |
parent | ea6f492198a03cffc3be47df000fa16dfc3b262f (diff) | |
download | mana-8195e73cb801d56240beb966554a864729d9f20c.tar.gz mana-8195e73cb801d56240beb966554a864729d9f20c.tar.bz2 mana-8195e73cb801d56240beb966554a864729d9f20c.tar.xz mana-8195e73cb801d56240beb966554a864729d9f20c.zip |
Made the wallpaper be rescaled when necessary under SDL and OpenGL.
The SDL methods to rescale the wallpaper has been optimized to permit rescaling
at load time while OpenGL draws directly rescaled. Does someone know how to smooth
the rescaled image under OpenGL?
Diffstat (limited to 'src/graphics.cpp')
-rw-r--r-- | src/graphics.cpp | 41 |
1 files changed, 39 insertions, 2 deletions
diff --git a/src/graphics.cpp b/src/graphics.cpp index 58f643e9..b84e0bf6 100644 --- a/src/graphics.cpp +++ b/src/graphics.cpp @@ -120,11 +120,47 @@ bool Graphics::drawImage(Image *image, int x, int y) return drawImage(image, 0, 0, x, y, image->mBounds.w, image->mBounds.h); } +bool Graphics::drawRescaledImage(Image *image, int srcX, int srcY, + int dstX, int dstY, + int width, int height, + int desiredWidth, int desiredHeight, + bool useColor) +{ + // Check that preconditions for blitting are met. + if (!mScreen || !image) return false; + if (!image->mImage) return false; + + Image *tmpImage = image->SDLgetScaledImage(desiredWidth, desiredHeight); + bool returnValue = false; + if (!tmpImage) return false; + if (!tmpImage->mImage) return false; + + dstX += mClipStack.top().xOffset; + dstY += mClipStack.top().yOffset; + + srcX += image->mBounds.x; + srcY += image->mBounds.y; + + SDL_Rect dstRect; + SDL_Rect srcRect; + dstRect.x = dstX; dstRect.y = dstY; + srcRect.x = srcX; srcRect.y = srcY; + srcRect.w = width; + srcRect.h = height; + + returnValue = !(SDL_BlitSurface(tmpImage->mImage, &srcRect, mScreen, &dstRect) < 0); + + delete tmpImage; + + return returnValue; +} + bool Graphics::drawImage(Image *image, int srcX, int srcY, int dstX, int dstY, int width, int height, bool) { // Check that preconditions for blitting are met. - if (!mScreen || !image || !image->mImage) return false; + if (!mScreen || !image) return false; + if (!image->mImage) return false; dstX += mClipStack.top().xOffset; dstY += mClipStack.top().yOffset; @@ -154,7 +190,8 @@ void Graphics::drawImage(gcn::Image const *image, int srcX, int srcY, void Graphics::drawImagePattern(Image *image, int x, int y, int w, int h) { // Check that preconditions for blitting are met. - if (!mScreen || !image || !image->mImage) return; + if (!mScreen || !image) return; + if (!image->mImage) return; const int iw = image->getWidth(); const int ih = image->getHeight(); |