Pārlūkot izejas kodu

Bug fix: properties lost on image after rotation

Popov72 5 gadi atpakaļ
vecāks
revīzija
f9afb10468
1 mainītis faili ar 10 papildinājumiem un 1 dzēšanām
  1. 10 1
      gui/src/2D/controls/image.ts

+ 10 - 1
gui/src/2D/controls/image.ts

@@ -261,7 +261,7 @@ export class Image extends Control {
     }
 
     /** @hidden */
-    public _rotate90(n: number): Image {
+    public _rotate90(n: number, preserveProperties: boolean = false): Image {
         let canvas = document.createElement('canvas');
 
         const context = canvas.getContext('2d')!;
@@ -279,6 +279,15 @@ export class Image extends Control {
         const dataUrl: string = canvas.toDataURL("image/jpg");
         const rotatedImage = new Image(this.name + "rotated", dataUrl);
 
+        if (preserveProperties) {
+            rotatedImage._stretch = this._stretch;
+            rotatedImage._autoScale = this._autoScale;
+            rotatedImage._cellId = this._cellId;
+            rotatedImage._cellWidth = n % 1 ? this._cellHeight : this._cellWidth;
+            rotatedImage._cellHeight = n % 1 ? this._cellWidth : this._cellHeight;
+        }
+
+
         return rotatedImage;
     }