mirror of
https://github.com/mozilla/pdf.js.git
synced 2026-08-03 12:57:20 +02:00
Compare commits
6 Commits
92d7b6d09f
...
6243afa85e
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
6243afa85e | ||
|
|
2f1497c9c4 | ||
|
|
afb14bdc0b | ||
|
|
1fb6edc713 | ||
|
|
e37236e9af | ||
|
|
e5e0856f99 |
@ -480,7 +480,6 @@ pdfjs-editor-new-alt-text-error-close-button = Close
|
|||||||
# Variables:
|
# Variables:
|
||||||
# $totalSize (Number) - the total size (in MB) of the AI model.
|
# $totalSize (Number) - the total size (in MB) of the AI model.
|
||||||
# $downloadedSize (Number) - the downloaded size (in MB) of the AI model.
|
# $downloadedSize (Number) - the downloaded size (in MB) of the AI model.
|
||||||
# $percent (Number) - the percentage of the downloaded size.
|
|
||||||
pdfjs-editor-new-alt-text-ai-model-downloading-progress = Downloading alt text AI model ({ $downloadedSize } of { $totalSize } MB)
|
pdfjs-editor-new-alt-text-ai-model-downloading-progress = Downloading alt text AI model ({ $downloadedSize } of { $totalSize } MB)
|
||||||
.aria-valuetext = Downloading alt text AI model ({ $downloadedSize } of { $totalSize } MB)
|
.aria-valuetext = Downloading alt text AI model ({ $downloadedSize } of { $totalSize } MB)
|
||||||
|
|
||||||
|
|||||||
@ -28,6 +28,17 @@ import { shadow, warn } from "../shared/util.js";
|
|||||||
import { ColorSpace } from "./colorspace.js";
|
import { ColorSpace } from "./colorspace.js";
|
||||||
import { QCMS } from "../../external/qcms/qcms_utils.js";
|
import { QCMS } from "../../external/qcms/qcms_utils.js";
|
||||||
|
|
||||||
|
function fetchSync(url) {
|
||||||
|
// Parsing and using color spaces is still synchronous,
|
||||||
|
// so we must load the wasm module synchronously.
|
||||||
|
// TODO: Make the color space stuff asynchronous and use fetch.
|
||||||
|
const xhr = new XMLHttpRequest();
|
||||||
|
xhr.open("GET", url, false);
|
||||||
|
xhr.responseType = "arraybuffer";
|
||||||
|
xhr.send(null);
|
||||||
|
return xhr.response;
|
||||||
|
}
|
||||||
|
|
||||||
class IccColorSpace extends ColorSpace {
|
class IccColorSpace extends ColorSpace {
|
||||||
#transformer;
|
#transformer;
|
||||||
|
|
||||||
@ -132,7 +143,9 @@ class IccColorSpace extends ColorSpace {
|
|||||||
if (this.#useWasm) {
|
if (this.#useWasm) {
|
||||||
if (this.#wasmUrl) {
|
if (this.#wasmUrl) {
|
||||||
try {
|
try {
|
||||||
this._module = QCMS._module = this.#load();
|
this._module = QCMS._module = initSync({
|
||||||
|
module: fetchSync(`${this.#wasmUrl}qcms_bg.wasm`),
|
||||||
|
});
|
||||||
isUsable = !!this._module;
|
isUsable = !!this._module;
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
warn(`ICCBased color space: "${e}".`);
|
warn(`ICCBased color space: "${e}".`);
|
||||||
@ -144,30 +157,16 @@ class IccColorSpace extends ColorSpace {
|
|||||||
|
|
||||||
return shadow(this, "isUsable", isUsable);
|
return shadow(this, "isUsable", isUsable);
|
||||||
}
|
}
|
||||||
|
|
||||||
static #load() {
|
|
||||||
// Parsing and using color spaces is still synchronous,
|
|
||||||
// so we must load the wasm module synchronously.
|
|
||||||
// TODO: Make the color space stuff asynchronous and use fetch.
|
|
||||||
const filename = "qcms_bg.wasm";
|
|
||||||
const xhr = new XMLHttpRequest();
|
|
||||||
xhr.open("GET", `${this.#wasmUrl}${filename}`, false);
|
|
||||||
xhr.responseType = "arraybuffer";
|
|
||||||
xhr.send(null);
|
|
||||||
return initSync({ module: xhr.response });
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
class CmykICCBasedCS extends IccColorSpace {
|
class CmykICCBasedCS extends IccColorSpace {
|
||||||
static #iccUrl;
|
static #iccUrl;
|
||||||
|
|
||||||
constructor() {
|
constructor() {
|
||||||
const filename = "CGATS001Compat-v2-micro.icc";
|
const iccProfile = new Uint8Array(
|
||||||
const xhr = new XMLHttpRequest();
|
fetchSync(`${CmykICCBasedCS.#iccUrl}CGATS001Compat-v2-micro.icc`)
|
||||||
xhr.open("GET", `${CmykICCBasedCS.#iccUrl}${filename}`, false);
|
);
|
||||||
xhr.responseType = "arraybuffer";
|
super(iccProfile, "DeviceCMYK", 4);
|
||||||
xhr.send(null);
|
|
||||||
super(new Uint8Array(xhr.response), "DeviceCMYK", 4);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static setOptions({ iccUrl }) {
|
static setOptions({ iccUrl }) {
|
||||||
|
|||||||
@ -15,6 +15,7 @@
|
|||||||
|
|
||||||
import { assert, BaseException, warn } from "../shared/util.js";
|
import { assert, BaseException, warn } from "../shared/util.js";
|
||||||
import { ColorSpaceUtils } from "./colorspace_utils.js";
|
import { ColorSpaceUtils } from "./colorspace_utils.js";
|
||||||
|
import { DeviceCmykCS } from "./colorspace.js";
|
||||||
import { grayToRGBA } from "../shared/image_utils.js";
|
import { grayToRGBA } from "../shared/image_utils.js";
|
||||||
import { readUint16 } from "./core_utils.js";
|
import { readUint16 } from "./core_utils.js";
|
||||||
|
|
||||||
@ -1349,6 +1350,13 @@ class JpegImage {
|
|||||||
|
|
||||||
_convertCmykToRgba(data) {
|
_convertCmykToRgba(data) {
|
||||||
ColorSpaceUtils.cmyk.getRgbBuffer(data, 0, data.length / 4, data, 0, 8, 1);
|
ColorSpaceUtils.cmyk.getRgbBuffer(data, 0, data.length / 4, data, 0, 8, 1);
|
||||||
|
|
||||||
|
if (ColorSpaceUtils.cmyk instanceof DeviceCmykCS) {
|
||||||
|
// The alpha-component isn't updated by `DeviceCmykCS`, doing it manually.
|
||||||
|
for (let i = 3, ii = data.length; i < ii; i += 4) {
|
||||||
|
data[i] = 255;
|
||||||
|
}
|
||||||
|
}
|
||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -2960,6 +2960,15 @@
|
|||||||
"rounds": 1,
|
"rounds": 1,
|
||||||
"type": "eq"
|
"type": "eq"
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"id": "cmykjpeg_nowasm",
|
||||||
|
"file": "pdfs/cmykjpeg.pdf",
|
||||||
|
"md5": "85d162b48ce98503a382d96f574f70a2",
|
||||||
|
"link": false,
|
||||||
|
"rounds": 1,
|
||||||
|
"type": "eq",
|
||||||
|
"useWasm": false
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"id": "issue4402_reduced",
|
"id": "issue4402_reduced",
|
||||||
"file": "pdfs/issue4402_reduced.pdf",
|
"file": "pdfs/issue4402_reduced.pdf",
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user