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

Unified Diff: ui/file_manager/gallery/js/image_editor/image_view.js

Issue 1370683003: Gallery: resize image data to overlay canvas size. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ui/file_manager/gallery/js/image_editor/image_adjust.js ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/file_manager/gallery/js/image_editor/image_view.js
diff --git a/ui/file_manager/gallery/js/image_editor/image_view.js b/ui/file_manager/gallery/js/image_editor/image_view.js
index cd8fb1ccbc15b89f338556152d7a7ef269b48ee0..340b9eaa70d90c5739fc1882987896f66b6d5996 100644
--- a/ui/file_manager/gallery/js/image_editor/image_view.js
+++ b/ui/file_manager/gallery/js/image_editor/image_view.js
@@ -307,6 +307,7 @@ ImageView.prototype.setupDeviceBuffer = function(canvas) {
// Set the canvas position and size in device pixels.
var deviceRect = this.viewport_.getDeviceBounds();
var needRepaint = false;
+
yawano 2015/09/25 11:07:59 This blank line is added for readability.
yawano 2015/09/25 11:33:03 This kind of thing should be done with separate CL
if (canvas.width !== deviceRect.width) {
canvas.width = deviceRect.width;
needRepaint = true;
@@ -320,11 +321,29 @@ ImageView.prototype.setupDeviceBuffer = function(canvas) {
};
/**
- * @return {!ImageData} A new ImageData object with a copy of the content.
+ * Gets screen image data with specified size.
+ * @param {number} width
+ * @param {number} height
+ * @return {!ImageData} A new ImageData object.
*/
-ImageView.prototype.copyScreenImageData = function() {
- return this.screenImage_.getContext('2d').getImageData(
- 0, 0, this.screenImage_.width, this.screenImage_.height);
+ImageView.prototype.getScreenImageDataWith = function(width, height) {
+ // If specified size is same with current screen image size, just return it.
+ if (width === this.screenImage_.width &&
+ height === this.screenImage_.height) {
+ return this.screenImage_.getContext('2d').getImageData(
+ 0, 0, this.screenImage_.width, this.screenImage_.height);
+ }
+
+ // Resize if these sizes are different.
+ var resizeCanvas = document.createElement('canvas');
+ resizeCanvas.width = width;
+ resizeCanvas.height = height;
+
+ var context = resizeCanvas.getContext('2d');
+ context.drawImage(this.screenImage_,
+ 0, 0, this.screenImage_.width, this.screenImage_.height,
+ 0, 0, resizeCanvas.width, resizeCanvas.height);
+ return context.getImageData(0, 0, resizeCanvas.width, resizeCanvas.height);
};
/**
« no previous file with comments | « ui/file_manager/gallery/js/image_editor/image_adjust.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698