Chromium Code Reviews| Index: ui/file_manager/gallery/js/image_editor/commands.js |
| diff --git a/ui/file_manager/gallery/js/image_editor/commands.js b/ui/file_manager/gallery/js/image_editor/commands.js |
| index a63801b2c37b8a207a0a907ecd7e6c34583ecfe3..9f7e6038ce9571290ef2e0685ffbc7b9a472a625 100644 |
| --- a/ui/file_manager/gallery/js/image_editor/commands.js |
| +++ b/ui/file_manager/gallery/js/image_editor/commands.js |
| @@ -450,3 +450,34 @@ Command.Filter.prototype.execute = function( |
| filter.applyByStrips(result, srcImage, this.filter_, |
| uiContext.imageView ? onProgressVisible : onProgressInvisible); |
| }; |
| + |
| +/** |
| + * Resize Command |
| + * @param {number} inputWidth width user input |
| + * @param {number} inputHeight height user input |
| + * @constructor |
| + * @extends {Command} |
| + * @struct |
| + */ |
| +Command.Resize = function(inputWidth, inputHeight) { |
| + Command.call(this, 'resize(x:' + inputWidth + ',y:' + inputHeight + ')'); |
| + this.newWidth_ = inputWidth; |
| + this.newHeight_ = inputHeight; |
| +}; |
| + |
| +Command.Resize.prototype = {__proto__: Command.prototype}; |
| + |
| +/** @override */ |
| +Command.Resize.prototype.execute = function( |
| + document, srcImage, callback, uiContext) { |
|
fukino
2016/09/16 02:24:49
4 space indent.
harukam
2016/09/16 05:21:58
Done.
|
| + var result = this.createCanvas_( |
| + document, srcImage, this.newWidth_, this.newHeight_); |
| + |
| + var scaleX = this.newWidth_ / srcImage.width; |
| + var scaleY = this.newHeight_ / srcImage.height; |
| + ImageUtil.drawImageTransformed(result, srcImage, scaleX, scaleY, 0); |
| + |
| + if(uiContext.imageView) |
| + uiContext.imageView.replace(result); |
| + callback(result); |
| +}; |