Roo/dialog/UploadCropbox.js
[roojs1] / Roo / dialog / UploadCropbox.js
index d25eb3c..741766c 100644 (file)
@@ -873,27 +873,20 @@ Roo.extend(Roo.dialog.UploadCropbox, Roo.Component,  {
         
         var context = canvas.getContext("2d");
 
-        var scaleLevel = this.getScaleLevel();
-
-        if(this.thumbEl.getWidth() / this.getScaleLevel() > 1200) {
-            scaleLevel = this.thumbEl.getWidth() / 1200;
-        }
-
-        canvas.width = this.thumbEl.getWidth() / scaleLevel;
+        canvas.width = this.thumbEl.getWidth() / this.getScaleLevel();
         
-        canvas.height = this.thumbEl.getHeight() / scaleLevel;
-
+        canvas.height = this.thumbEl.getHeight() / this.getScaleLevel();
 
         console.log("CANVAS WIDTH: " + canvas.width);
         console.log("CANVAS HEIGHT: " + canvas.height);
 
-        console.log("SCALELEVLE: " + scaleLevel);
+        console.log("SCALELEVLE: " + this.getScaleLevel());
 
         switch (this.rotate) {
             case 0 :
                 
-                var width = (this.thumbEl.getWidth() / this.getScaleLevel() > this.imageEl.OriginWidth) ? this.imageEl.OriginWidth : (this.thumbEl.getWidth() / scaleLevel);
-                var height = (this.thumbEl.getHeight() / this.getScaleLevel() > this.imageEl.OriginHeight) ? this.imageEl.OriginHeight : (this.thumbEl.getHeight() / scaleLevel);
+                var width = (this.thumbEl.getWidth() / this.getScaleLevel() > this.imageEl.OriginWidth) ? this.imageEl.OriginWidth : (this.thumbEl.getWidth() / this.getScaleLevel());
+                var height = (this.thumbEl.getHeight() / this.getScaleLevel() > this.imageEl.OriginHeight) ? this.imageEl.OriginHeight : (this.thumbEl.getHeight() / this.getScaleLevel());
 
                 console.log("WIDTH: " + width);
                 console.log("HEIGHT: " + height);
@@ -941,6 +934,11 @@ Roo.extend(Roo.dialog.UploadCropbox, Roo.Component,  {
                 sx = sx < 0 ? 0 : (sx / this.getScaleLevel());
                 sy = sy < 0 ? 0 : (sy / this.getScaleLevel());
 
+                if(canvas.width > 1200) {
+                    canvas.height = 1200 * canvas.height / canvas.width;
+                    canvas.width = 1200;
+                }
+
                 context.drawImage(imageCanvas, sx, sy, width, height, x, y, width, height);
                 
                 break;