[Pkg-javascript-commits] [pdf.js] 59/116: Merge pull request #5610 from fkaelberer/betterThumbnailScaling
David Prévot
taffit at moszumanska.debian.org
Fri Mar 6 16:20:01 UTC 2015
This is an automated email from the git hooks/post-receive script.
taffit pushed a commit to branch master
in repository pdf.js.
commit 6f36df79a1c6461fb00920d8b7c4c467790c16e1
Merge: 801902c 32c32c1
Author: Tim van der Meij <timvandermeij at gmail.com>
Date: Fri Jan 23 20:45:37 2015 +0100
Merge pull request #5610 from fkaelberer/betterThumbnailScaling
Better thumbnail image scaling
web/thumbnail_view.js | 36 +++++++++++++++++++-----------------
1 file changed, 19 insertions(+), 17 deletions(-)
diff --cc web/thumbnail_view.js
index f114542,747db19..7096b0e
--- a/web/thumbnail_view.js
+++ b/web/thumbnail_view.js
@@@ -207,28 -216,28 +207,31 @@@ var ThumbnailView = function thumbnailV
if (this.hasImage || !img) {
return;
}
+ if (!this.pdfPage) {
+ this.setPdfPage(pageView.pdfPage);
+ }
this.renderingState = RenderingStates.FINISHED;
var ctx = this.getPageDrawContext();
-
- var reducedImage = img;
- var reducedWidth = img.width;
- var reducedHeight = img.height;
-
- // drawImage does an awful job of rescaling the image, doing it gradually
- var MAX_SCALE_FACTOR = 2.0;
- if (Math.max(img.width / ctx.canvas.width,
- img.height / ctx.canvas.height) > MAX_SCALE_FACTOR) {
- reducedWidth >>= 1;
- reducedHeight >>= 1;
- reducedImage = getTempCanvas(reducedWidth, reducedHeight);
+ var canvas = ctx.canvas;
+
+ if (img.width <= 2 * canvas.width) {
+ ctx.drawImage(img, 0, 0, img.width, img.height,
+ 0, 0, canvas.width, canvas.height);
+ } else {
+ // drawImage does an awful job of rescaling the image, doing it gradually
+ var MAX_NUM_SCALING_STEPS = 3;
+ var reducedWidth = canvas.width << MAX_NUM_SCALING_STEPS;
+ var reducedHeight = canvas.height << MAX_NUM_SCALING_STEPS;
+ var reducedImage = getTempCanvas(reducedWidth, reducedHeight);
var reducedImageCtx = reducedImage.getContext('2d');
+
+ while (reducedWidth > img.width || reducedHeight > img.height) {
+ reducedWidth >>= 1;
+ reducedHeight >>= 1;
+ }
reducedImageCtx.drawImage(img, 0, 0, img.width, img.height,
0, 0, reducedWidth, reducedHeight);
- while (Math.max(reducedWidth / ctx.canvas.width,
- reducedHeight / ctx.canvas.height) > MAX_SCALE_FACTOR) {
+ while (reducedWidth > 2 * canvas.width) {
reducedImageCtx.drawImage(reducedImage,
0, 0, reducedWidth, reducedHeight,
0, 0, reducedWidth >> 1, reducedHeight >> 1);
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-javascript/pdf.js.git
More information about the Pkg-javascript-commits
mailing list