Created
June 12, 2014 15:06
-
-
Save CodingFabian/0a7c539c081c96538e6a to your computer and use it in GitHub Desktop.
thubnail resize diff
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/web/thumbnail_view.js b/web/thumbnail_view.js | |
index 90d4e89..9766530 100644 | |
--- a/web/thumbnail_view.js | |
+++ b/web/thumbnail_view.js | |
@@ -97,12 +97,12 @@ var ThumbnailView = function thumbnailView(container, id, defaultViewport) { | |
this.resume = null; | |
}; | |
- this.getPageDrawContext = function thumbnailViewGetPageDrawContext() { | |
+ this.getPageDrawContext = function thumbnailViewGetPageDrawContext(w, h) { | |
var canvas = document.createElement('canvas'); | |
canvas.id = 'thumbnail' + id; | |
- canvas.width = this.canvasWidth; | |
- canvas.height = this.canvasHeight; | |
+ canvas.width = w || this.canvasWidth; | |
+ canvas.height = h || this.canvasHeight; | |
canvas.className = 'thumbnailImage'; | |
canvas.setAttribute('aria-label', mozL10n.get('thumb_page_canvas', | |
{page: id}, 'Thumbnail of Page {{page}}')); | |
@@ -187,10 +187,10 @@ var ThumbnailView = function thumbnailView(container, id, defaultViewport) { | |
return; | |
} | |
this.renderingState = RenderingStates.FINISHED; | |
- var ctx = this.getPageDrawContext(); | |
- ctx.drawImage(img, 0, 0, img.width, img.height, | |
- 0, 0, ctx.canvas.width, ctx.canvas.height); | |
- | |
+ var ctx = this.getPageDrawContext(img.width, img.height); | |
+ ctx.drawImage(img, 0, 0); | |
+ ctx.canvas.style.width = this.canvasWidth + "px"; | |
+ ctx.canvas.style.height = this.canvasHeight + "px"; | |
this.hasImage = true; | |
}; | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment