Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update JpxImage.parseImageProperties to support TypedArray data in IMAGE_DECODERS builds #17977

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions src/core/jpx.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@

import { BaseException } from "../shared/util.js";
import OpenJPEG from "../../external/openjpeg/openjpeg.js";
import { Stream } from "./stream.js";

class JpxError extends BaseException {
constructor(msg) {
Expand All @@ -39,6 +40,13 @@ class JpxImage {
}

static parseImageProperties(stream) {
if (typeof PDFJSDev !== "undefined" && PDFJSDev.test("IMAGE_DECODERS")) {
if (stream instanceof ArrayBuffer || ArrayBuffer.isView(stream)) {
stream = new Stream(stream);
} else {
throw new JpxError("Invalid data format, must be a TypedArray.");
}
}
// No need to use OpenJPEG here since we're only getting very basic
// information which are located in the first bytes of the file.
let newByte = stream.getByte();
Expand Down