1
0
Fork 0
mirror of https://github.com/mozilla/pdf.js.git synced 2025-04-22 16:18:08 +02:00

Update the current stride before composing when decoding a text region

Fixes #17871.

We do something similar to:
https://source.chromium.org/chromium/chromium/src/+/main:third_party/pdfium/core/fxcodec/jbig2/JBig2_TrdProc.cpp;l=373-379;drc=24c6be6924df3ff585bb63f6aed4e2c81e791fb2
This commit is contained in:
Calixte Denizet 2024-04-03 11:18:41 +02:00
parent d8331e3100
commit 3f2f98336e
5 changed files with 31 additions and 3 deletions

View file

@ -865,6 +865,20 @@ function decodeTextRegion(
decodingContext
);
}
let increment = 0;
if (!transposed) {
if (referenceCorner > 1) {
currentS += symbolWidth - 1;
} else {
increment = symbolWidth - 1;
}
} else if (!(referenceCorner & 1)) {
currentS += symbolHeight - 1;
} else {
increment = symbolHeight - 1;
}
const offsetT = t - (referenceCorner & 1 ? 0 : symbolHeight - 1);
const offsetS = currentS - (referenceCorner & 2 ? symbolWidth - 1 : 0);
let s2, t2, symbolRow;
@ -896,7 +910,6 @@ function decodeTextRegion(
);
}
}
currentS += symbolHeight - 1;
} else {
for (t2 = 0; t2 < symbolHeight; t2++) {
row = bitmap[offsetT + t2];
@ -921,7 +934,6 @@ function decodeTextRegion(
);
}
}
currentS += symbolWidth - 1;
}
i++;
const deltaS = huffman
@ -930,7 +942,7 @@ function decodeTextRegion(
if (deltaS === null) {
break; // OOB
}
currentS += deltaS + dsOffset;
currentS += increment + deltaS + dsOffset;
} while (true);
}
return bitmap;