From f1b38c42f973b2065d4b911bf643b3d98cd81108 Mon Sep 17 00:00:00 2001 From: Jermolene Date: Thu, 22 Mar 2018 10:46:57 +0000 Subject: [PATCH] Fix problem with rotate-left bitmap operation Spotted by @BurningTreeC - https://github.com/Jermolene/TiddlyWiki5/commit/c0569849d22f99623423d349c0d96ecae11ffbe8#commitcomment-28211117 --- core/modules/widgets/edit-bitmap.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/core/modules/widgets/edit-bitmap.js b/core/modules/widgets/edit-bitmap.js index c78c9d25a..0a7ecd0ef 100644 --- a/core/modules/widgets/edit-bitmap.js +++ b/core/modules/widgets/edit-bitmap.js @@ -194,8 +194,8 @@ EditBitmapWidget.prototype.changeCanvasSize = function(newWidth,newHeight) { */ EditBitmapWidget.prototype.rotateCanvasLeft = function() { // Get the current size of the image - var origWidth = this.canvasDomNode.width, - origHeight = this.canvasDomNode.height; + var origWidth = this.currCanvas.width, + origHeight = this.currCanvas.height; // Create and size a new canvas var newCanvas = this.document.createElement("canvas"), newWidth = origHeight, @@ -203,9 +203,11 @@ EditBitmapWidget.prototype.rotateCanvasLeft = function() { this.initCanvas(newCanvas,newWidth,newHeight); // Copy the old image var ctx = newCanvas.getContext("2d"); + ctx.save(); ctx.translate(newWidth / 2,newHeight / 2); ctx.rotate(-Math.PI / 2); ctx.drawImage(this.currCanvas,-origWidth / 2,-origHeight / 2); + ctx.restore(); // Set the new canvas as the current one this.currCanvas = newCanvas; // Set the size of the onscreen canvas