Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(783)

Side by Side Diff: ui/file_manager/gallery/js/image_editor/commands.js

Issue 2299493002: Add an ability for resize in gallery. (Closed)
Patch Set: Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 /** 5 /**
6 * Command queue is the only way to modify images. 6 * Command queue is the only way to modify images.
7 * Supports undo/redo. 7 * Supports undo/redo.
8 * Command execution is asynchronous (callback-based). 8 * Command execution is asynchronous (callback-based).
9 * 9 *
10 * @param {!Document} document Document to create canvases in. 10 * @param {!Document} document Document to create canvases in.
(...skipping 432 matching lines...) Expand 10 before | Expand all | Expand 10 after
443 443
444 function onProgressInvisible(updatedRow, rowCount) { 444 function onProgressInvisible(updatedRow, rowCount) {
445 if (updatedRow == rowCount) { 445 if (updatedRow == rowCount) {
446 callback(result); 446 callback(result);
447 } 447 }
448 } 448 }
449 449
450 filter.applyByStrips(result, srcImage, this.filter_, 450 filter.applyByStrips(result, srcImage, this.filter_,
451 uiContext.imageView ? onProgressVisible : onProgressInvisible); 451 uiContext.imageView ? onProgressVisible : onProgressInvisible);
452 }; 452 };
453
454 /**
455 * ImagResize Command
456 * @param {number} inputWidth width user input
457 * @param {number} inputHeight height user input
458 * @constructor
459 * @extends {Command}
460 * @struct
461 */
462 Command.ImageResize = function(inputWidth, inputHeight) {
fukino 2016/08/31 05:10:24 Command.Resize sounds more consistent with Command
harukam 2016/09/05 10:37:00 Agree. Thanks! done.
463 Command.call(this, 'imageResize(x:' + inputWidth + ',y:' + inputHeight + ')');
464 this.newWidth_ = inputWidth;
465 this.newHeight_ = inputHeight;
466 };
467
468 Command.ImageResize.prototype = {__proto__: Command.prototype};
469
470 /** @override */
471 Command.ImageResize.prototype.execute = function(
472 document, srcImage, callback, uiContext) {
473 var result = this.createCanvas_(
474 document,
fukino 2016/08/31 05:10:24 4 spaces indent.
harukam 2016/09/05 10:37:00 Done.
475 srcImage,
fukino 2016/08/31 05:10:24 All arguments can be fit in one line.
harukam 2016/09/05 10:37:00 Done.
476 this.newWidth_,
477 this.newHeight_);
478
479 var scaleX = this.newWidth_ / srcImage.width;
480 var scaleY = this.newHeight_ / srcImage.height;
481 ImageUtil.drawImageTransformed(result, srcImage, scaleX, scaleY, 0);
482
483 if(uiContext.imageView)
484 uiContext.imageView.replace(result);
485 callback(result);
486 };
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698