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

Side by Side 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: Remove blank line. Created 5 years, 2 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
« no previous file with comments | « ui/file_manager/gallery/js/image_editor/image_adjust.js ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 * The overlay displaying the image. 6 * The overlay displaying the image.
7 * 7 *
8 * @param {!HTMLElement} container The container element. 8 * @param {!HTMLElement} container The container element.
9 * @param {!Viewport} viewport The viewport. 9 * @param {!Viewport} viewport The viewport.
10 * @param {!MetadataModel} metadataModel 10 * @param {!MetadataModel} metadataModel
(...skipping 302 matching lines...) Expand 10 before | Expand all | Expand 10 after
313 } 313 }
314 if (canvas.height !== deviceRect.height) { 314 if (canvas.height !== deviceRect.height) {
315 canvas.height = deviceRect.height; 315 canvas.height = deviceRect.height;
316 needRepaint = true; 316 needRepaint = true;
317 } 317 }
318 this.setTransform_(canvas, this.viewport_); 318 this.setTransform_(canvas, this.viewport_);
319 return needRepaint; 319 return needRepaint;
320 }; 320 };
321 321
322 /** 322 /**
323 * @return {!ImageData} A new ImageData object with a copy of the content. 323 * Gets screen image data with specified size.
324 * @param {number} width
325 * @param {number} height
326 * @return {!ImageData} A new ImageData object.
324 */ 327 */
325 ImageView.prototype.copyScreenImageData = function() { 328 ImageView.prototype.getScreenImageDataWith = function(width, height) {
326 return this.screenImage_.getContext('2d').getImageData( 329 // If specified size is same with current screen image size, just return it.
327 0, 0, this.screenImage_.width, this.screenImage_.height); 330 if (width === this.screenImage_.width &&
331 height === this.screenImage_.height) {
332 return this.screenImage_.getContext('2d').getImageData(
333 0, 0, this.screenImage_.width, this.screenImage_.height);
334 }
335
336 // Resize if these sizes are different.
337 var resizeCanvas = document.createElement('canvas');
338 resizeCanvas.width = width;
339 resizeCanvas.height = height;
340
341 var context = resizeCanvas.getContext('2d');
342 context.drawImage(this.screenImage_,
343 0, 0, this.screenImage_.width, this.screenImage_.height,
344 0, 0, resizeCanvas.width, resizeCanvas.height);
345 return context.getImageData(0, 0, resizeCanvas.width, resizeCanvas.height);
328 }; 346 };
329 347
330 /** 348 /**
331 * @return {boolean} True if the image is currently being loaded. 349 * @return {boolean} True if the image is currently being loaded.
332 */ 350 */
333 ImageView.prototype.isLoading = function() { 351 ImageView.prototype.isLoading = function() {
334 return this.imageLoader_.isBusy(); 352 return this.imageLoader_.isBusy();
335 }; 353 };
336 354
337 /** 355 /**
(...skipping 657 matching lines...) Expand 10 before | Expand all | Expand 10 after
995 1013
996 ImageView.Effect.Rotate.prototype = { __proto__: ImageView.Effect.prototype }; 1014 ImageView.Effect.Rotate.prototype = { __proto__: ImageView.Effect.prototype };
997 1015
998 /** 1016 /**
999 * @override 1017 * @override
1000 */ 1018 */
1001 ImageView.Effect.Rotate.prototype.transform = function(element, viewport) { 1019 ImageView.Effect.Rotate.prototype.transform = function(element, viewport) {
1002 return viewport.getRotatingTransformation( 1020 return viewport.getRotatingTransformation(
1003 element.width, element.height, this.orientation_ ? -1 : 1); 1021 element.width, element.height, this.orientation_ ? -1 : 1);
1004 }; 1022 };
OLDNEW
« 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