Fix size of maskCanvas to draw image masks correctly
Use existing helper to calculate the Box Co-authored-by: Jonas Jenwald <jonas.jenwald@gmail.com> Ensure that there are non-zero Co-authored-by: Jonas Jenwald <jonas.jenwald@gmail.com> Add a reference test for #17147
This commit is contained in:
parent
36c3c0a4c1
commit
0eacd5c107
@ -1313,11 +1313,12 @@ class CanvasGraphics {
|
||||
0,
|
||||
]);
|
||||
maskToCanvas = Util.transform(maskToCanvas, [1, 0, 0, 1, 0, -height]);
|
||||
const cord1 = Util.applyTransform([0, 0], maskToCanvas);
|
||||
const cord2 = Util.applyTransform([width, height], maskToCanvas);
|
||||
const rect = Util.normalizeRect([cord1[0], cord1[1], cord2[0], cord2[1]]);
|
||||
const drawnWidth = Math.round(rect[2] - rect[0]) || 1;
|
||||
const drawnHeight = Math.round(rect[3] - rect[1]) || 1;
|
||||
const [minX, minY, maxX, maxY] = Util.getAxialAlignedBoundingBox(
|
||||
[0, 0, width, height],
|
||||
maskToCanvas
|
||||
);
|
||||
const drawnWidth = Math.round(maxX - minX) || 1;
|
||||
const drawnHeight = Math.round(maxY - minY) || 1;
|
||||
const fillCanvas = this.cachedCanvases.getCanvas(
|
||||
"fillCanvas",
|
||||
drawnWidth,
|
||||
@ -1329,8 +1330,8 @@ class CanvasGraphics {
|
||||
// If objToCanvas is [a,b,c,d,e,f] then:
|
||||
// - offsetX = min(a, c) + e
|
||||
// - offsetY = min(b, d) + f
|
||||
const offsetX = Math.min(cord1[0], cord2[0]);
|
||||
const offsetY = Math.min(cord1[1], cord2[1]);
|
||||
const offsetX = minX;
|
||||
const offsetY = minY;
|
||||
fillCtx.translate(-offsetX, -offsetY);
|
||||
fillCtx.transform(...maskToCanvas);
|
||||
|
||||
|
1
test/pdfs/.gitignore
vendored
1
test/pdfs/.gitignore
vendored
@ -332,6 +332,7 @@
|
||||
!issue5470.pdf
|
||||
!issue5501.pdf
|
||||
!issue5599.pdf
|
||||
!issue17147.pdf
|
||||
!issue5747.pdf
|
||||
!issue6099.pdf
|
||||
!issue6336.pdf
|
||||
|
BIN
test/pdfs/issue17147.pdf
Normal file
BIN
test/pdfs/issue17147.pdf
Normal file
Binary file not shown.
@ -32,6 +32,12 @@
|
||||
"type": "eq",
|
||||
"renderTaskOnContinue": true
|
||||
},
|
||||
{ "id": "issue17147",
|
||||
"file": "pdfs/issue17147.pdf",
|
||||
"md5": "47012ba13ee819ec0af278c9d943f010",
|
||||
"rounds": 1,
|
||||
"type": "eq"
|
||||
},
|
||||
{ "id": "issue13130",
|
||||
"file": "pdfs/issue13130.pdf",
|
||||
"md5": "318518299132fe3b52252ca43a69a23e",
|
||||
|
Loading…
Reference in New Issue
Block a user