Roo/dialog/UploadCropbox.js
[roojs1] / Roo / dialog / UploadCropbox.js
index 5776e90..6271d21 100644 (file)
@@ -581,8 +581,8 @@ Roo.extend(Roo.dialog.UploadCropbox, Roo.Component,  {
         var height = Math.ceil(this.imageEl.OriginHeight * this.getScaleLevel() / minScale);
 
         console.log("ZOOM");
-        console.log("WIDTH: " + width);
-        console.log("HEIGHT: " + height);
+        console.log("WIDTH: " + (this.thumbEl.getWidth() / this.getScaleLevel()));
+        console.log("HEIGHT: " + (this.thumbEl.getHeight() / this.getScaleLevel()));
 
 
         var maxWidth = this.imageEl.OriginWidth;
@@ -873,7 +873,14 @@ Roo.extend(Roo.dialog.UploadCropbox, Roo.Component,  {
         
         var context = canvas.getContext("2d");
 
-        console.log("GETSCALELEVLE: " + this.getScaleLevel());
+        canvas.width = this.thumbEl.getWidth() / this.getScaleLevel();
+        
+        canvas.height = this.thumbEl.getHeight() / this.getScaleLevel();
+
+        console.log("CANVAS WIDTH: " + canvas.width);
+        console.log("CANVAS HEIGHT: " + canvas.height);
+
+        console.log("SCALELEVLE: " + scaleLevel);
 
         switch (this.rotate) {
             case 0 :
@@ -883,13 +890,6 @@ Roo.extend(Roo.dialog.UploadCropbox, Roo.Component,  {
 
                 console.log("WIDTH: " + width);
                 console.log("HEIGHT: " + height);
-
-                canvas.width = width;
-        
-                canvas.height = height;
-        
-                console.log("CANVAS WIDTH: " + canvas.width);
-                console.log("CANVAS HEIGHT: " + canvas.height);
                 
                 var x = (this.thumbEl.getLeft(true) > this.previewEl.getLeft(true)) ? 0 : ((this.previewEl.getLeft(true) - this.thumbEl.getLeft(true)) / this.getScaleLevel());
                 var y = (this.thumbEl.getTop(true) > this.previewEl.getTop(true)) ? 0 : ((this.previewEl.getTop(true) - this.thumbEl.getTop(true)) / this.getScaleLevel());
@@ -925,8 +925,8 @@ Roo.extend(Roo.dialog.UploadCropbox, Roo.Component,  {
                 
                 // context.scale(scale, scale);
                 
-                var sx = Math.min(this.canvasEl.width - this.thumbEl.getWidth(), this.thumbEl.getLeft(true) - this.previewEl.getLeft(true));
-                var sy = Math.min(this.canvasEl.height - this.thumbEl.getHeight(), this.thumbEl.getTop(true) - this.previewEl.getTop(true));
+                var sx = this.thumbEl.getLeft(true) - this.previewEl.getLeft(true);
+                var sy = this.thumbEl.getTop(true) - this.previewEl.getTop(true);
 
                 console.log("sx: " + sx);
                 console.log("sy: " + sy);
@@ -934,9 +934,7 @@ Roo.extend(Roo.dialog.UploadCropbox, Roo.Component,  {
                 sx = sx < 0 ? 0 : (sx / this.getScaleLevel());
                 sy = sy < 0 ? 0 : (sy / this.getScaleLevel());
 
-                // context.drawImage(imageCanvas, sx, sy, width, height, x, y, width, height);
-
-                context.drawImage(imageCanvas, 0, 0);
+                context.drawImage(imageCanvas, sx, sy, width, height, x, y, width, height);
                 
                 break;
             case 90 :