aboutsummaryrefslogtreecommitdiff
path: root/engines/wintermute/graphics/transparent_surface.cpp
diff options
context:
space:
mode:
authorTobia Tesan2013-06-27 16:47:33 +0200
committerTobia Tesan2013-08-01 00:02:47 +0200
commit58e096de97d7b8a0c09f5ac0bd6ff65853669a80 (patch)
treec66a65229911187e64d405928bcbec4a04ef7579 /engines/wintermute/graphics/transparent_surface.cpp
parentcced42a765cff0ad89490ebc0e70a7e00b8a2f4f (diff)
downloadscummvm-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/transparent_surface.cpp')
-rw-r--r--engines/wintermute/graphics/transparent_surface.cpp41
1 files changed, 41 insertions, 0 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);