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

Unified 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, 4 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 side-by-side diff with in-line comments
Download patch
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..182a7142c59d556c1d69a447806df2bd398dad68 100644
--- a/ui/file_manager/gallery/js/image_editor/commands.js
+++ b/ui/file_manager/gallery/js/image_editor/commands.js
@@ -450,3 +450,37 @@ Command.Filter.prototype.execute = function(
filter.applyByStrips(result, srcImage, this.filter_,
uiContext.imageView ? onProgressVisible : onProgressInvisible);
};
+
+/**
+ * ImagResize Command
+ * @param {number} inputWidth width user input
+ * @param {number} inputHeight height user input
+ * @constructor
+ * @extends {Command}
+ * @struct
+ */
+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.
+ Command.call(this, 'imageResize(x:' + inputWidth + ',y:' + inputHeight + ')');
+ this.newWidth_ = inputWidth;
+ this.newHeight_ = inputHeight;
+};
+
+Command.ImageResize.prototype = {__proto__: Command.prototype};
+
+/** @override */
+Command.ImageResize.prototype.execute = function(
+ document, srcImage, callback, uiContext) {
+ var result = this.createCanvas_(
+ document,
fukino 2016/08/31 05:10:24 4 spaces indent.
harukam 2016/09/05 10:37:00 Done.
+ srcImage,
fukino 2016/08/31 05:10:24 All arguments can be fit in one line.
harukam 2016/09/05 10:37:00 Done.
+ 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);
+};

Powered by Google App Engine
This is Rietveld 408576698