1
0
Fork 0
mirror of https://github.com/mozilla/pdf.js.git synced 2025-04-25 17:48:07 +02:00

Refactor searching for the SOI marker of inline JPEG image streams

This commit is contained in:
Jonas Jenwald 2014-11-20 21:39:35 +01:00
parent dc5961d969
commit 3e1b5216ac
2 changed files with 9 additions and 18 deletions

View file

@ -857,8 +857,15 @@ var PredictorStream = (function PredictorStreamClosure() {
*/
var JpegStream = (function JpegStreamClosure() {
function JpegStream(stream, maybeLength, dict, xref) {
// TODO: per poppler, some images may have 'junk' before that
// need to be removed
// Some images may contain 'junk' before the SOI (start-of-image) marker.
// Note: this seems to mainly affect inline images.
var ch;
while ((ch = stream.getByte()) !== -1) {
if (ch === 0xFF) { // Find the first byte of the SOI marker (0xFFD8).
stream.skip(-1); // Reset the stream position to the SOI.
break;
}
}
this.stream = stream;
this.maybeLength = maybeLength;
this.dict = dict;