Skip to content

Commit

Permalink
Merge pull request #306 from virxkane/bigimg-scaling-limit
Browse files Browse the repository at this point in the history
Android: maximum allowable size of the displayed illustration has been increased
  • Loading branch information
buggins committed Aug 18, 2021
2 parents 03b0789 + e406580 commit 4f5d156
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions android/jni/docview.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2078,7 +2078,8 @@ lString32 DocViewNative::getLink( int x, int y )
return href;
}

#define MAX_IMAGE_BUF_SIZE 1200000
// The maximum allowed value for multiplying the width and height of the image
#define MAX_IMAGE_SIZE_MUL 16777216 // 4096 x 4096 px, for now 4K is enough

// checks whether point belongs to image: if found, returns true, and _currentImage is set to image
bool DocViewNative::checkImage(int x, int y, int bufWidth, int bufHeight, int &dx, int &dy, bool & needRotate)
Expand All @@ -2101,8 +2102,8 @@ bool DocViewNative::checkImage(int x, int y, int bufWidth, int bufHeight, int &d
needRotate = 10 * dx < 8 * dy;
}
int scale = 1;
if (dx * dy > MAX_IMAGE_BUF_SIZE) {
scale = dx * dy / MAX_IMAGE_BUF_SIZE;
if (dx * dy > MAX_IMAGE_SIZE_MUL) {
scale = dx * dy / MAX_IMAGE_SIZE_MUL;
dx /= scale;
dy /= scale;
}
Expand Down

0 comments on commit 4f5d156

Please sign in to comment.