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

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: Make a change in GalleryJsTest.SlideModeTest 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 * Resize 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.Resize = function(inputWidth, inputHeight) {
463 Command.call(this, 'resize(x:' + inputWidth + ',y:' + inputHeight + ')');
464 this.newWidth_ = inputWidth;
465 this.newHeight_ = inputHeight;
466 };
467
468 Command.Resize.prototype = {__proto__: Command.prototype};
469
470 /** @override */
471 Command.Resize.prototype.execute = function(
472 document, srcImage, callback, uiContext) {
473 var result = this.createCanvas_(
474 document, srcImage, this.newWidth_, this.newHeight_);
475
476 var scaleX = this.newWidth_ / srcImage.width;
477 var scaleY = this.newHeight_ / srcImage.height;
478 ImageUtil.drawImageTransformed(result, srcImage, scaleX, scaleY, 0);
479
480 if(uiContext.imageView)
481 uiContext.imageView.replace(result);
482 callback(result);
483 };
OLDNEW
« no previous file with comments | « ui/file_manager/gallery/js/gallery_scripts.js ('k') | ui/file_manager/gallery/js/image_editor/image_editor.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698