diff options
author | Tobia Tesan | 2013-06-27 16:47:33 +0200 |
---|---|---|
committer | Tobia Tesan | 2013-08-01 00:02:47 +0200 |
commit | 58e096de97d7b8a0c09f5ac0bd6ff65853669a80 (patch) | |
tree | c66a65229911187e64d405928bcbec4a04ef7579 /engines/wintermute/graphics | |
parent | cced42a765cff0ad89490ebc0e70a7e00b8a2f4f (diff) | |
download | scummvm-rg350-58e096de97d7b8a0c09f5ac0bd6ff65853669a80.tar.gz scummvm-rg350-58e096de97d7b8a0c09f5ac0bd6ff65853669a80.tar.bz2 scummvm-rg350-58e096de97d7b8a0c09f5ac0bd6ff65853669a80.zip |
WINTERMUTE: Add rotation
Add actual rotation code, make ticket-system transformStruct-aware
Diffstat (limited to 'engines/wintermute/graphics')
-rw-r--r-- | engines/wintermute/graphics/transparent_surface.cpp | 41 | ||||
-rw-r--r-- | engines/wintermute/graphics/transparent_surface.h | 3 |
2 files changed, 43 insertions, 1 deletions
diff --git a/engines/wintermute/graphics/transparent_surface.cpp b/engines/wintermute/graphics/transparent_surface.cpp index f68259fb94..87cb143dac 100644 --- a/engines/wintermute/graphics/transparent_surface.cpp +++ b/engines/wintermute/graphics/transparent_surface.cpp @@ -23,9 +23,11 @@ #include "common/endian.h" #include "common/util.h" #include "common/rect.h" +#include "common/math.h" #include "common/textconsole.h" #include "graphics/primitives.h" #include "engines/wintermute/graphics/transparent_surface.h" +#include "engines/wintermute/graphics/transform_tools.h" namespace Wintermute { @@ -494,6 +496,45 @@ Common::Rect TransparentSurface::blit(Graphics::Surface &target, int posX, int p return retSize; } +TransparentSurface *TransparentSurface::rotate(Common::Rect aSrcRect, TransformStruct transform) const { + Point32 newHotspot; + Rect32 rect = TransformTools::newRect(Rect32 (aSrcRect), transform, &newHotspot); + Common::Rect srcRect(0, 0, (int16)(aSrcRect.right - aSrcRect.left), (int16)(aSrcRect.bottom - aSrcRect.top)); + Common::Rect dstRect(0, 0, (int16)(rect.right - rect.left), (int16)(rect.bottom - rect.top)); + + TransparentSurface *target = new TransparentSurface(); + assert(format.bytesPerPixel == 4); + + int dstW = dstRect.width(); + int dstH = dstRect.height(); + + target->create((uint16)dstW, (uint16)dstH, this->format); + + uint32 invAngle = (360 - transform._angle) % 360; + float invCos = cos(invAngle * M_PI / 180.0); + float invSin = sin(invAngle * M_PI / 180.0); + + for (int y = 0; y < dstH; y++) { + for (int x = 0; x < dstW; x++) { + int x1 = x - newHotspot.x; + int y1 = y - newHotspot.y; + + float targX = ((x1 * invCos - y1 * invSin)) * 100.0 / transform._zoom.x + srcRect.left; + float targY = ((x1 * invSin + y1 * invCos)) * 100.0 / transform._zoom.y + srcRect.top; + + targX += transform._hotspot.x; + targY += transform._hotspot.y; + + if (FAST_TRANSFORM) { + bilinearCopy(targX, targY, x, y, srcRect, dstRect, this, target); + } else { + bilinearCopy(targX, targY, x, y, srcRect, dstRect, this, target); + } + } + } + return target; +} + TransparentSurface *TransparentSurface::scale(uint16 newWidth, uint16 newHeight) const { Common::Rect srcRect(0, 0, (int16)w, (int16)h); Common::Rect dstRect(0, 0, (int16)newWidth, (int16)newHeight); diff --git a/engines/wintermute/graphics/transparent_surface.h b/engines/wintermute/graphics/transparent_surface.h index 0f48054d7c..b81dbe86e9 100644 --- a/engines/wintermute/graphics/transparent_surface.h +++ b/engines/wintermute/graphics/transparent_surface.h @@ -23,7 +23,7 @@ #define GRAPHICS_TRANSPARENTSURFACE_H #include "graphics/surface.h" - +#include "engines/wintermute/graphics/transform_struct.h" #define FAST_TRANSFORM 0 @@ -111,6 +111,7 @@ struct TransparentSurface : public Graphics::Surface { void applyColorKey(uint8 r, uint8 g, uint8 b, bool overwriteAlpha = false); TransparentSurface *scale (uint16 newWidth, uint16 newHeight) const; + TransparentSurface *rotate(Common::Rect srcRect, TransformStruct transform) const; static byte *_lookup; static void destroyLookup(); private: |