pdfjs-dist 2.0.489 → 2.2.228
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of pdfjs-dist might be problematic. Click here for more details.
- package/CODE_OF_CONDUCT.md +15 -0
- package/bower.json +1 -1
- package/build/pdf.js +18515 -11402
- package/build/pdf.js.map +1 -1
- package/build/pdf.min.js +1 -1
- package/build/pdf.worker.js +48266 -37137
- package/build/pdf.worker.js.map +1 -1
- package/build/pdf.worker.min.js +1 -1
- package/external/url/url-lib.js +627 -0
- package/image_decoders/pdf.image_decoders.js +11350 -0
- package/image_decoders/pdf.image_decoders.js.map +1 -0
- package/image_decoders/pdf.image_decoders.min.js +1 -0
- package/lib/core/annotation.js +587 -242
- package/lib/core/arithmetic_decoder.js +275 -245
- package/lib/core/bidi.js +65 -6
- package/lib/core/ccitt.js +173 -18
- package/lib/core/ccitt_stream.js +15 -6
- package/lib/core/cff_parser.js +433 -61
- package/lib/core/charsets.js +5 -4
- package/lib/core/chunked_stream.js +400 -152
- package/lib/core/cmap.js +326 -87
- package/lib/core/colorspace.js +874 -594
- package/lib/core/core_utils.js +147 -0
- package/lib/core/crypto.js +290 -45
- package/lib/core/document.js +560 -268
- package/lib/core/encodings.js +19 -10
- package/lib/core/evaluator.js +1005 -360
- package/lib/core/font_renderer.js +331 -97
- package/lib/core/fonts.js +812 -195
- package/lib/core/function.js +284 -71
- package/lib/core/glyphlist.js +4 -3
- package/lib/core/image.js +169 -62
- package/lib/core/image_utils.js +111 -0
- package/lib/core/jbig2.js +479 -66
- package/lib/core/jbig2_stream.js +19 -8
- package/lib/core/jpeg_stream.js +38 -13
- package/lib/core/jpg.js +253 -29
- package/lib/core/jpx.js +396 -6
- package/lib/core/jpx_stream.js +18 -6
- package/lib/core/metrics.js +15 -15
- package/lib/core/murmurhash3.js +56 -34
- package/lib/core/obj.js +1354 -488
- package/lib/core/operator_list.js +144 -31
- package/lib/core/parser.js +539 -191
- package/lib/core/pattern.js +148 -14
- package/lib/core/pdf_manager.js +323 -133
- package/lib/core/primitives.js +111 -24
- package/lib/core/ps_parser.js +134 -45
- package/lib/core/standard_fonts.js +17 -17
- package/lib/core/stream.js +313 -34
- package/lib/core/type1_parser.js +143 -13
- package/lib/core/unicode.js +32 -5
- package/lib/core/worker.js +217 -190
- package/lib/core/worker_stream.js +277 -0
- package/lib/display/annotation_layer.js +450 -133
- package/lib/display/api.js +1597 -784
- package/lib/display/api_compatibility.js +11 -13
- package/lib/display/canvas.js +360 -44
- package/lib/display/content_disposition.js +83 -32
- package/lib/display/display_utils.js +747 -0
- package/lib/display/fetch_stream.js +221 -90
- package/lib/display/font_loader.js +468 -236
- package/lib/display/metadata.js +38 -16
- package/lib/display/network.js +635 -428
- package/lib/display/network_utils.js +32 -19
- package/lib/display/node_stream.js +367 -175
- package/lib/display/pattern_helper.js +81 -31
- package/lib/display/svg.js +1235 -519
- package/lib/display/text_layer.js +153 -29
- package/lib/display/transport_stream.js +345 -94
- package/lib/display/webgl.js +64 -18
- package/lib/display/worker_options.js +5 -4
- package/lib/display/xml_parser.js +166 -53
- package/lib/examples/node/domstubs.js +60 -4
- package/lib/pdf.js +36 -14
- package/lib/pdf.worker.js +5 -3
- package/lib/shared/compatibility.js +158 -564
- package/lib/shared/global_scope.js +2 -2
- package/lib/shared/is_node.js +4 -4
- package/lib/shared/message_handler.js +521 -0
- package/lib/shared/streams_polyfill.js +21 -17
- package/lib/shared/url_polyfill.js +56 -0
- package/lib/shared/util.js +243 -710
- package/lib/test/unit/annotation_spec.js +870 -401
- package/lib/test/unit/api_spec.js +657 -345
- package/lib/test/unit/bidi_spec.js +7 -7
- package/lib/test/unit/cff_parser_spec.js +54 -11
- package/lib/test/unit/clitests_helper.js +10 -8
- package/lib/test/unit/cmap_spec.js +95 -41
- package/lib/test/unit/colorspace_spec.js +115 -63
- package/lib/test/unit/core_utils_spec.js +191 -0
- package/lib/test/unit/crypto_spec.js +17 -5
- package/lib/test/unit/custom_spec.js +43 -55
- package/lib/test/unit/display_svg_spec.js +34 -18
- package/lib/test/unit/display_utils_spec.js +273 -0
- package/lib/test/unit/document_spec.js +8 -13
- package/lib/test/unit/encodings_spec.js +25 -45
- package/lib/test/unit/evaluator_spec.js +38 -15
- package/lib/test/unit/fetch_stream_spec.js +109 -0
- package/lib/test/unit/function_spec.js +17 -5
- package/lib/test/unit/jasmine-boot.js +33 -20
- package/lib/test/unit/{util_stream_spec.js → message_handler_spec.js} +41 -69
- package/lib/test/unit/metadata_spec.js +71 -11
- package/lib/test/unit/murmurhash3_spec.js +3 -3
- package/lib/test/unit/network_spec.js +19 -54
- package/lib/test/unit/network_utils_spec.js +91 -14
- package/lib/test/unit/node_stream_spec.js +56 -32
- package/lib/test/unit/parser_spec.js +162 -71
- package/lib/test/unit/pdf_find_controller_spec.js +230 -0
- package/lib/test/unit/pdf_find_utils_spec.js +63 -0
- package/lib/test/unit/pdf_history_spec.js +21 -9
- package/lib/test/unit/primitives_spec.js +53 -20
- package/lib/test/unit/stream_spec.js +12 -4
- package/lib/test/unit/test_utils.js +273 -56
- package/lib/test/unit/testreporter.js +21 -3
- package/lib/test/unit/type1_parser_spec.js +8 -6
- package/lib/test/unit/ui_utils_spec.js +454 -16
- package/lib/test/unit/unicode_spec.js +18 -15
- package/lib/test/unit/util_spec.js +87 -128
- package/lib/web/annotation_layer_builder.js +39 -22
- package/lib/web/app.js +1290 -588
- package/lib/web/app_options.js +100 -62
- package/lib/web/base_viewer.js +511 -182
- package/lib/web/chromecom.js +261 -117
- package/lib/web/debugger.js +166 -22
- package/lib/web/download_manager.js +32 -13
- package/lib/web/firefox_print_service.js +20 -10
- package/lib/web/firefoxcom.js +315 -80
- package/lib/web/genericcom.js +89 -30
- package/lib/web/genericl10n.js +142 -30
- package/lib/web/grab_to_pan.js +28 -4
- package/lib/web/interfaces.js +170 -47
- package/lib/web/overlay_manager.js +235 -85
- package/lib/web/password_prompt.js +22 -14
- package/lib/web/pdf_attachment_viewer.js +38 -18
- package/lib/web/pdf_cursor_tools.js +39 -16
- package/lib/web/pdf_document_properties.js +255 -136
- package/lib/web/pdf_find_bar.js +84 -40
- package/lib/web/pdf_find_controller.js +495 -184
- package/lib/web/pdf_find_utils.js +111 -0
- package/lib/web/pdf_history.js +190 -53
- package/lib/web/pdf_link_service.js +138 -77
- package/lib/web/pdf_outline_viewer.js +122 -46
- package/lib/web/pdf_page_view.js +191 -67
- package/lib/web/pdf_presentation_mode.js +99 -34
- package/lib/web/pdf_print_service.js +61 -13
- package/lib/web/pdf_rendering_queue.js +28 -9
- package/lib/web/pdf_sidebar.js +141 -81
- package/lib/web/pdf_sidebar_resizer.js +42 -16
- package/lib/web/pdf_single_page_viewer.js +74 -66
- package/lib/web/pdf_thumbnail_view.js +104 -33
- package/lib/web/pdf_thumbnail_viewer.js +66 -26
- package/lib/web/pdf_viewer.component.js +112 -32
- package/lib/web/pdf_viewer.js +91 -52
- package/lib/web/preferences.js +284 -89
- package/lib/web/secondary_toolbar.js +165 -40
- package/lib/web/text_layer_builder.js +134 -59
- package/lib/web/toolbar.js +78 -43
- package/lib/web/ui_utils.js +462 -136
- package/lib/web/view_history.js +215 -67
- package/lib/web/viewer_compatibility.js +4 -13
- package/package.json +5 -4
- package/web/pdf_viewer.css +79 -11
- package/web/pdf_viewer.js +6107 -3748
- package/web/pdf_viewer.js.map +1 -1
- package/lib/display/dom_utils.js +0 -309
- package/lib/test/unit/dom_utils_spec.js +0 -89
- package/lib/test/unit/fonts_spec.js +0 -81
- package/lib/web/dom_events.js +0 -137
package/lib/core/colorspace.js
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
* @licstart The following is the entire license notice for the
|
3
3
|
* Javascript code in this page
|
4
4
|
*
|
5
|
-
* Copyright
|
5
|
+
* Copyright 2019 Mozilla Foundation
|
6
6
|
*
|
7
7
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
8
8
|
* you may not use this file except in compliance with the License.
|
@@ -19,86 +19,133 @@
|
|
19
19
|
* @licend The above is the entire license notice for the
|
20
20
|
* Javascript code in this page
|
21
21
|
*/
|
22
|
-
|
22
|
+
"use strict";
|
23
23
|
|
24
24
|
Object.defineProperty(exports, "__esModule", {
|
25
25
|
value: true
|
26
26
|
});
|
27
|
-
exports.ColorSpace =
|
28
|
-
|
29
|
-
var _util = require(
|
30
|
-
|
31
|
-
var _primitives = require(
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
27
|
+
exports.ColorSpace = void 0;
|
28
|
+
|
29
|
+
var _util = require("../shared/util");
|
30
|
+
|
31
|
+
var _primitives = require("./primitives");
|
32
|
+
|
33
|
+
function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
|
34
|
+
|
35
|
+
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
|
36
|
+
|
37
|
+
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
|
38
|
+
|
39
|
+
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
|
40
|
+
|
41
|
+
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
|
42
|
+
|
43
|
+
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
|
44
|
+
|
45
|
+
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
46
|
+
|
47
|
+
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
|
48
|
+
|
49
|
+
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
|
50
|
+
|
51
|
+
function resizeRgbImage(src, dest, w1, h1, w2, h2, alpha01) {
|
52
|
+
var COMPONENTS = 3;
|
53
|
+
alpha01 = alpha01 !== 1 ? 0 : alpha01;
|
54
|
+
var xRatio = w1 / w2;
|
55
|
+
var yRatio = h1 / h2;
|
56
|
+
var newIndex = 0,
|
57
|
+
oldIndex;
|
58
|
+
var xScaled = new Uint16Array(w2);
|
59
|
+
var w1Scanline = w1 * COMPONENTS;
|
60
|
+
|
61
|
+
for (var i = 0; i < w2; i++) {
|
62
|
+
xScaled[i] = Math.floor(i * xRatio) * COMPONENTS;
|
63
|
+
}
|
64
|
+
|
65
|
+
for (var _i = 0; _i < h2; _i++) {
|
66
|
+
var py = Math.floor(_i * yRatio) * w1Scanline;
|
67
|
+
|
68
|
+
for (var j = 0; j < w2; j++) {
|
69
|
+
oldIndex = py + xScaled[j];
|
70
|
+
dest[newIndex++] = src[oldIndex++];
|
71
|
+
dest[newIndex++] = src[oldIndex++];
|
72
|
+
dest[newIndex++] = src[oldIndex++];
|
73
|
+
newIndex += alpha01;
|
58
74
|
}
|
59
75
|
}
|
60
|
-
|
61
|
-
|
76
|
+
}
|
77
|
+
|
78
|
+
var ColorSpace =
|
79
|
+
/*#__PURE__*/
|
80
|
+
function () {
|
81
|
+
function ColorSpace(name, numComps) {
|
82
|
+
_classCallCheck(this, ColorSpace);
|
83
|
+
|
84
|
+
if (this.constructor === ColorSpace) {
|
85
|
+
(0, _util.unreachable)('Cannot initialize ColorSpace.');
|
86
|
+
}
|
87
|
+
|
88
|
+
this.name = name;
|
89
|
+
this.numComps = numComps;
|
62
90
|
}
|
63
|
-
|
64
|
-
|
65
|
-
|
91
|
+
|
92
|
+
_createClass(ColorSpace, [{
|
93
|
+
key: "getRgb",
|
94
|
+
value: function getRgb(src, srcOffset) {
|
95
|
+
var rgb = new Uint8ClampedArray(3);
|
66
96
|
this.getRgbItem(src, srcOffset, rgb, 0);
|
67
97
|
return rgb;
|
68
|
-
}
|
69
|
-
|
98
|
+
}
|
99
|
+
}, {
|
100
|
+
key: "getRgbItem",
|
101
|
+
value: function getRgbItem(src, srcOffset, dest, destOffset) {
|
70
102
|
(0, _util.unreachable)('Should not call ColorSpace.getRgbItem');
|
71
|
-
}
|
72
|
-
|
103
|
+
}
|
104
|
+
}, {
|
105
|
+
key: "getRgbBuffer",
|
106
|
+
value: function getRgbBuffer(src, srcOffset, count, dest, destOffset, bits, alpha01) {
|
73
107
|
(0, _util.unreachable)('Should not call ColorSpace.getRgbBuffer');
|
74
|
-
}
|
75
|
-
|
108
|
+
}
|
109
|
+
}, {
|
110
|
+
key: "getOutputLength",
|
111
|
+
value: function getOutputLength(inputLength, alpha01) {
|
76
112
|
(0, _util.unreachable)('Should not call ColorSpace.getOutputLength');
|
77
|
-
}
|
78
|
-
|
113
|
+
}
|
114
|
+
}, {
|
115
|
+
key: "isPassthrough",
|
116
|
+
value: function isPassthrough(bits) {
|
79
117
|
return false;
|
80
|
-
}
|
81
|
-
|
118
|
+
}
|
119
|
+
}, {
|
120
|
+
key: "isDefaultDecode",
|
121
|
+
value: function isDefaultDecode(decodeMap, bpc) {
|
122
|
+
return ColorSpace.isDefaultDecode(decodeMap, this.numComps);
|
123
|
+
}
|
124
|
+
}, {
|
125
|
+
key: "fillRgb",
|
126
|
+
value: function fillRgb(dest, originalWidth, originalHeight, width, height, actualHeight, bpc, comps, alpha01) {
|
82
127
|
var count = originalWidth * originalHeight;
|
83
128
|
var rgbBuf = null;
|
84
129
|
var numComponentColors = 1 << bpc;
|
85
130
|
var needsResizing = originalHeight !== height || originalWidth !== width;
|
86
|
-
|
131
|
+
|
87
132
|
if (this.isPassthrough(bpc)) {
|
88
133
|
rgbBuf = comps;
|
89
134
|
} else if (this.numComps === 1 && count > numComponentColors && this.name !== 'DeviceGray' && this.name !== 'DeviceRGB') {
|
90
135
|
var allColors = bpc <= 8 ? new Uint8Array(numComponentColors) : new Uint16Array(numComponentColors);
|
91
|
-
|
92
|
-
for (i = 0; i < numComponentColors; i++) {
|
136
|
+
|
137
|
+
for (var i = 0; i < numComponentColors; i++) {
|
93
138
|
allColors[i] = i;
|
94
139
|
}
|
95
|
-
|
140
|
+
|
141
|
+
var colorMap = new Uint8ClampedArray(numComponentColors * 3);
|
96
142
|
this.getRgbBuffer(allColors, 0, numComponentColors, colorMap, 0, bpc, 0);
|
97
|
-
|
143
|
+
|
98
144
|
if (!needsResizing) {
|
99
|
-
destPos = 0;
|
100
|
-
|
101
|
-
|
145
|
+
var destPos = 0;
|
146
|
+
|
147
|
+
for (var _i2 = 0; _i2 < count; ++_i2) {
|
148
|
+
var key = comps[_i2] * 3;
|
102
149
|
dest[destPos++] = colorMap[key];
|
103
150
|
dest[destPos++] = colorMap[key + 1];
|
104
151
|
dest[destPos++] = colorMap[key + 2];
|
@@ -106,253 +153,332 @@ var ColorSpace = function ColorSpaceClosure() {
|
|
106
153
|
}
|
107
154
|
} else {
|
108
155
|
rgbBuf = new Uint8Array(count * 3);
|
109
|
-
rgbPos = 0;
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
rgbBuf[rgbPos++] = colorMap[
|
156
|
+
var rgbPos = 0;
|
157
|
+
|
158
|
+
for (var _i3 = 0; _i3 < count; ++_i3) {
|
159
|
+
var _key = comps[_i3] * 3;
|
160
|
+
|
161
|
+
rgbBuf[rgbPos++] = colorMap[_key];
|
162
|
+
rgbBuf[rgbPos++] = colorMap[_key + 1];
|
163
|
+
rgbBuf[rgbPos++] = colorMap[_key + 2];
|
115
164
|
}
|
116
165
|
}
|
117
166
|
} else {
|
118
167
|
if (!needsResizing) {
|
119
168
|
this.getRgbBuffer(comps, 0, width * actualHeight, dest, 0, bpc, alpha01);
|
120
169
|
} else {
|
121
|
-
rgbBuf = new
|
170
|
+
rgbBuf = new Uint8ClampedArray(count * 3);
|
122
171
|
this.getRgbBuffer(comps, 0, count, rgbBuf, 0, bpc, 0);
|
123
172
|
}
|
124
173
|
}
|
174
|
+
|
125
175
|
if (rgbBuf) {
|
126
176
|
if (needsResizing) {
|
127
|
-
resizeRgbImage(rgbBuf,
|
177
|
+
resizeRgbImage(rgbBuf, dest, originalWidth, originalHeight, width, height, alpha01);
|
128
178
|
} else {
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
dest[
|
134
|
-
dest[
|
135
|
-
|
179
|
+
var _destPos = 0,
|
180
|
+
_rgbPos = 0;
|
181
|
+
|
182
|
+
for (var _i4 = 0, ii = width * actualHeight; _i4 < ii; _i4++) {
|
183
|
+
dest[_destPos++] = rgbBuf[_rgbPos++];
|
184
|
+
dest[_destPos++] = rgbBuf[_rgbPos++];
|
185
|
+
dest[_destPos++] = rgbBuf[_rgbPos++];
|
186
|
+
_destPos += alpha01;
|
136
187
|
}
|
137
188
|
}
|
138
189
|
}
|
139
|
-
}
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
}
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
return 'DeviceCmykCS';
|
208
|
-
case 'Pattern':
|
209
|
-
return ['PatternCS', null];
|
190
|
+
}
|
191
|
+
}, {
|
192
|
+
key: "usesZeroToOneRange",
|
193
|
+
get: function get() {
|
194
|
+
return (0, _util.shadow)(this, 'usesZeroToOneRange', true);
|
195
|
+
}
|
196
|
+
}], [{
|
197
|
+
key: "parse",
|
198
|
+
value: function parse(cs, xref, res, pdfFunctionFactory) {
|
199
|
+
var IR = this.parseToIR(cs, xref, res, pdfFunctionFactory);
|
200
|
+
return this.fromIR(IR);
|
201
|
+
}
|
202
|
+
}, {
|
203
|
+
key: "fromIR",
|
204
|
+
value: function fromIR(IR) {
|
205
|
+
var name = Array.isArray(IR) ? IR[0] : IR;
|
206
|
+
var whitePoint, blackPoint, gamma;
|
207
|
+
|
208
|
+
switch (name) {
|
209
|
+
case 'DeviceGrayCS':
|
210
|
+
return this.singletons.gray;
|
211
|
+
|
212
|
+
case 'DeviceRgbCS':
|
213
|
+
return this.singletons.rgb;
|
214
|
+
|
215
|
+
case 'DeviceCmykCS':
|
216
|
+
return this.singletons.cmyk;
|
217
|
+
|
218
|
+
case 'CalGrayCS':
|
219
|
+
whitePoint = IR[1];
|
220
|
+
blackPoint = IR[2];
|
221
|
+
gamma = IR[3];
|
222
|
+
return new CalGrayCS(whitePoint, blackPoint, gamma);
|
223
|
+
|
224
|
+
case 'CalRGBCS':
|
225
|
+
whitePoint = IR[1];
|
226
|
+
blackPoint = IR[2];
|
227
|
+
gamma = IR[3];
|
228
|
+
var matrix = IR[4];
|
229
|
+
return new CalRGBCS(whitePoint, blackPoint, gamma, matrix);
|
230
|
+
|
231
|
+
case 'PatternCS':
|
232
|
+
var basePatternCS = IR[1];
|
233
|
+
|
234
|
+
if (basePatternCS) {
|
235
|
+
basePatternCS = this.fromIR(basePatternCS);
|
236
|
+
}
|
237
|
+
|
238
|
+
return new PatternCS(basePatternCS);
|
239
|
+
|
240
|
+
case 'IndexedCS':
|
241
|
+
var baseIndexedCS = IR[1];
|
242
|
+
var hiVal = IR[2];
|
243
|
+
var lookup = IR[3];
|
244
|
+
return new IndexedCS(this.fromIR(baseIndexedCS), hiVal, lookup);
|
245
|
+
|
246
|
+
case 'AlternateCS':
|
247
|
+
var numComps = IR[1];
|
248
|
+
var alt = IR[2];
|
249
|
+
var tintFn = IR[3];
|
250
|
+
return new AlternateCS(numComps, this.fromIR(alt), tintFn);
|
251
|
+
|
252
|
+
case 'LabCS':
|
253
|
+
whitePoint = IR[1];
|
254
|
+
blackPoint = IR[2];
|
255
|
+
var range = IR[3];
|
256
|
+
return new LabCS(whitePoint, blackPoint, range);
|
257
|
+
|
210
258
|
default:
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
|
259
|
+
throw new _util.FormatError("Unknown colorspace name: ".concat(name));
|
260
|
+
}
|
261
|
+
}
|
262
|
+
}, {
|
263
|
+
key: "parseToIR",
|
264
|
+
value: function parseToIR(cs, xref) {
|
265
|
+
var res = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;
|
266
|
+
var pdfFunctionFactory = arguments.length > 3 ? arguments[3] : undefined;
|
267
|
+
cs = xref.fetchIfRef(cs);
|
268
|
+
|
269
|
+
if ((0, _primitives.isName)(cs)) {
|
270
|
+
switch (cs.name) {
|
271
|
+
case 'DeviceGray':
|
272
|
+
case 'G':
|
273
|
+
return 'DeviceGrayCS';
|
274
|
+
|
275
|
+
case 'DeviceRGB':
|
276
|
+
case 'RGB':
|
277
|
+
return 'DeviceRgbCS';
|
278
|
+
|
279
|
+
case 'DeviceCMYK':
|
280
|
+
case 'CMYK':
|
281
|
+
return 'DeviceCmykCS';
|
282
|
+
|
283
|
+
case 'Pattern':
|
284
|
+
return ['PatternCS', null];
|
285
|
+
|
286
|
+
default:
|
287
|
+
if ((0, _primitives.isDict)(res)) {
|
288
|
+
var colorSpaces = res.get('ColorSpace');
|
289
|
+
|
290
|
+
if ((0, _primitives.isDict)(colorSpaces)) {
|
291
|
+
var resCS = colorSpaces.get(cs.name);
|
292
|
+
|
293
|
+
if (resCS) {
|
294
|
+
if ((0, _primitives.isName)(resCS)) {
|
295
|
+
return this.parseToIR(resCS, xref, res, pdfFunctionFactory);
|
296
|
+
}
|
297
|
+
|
298
|
+
cs = resCS;
|
299
|
+
break;
|
218
300
|
}
|
219
|
-
cs = resCS;
|
220
|
-
break;
|
221
301
|
}
|
222
302
|
}
|
223
|
-
|
224
|
-
|
225
|
-
|
226
|
-
|
227
|
-
|
228
|
-
|
229
|
-
|
230
|
-
|
231
|
-
|
232
|
-
|
233
|
-
|
234
|
-
|
235
|
-
case 'RGB':
|
236
|
-
return 'DeviceRgbCS';
|
237
|
-
case 'DeviceCMYK':
|
238
|
-
case 'CMYK':
|
239
|
-
return 'DeviceCmykCS';
|
240
|
-
case 'CalGray':
|
241
|
-
params = xref.fetchIfRef(cs[1]);
|
242
|
-
whitePoint = params.getArray('WhitePoint');
|
243
|
-
blackPoint = params.getArray('BlackPoint');
|
244
|
-
gamma = params.get('Gamma');
|
245
|
-
return ['CalGrayCS', whitePoint, blackPoint, gamma];
|
246
|
-
case 'CalRGB':
|
247
|
-
params = xref.fetchIfRef(cs[1]);
|
248
|
-
whitePoint = params.getArray('WhitePoint');
|
249
|
-
blackPoint = params.getArray('BlackPoint');
|
250
|
-
gamma = params.getArray('Gamma');
|
251
|
-
var matrix = params.getArray('Matrix');
|
252
|
-
return ['CalRGBCS', whitePoint, blackPoint, gamma, matrix];
|
253
|
-
case 'ICCBased':
|
254
|
-
var stream = xref.fetchIfRef(cs[1]);
|
255
|
-
var dict = stream.dict;
|
256
|
-
numComps = dict.get('N');
|
257
|
-
alt = dict.get('Alternate');
|
258
|
-
if (alt) {
|
259
|
-
var altIR = ColorSpace.parseToIR(alt, xref, res, pdfFunctionFactory);
|
260
|
-
var altCS = ColorSpace.fromIR(altIR, pdfFunctionFactory);
|
261
|
-
if (altCS.numComps === numComps) {
|
262
|
-
return altIR;
|
263
|
-
}
|
264
|
-
(0, _util.warn)('ICCBased color space: Ignoring incorrect /Alternate entry.');
|
265
|
-
}
|
266
|
-
if (numComps === 1) {
|
303
|
+
|
304
|
+
throw new _util.FormatError("unrecognized colorspace ".concat(cs.name));
|
305
|
+
}
|
306
|
+
}
|
307
|
+
|
308
|
+
if (Array.isArray(cs)) {
|
309
|
+
var mode = xref.fetchIfRef(cs[0]).name;
|
310
|
+
var numComps, params, alt, whitePoint, blackPoint, gamma;
|
311
|
+
|
312
|
+
switch (mode) {
|
313
|
+
case 'DeviceGray':
|
314
|
+
case 'G':
|
267
315
|
return 'DeviceGrayCS';
|
268
|
-
|
316
|
+
|
317
|
+
case 'DeviceRGB':
|
318
|
+
case 'RGB':
|
269
319
|
return 'DeviceRgbCS';
|
270
|
-
|
320
|
+
|
321
|
+
case 'DeviceCMYK':
|
322
|
+
case 'CMYK':
|
271
323
|
return 'DeviceCmykCS';
|
272
|
-
|
273
|
-
|
274
|
-
|
275
|
-
|
276
|
-
|
277
|
-
|
278
|
-
|
279
|
-
|
280
|
-
|
281
|
-
|
282
|
-
|
283
|
-
|
284
|
-
|
285
|
-
|
286
|
-
|
287
|
-
|
288
|
-
|
289
|
-
|
290
|
-
|
291
|
-
|
292
|
-
|
293
|
-
|
294
|
-
|
295
|
-
|
296
|
-
|
297
|
-
|
298
|
-
|
299
|
-
|
300
|
-
|
301
|
-
|
302
|
-
|
303
|
-
|
324
|
+
|
325
|
+
case 'CalGray':
|
326
|
+
params = xref.fetchIfRef(cs[1]);
|
327
|
+
whitePoint = params.getArray('WhitePoint');
|
328
|
+
blackPoint = params.getArray('BlackPoint');
|
329
|
+
gamma = params.get('Gamma');
|
330
|
+
return ['CalGrayCS', whitePoint, blackPoint, gamma];
|
331
|
+
|
332
|
+
case 'CalRGB':
|
333
|
+
params = xref.fetchIfRef(cs[1]);
|
334
|
+
whitePoint = params.getArray('WhitePoint');
|
335
|
+
blackPoint = params.getArray('BlackPoint');
|
336
|
+
gamma = params.getArray('Gamma');
|
337
|
+
var matrix = params.getArray('Matrix');
|
338
|
+
return ['CalRGBCS', whitePoint, blackPoint, gamma, matrix];
|
339
|
+
|
340
|
+
case 'ICCBased':
|
341
|
+
var stream = xref.fetchIfRef(cs[1]);
|
342
|
+
var dict = stream.dict;
|
343
|
+
numComps = dict.get('N');
|
344
|
+
alt = dict.get('Alternate');
|
345
|
+
|
346
|
+
if (alt) {
|
347
|
+
var altIR = this.parseToIR(alt, xref, res, pdfFunctionFactory);
|
348
|
+
var altCS = this.fromIR(altIR, pdfFunctionFactory);
|
349
|
+
|
350
|
+
if (altCS.numComps === numComps) {
|
351
|
+
return altIR;
|
352
|
+
}
|
353
|
+
|
354
|
+
(0, _util.warn)('ICCBased color space: Ignoring incorrect /Alternate entry.');
|
355
|
+
}
|
356
|
+
|
357
|
+
if (numComps === 1) {
|
358
|
+
return 'DeviceGrayCS';
|
359
|
+
} else if (numComps === 3) {
|
360
|
+
return 'DeviceRgbCS';
|
361
|
+
} else if (numComps === 4) {
|
362
|
+
return 'DeviceCmykCS';
|
363
|
+
}
|
364
|
+
|
365
|
+
break;
|
366
|
+
|
367
|
+
case 'Pattern':
|
368
|
+
var basePatternCS = cs[1] || null;
|
369
|
+
|
370
|
+
if (basePatternCS) {
|
371
|
+
basePatternCS = this.parseToIR(basePatternCS, xref, res, pdfFunctionFactory);
|
372
|
+
}
|
373
|
+
|
374
|
+
return ['PatternCS', basePatternCS];
|
375
|
+
|
376
|
+
case 'Indexed':
|
377
|
+
case 'I':
|
378
|
+
var baseIndexedCS = this.parseToIR(cs[1], xref, res, pdfFunctionFactory);
|
379
|
+
var hiVal = xref.fetchIfRef(cs[2]) + 1;
|
380
|
+
var lookup = xref.fetchIfRef(cs[3]);
|
381
|
+
|
382
|
+
if ((0, _primitives.isStream)(lookup)) {
|
383
|
+
lookup = lookup.getBytes();
|
384
|
+
}
|
385
|
+
|
386
|
+
return ['IndexedCS', baseIndexedCS, hiVal, lookup];
|
387
|
+
|
388
|
+
case 'Separation':
|
389
|
+
case 'DeviceN':
|
390
|
+
var name = xref.fetchIfRef(cs[1]);
|
391
|
+
numComps = Array.isArray(name) ? name.length : 1;
|
392
|
+
alt = this.parseToIR(cs[2], xref, res, pdfFunctionFactory);
|
393
|
+
var tintFn = pdfFunctionFactory.create(xref.fetchIfRef(cs[3]));
|
394
|
+
return ['AlternateCS', numComps, alt, tintFn];
|
395
|
+
|
396
|
+
case 'Lab':
|
397
|
+
params = xref.fetchIfRef(cs[1]);
|
398
|
+
whitePoint = params.getArray('WhitePoint');
|
399
|
+
blackPoint = params.getArray('BlackPoint');
|
400
|
+
var range = params.getArray('Range');
|
401
|
+
return ['LabCS', whitePoint, blackPoint, range];
|
402
|
+
|
403
|
+
default:
|
404
|
+
throw new _util.FormatError("unimplemented color space object \"".concat(mode, "\""));
|
405
|
+
}
|
304
406
|
}
|
407
|
+
|
408
|
+
throw new _util.FormatError("unrecognized color space object: \"".concat(cs, "\""));
|
305
409
|
}
|
306
|
-
|
307
|
-
|
308
|
-
|
309
|
-
|
310
|
-
|
311
|
-
|
312
|
-
|
313
|
-
|
314
|
-
|
315
|
-
|
316
|
-
|
317
|
-
|
318
|
-
|
410
|
+
}, {
|
411
|
+
key: "isDefaultDecode",
|
412
|
+
value: function isDefaultDecode(decode, numComps) {
|
413
|
+
if (!Array.isArray(decode)) {
|
414
|
+
return true;
|
415
|
+
}
|
416
|
+
|
417
|
+
if (numComps * 2 !== decode.length) {
|
418
|
+
(0, _util.warn)('The decode map is not the correct length');
|
419
|
+
return true;
|
420
|
+
}
|
421
|
+
|
422
|
+
for (var i = 0, ii = decode.length; i < ii; i += 2) {
|
423
|
+
if (decode[i] !== 0 || decode[i + 1] !== 1) {
|
424
|
+
return false;
|
425
|
+
}
|
319
426
|
}
|
427
|
+
|
428
|
+
return true;
|
320
429
|
}
|
321
|
-
|
322
|
-
|
323
|
-
|
324
|
-
|
325
|
-
|
326
|
-
|
327
|
-
|
328
|
-
|
329
|
-
|
330
|
-
|
331
|
-
|
430
|
+
}, {
|
431
|
+
key: "singletons",
|
432
|
+
get: function get() {
|
433
|
+
return (0, _util.shadow)(this, 'singletons', {
|
434
|
+
get gray() {
|
435
|
+
return (0, _util.shadow)(this, 'gray', new DeviceGrayCS());
|
436
|
+
},
|
437
|
+
|
438
|
+
get rgb() {
|
439
|
+
return (0, _util.shadow)(this, 'rgb', new DeviceRgbCS());
|
440
|
+
},
|
441
|
+
|
442
|
+
get cmyk() {
|
443
|
+
return (0, _util.shadow)(this, 'cmyk', new DeviceCmykCS());
|
444
|
+
}
|
445
|
+
|
446
|
+
});
|
332
447
|
}
|
333
|
-
};
|
448
|
+
}]);
|
449
|
+
|
334
450
|
return ColorSpace;
|
335
451
|
}();
|
336
|
-
|
452
|
+
|
453
|
+
exports.ColorSpace = ColorSpace;
|
454
|
+
|
455
|
+
var AlternateCS =
|
456
|
+
/*#__PURE__*/
|
457
|
+
function (_ColorSpace) {
|
458
|
+
_inherits(AlternateCS, _ColorSpace);
|
459
|
+
|
337
460
|
function AlternateCS(numComps, base, tintFn) {
|
338
|
-
|
339
|
-
|
340
|
-
this
|
341
|
-
|
342
|
-
|
343
|
-
|
344
|
-
|
345
|
-
|
346
|
-
|
461
|
+
var _this;
|
462
|
+
|
463
|
+
_classCallCheck(this, AlternateCS);
|
464
|
+
|
465
|
+
_this = _possibleConstructorReturn(this, _getPrototypeOf(AlternateCS).call(this, 'Alternate', numComps));
|
466
|
+
_this.base = base;
|
467
|
+
_this.tintFn = tintFn;
|
468
|
+
_this.tmpBuf = new Float32Array(base.numComps);
|
469
|
+
return _this;
|
347
470
|
}
|
348
|
-
|
349
|
-
|
350
|
-
|
471
|
+
|
472
|
+
_createClass(AlternateCS, [{
|
473
|
+
key: "getRgbItem",
|
474
|
+
value: function getRgbItem(src, srcOffset, dest, destOffset) {
|
351
475
|
var tmpBuf = this.tmpBuf;
|
352
476
|
this.tintFn(src, srcOffset, tmpBuf, 0);
|
353
477
|
this.base.getRgbItem(tmpBuf, 0, dest, destOffset);
|
354
|
-
}
|
355
|
-
|
478
|
+
}
|
479
|
+
}, {
|
480
|
+
key: "getRgbBuffer",
|
481
|
+
value: function getRgbBuffer(src, srcOffset, count, dest, destOffset, bits, alpha01) {
|
356
482
|
var tintFn = this.tintFn;
|
357
483
|
var base = this.base;
|
358
484
|
var scale = 1 / ((1 << bits) - 1);
|
@@ -360,16 +486,19 @@ var AlternateCS = function AlternateCSClosure() {
|
|
360
486
|
var usesZeroToOneRange = base.usesZeroToOneRange;
|
361
487
|
var isPassthrough = (base.isPassthrough(8) || !usesZeroToOneRange) && alpha01 === 0;
|
362
488
|
var pos = isPassthrough ? destOffset : 0;
|
363
|
-
var baseBuf = isPassthrough ? dest : new
|
489
|
+
var baseBuf = isPassthrough ? dest : new Uint8ClampedArray(baseNumComps * count);
|
364
490
|
var numComps = this.numComps;
|
365
491
|
var scaled = new Float32Array(numComps);
|
366
492
|
var tinted = new Float32Array(baseNumComps);
|
367
493
|
var i, j;
|
494
|
+
|
368
495
|
for (i = 0; i < count; i++) {
|
369
496
|
for (j = 0; j < numComps; j++) {
|
370
497
|
scaled[j] = src[srcOffset++] * scale;
|
371
498
|
}
|
499
|
+
|
372
500
|
tintFn(scaled, 0, tinted, 0);
|
501
|
+
|
373
502
|
if (usesZeroToOneRange) {
|
374
503
|
for (j = 0; j < baseNumComps; j++) {
|
375
504
|
baseBuf[pos++] = tinted[j] * 255;
|
@@ -379,276 +508,364 @@ var AlternateCS = function AlternateCSClosure() {
|
|
379
508
|
pos += baseNumComps;
|
380
509
|
}
|
381
510
|
}
|
511
|
+
|
382
512
|
if (!isPassthrough) {
|
383
513
|
base.getRgbBuffer(baseBuf, 0, count, dest, destOffset, 8, alpha01);
|
384
514
|
}
|
385
|
-
}
|
386
|
-
|
515
|
+
}
|
516
|
+
}, {
|
517
|
+
key: "getOutputLength",
|
518
|
+
value: function getOutputLength(inputLength, alpha01) {
|
387
519
|
return this.base.getOutputLength(inputLength * this.base.numComps / this.numComps, alpha01);
|
388
|
-
}
|
389
|
-
|
390
|
-
|
391
|
-
isDefaultDecode: function AlternateCS_isDefaultDecode(decodeMap) {
|
392
|
-
return ColorSpace.isDefaultDecode(decodeMap, this.numComps);
|
393
|
-
},
|
394
|
-
usesZeroToOneRange: true
|
395
|
-
};
|
520
|
+
}
|
521
|
+
}]);
|
522
|
+
|
396
523
|
return AlternateCS;
|
397
|
-
}();
|
398
|
-
|
524
|
+
}(ColorSpace);
|
525
|
+
|
526
|
+
var PatternCS =
|
527
|
+
/*#__PURE__*/
|
528
|
+
function (_ColorSpace2) {
|
529
|
+
_inherits(PatternCS, _ColorSpace2);
|
530
|
+
|
399
531
|
function PatternCS(baseCS) {
|
400
|
-
|
401
|
-
|
532
|
+
var _this2;
|
533
|
+
|
534
|
+
_classCallCheck(this, PatternCS);
|
535
|
+
|
536
|
+
_this2 = _possibleConstructorReturn(this, _getPrototypeOf(PatternCS).call(this, 'Pattern', null));
|
537
|
+
_this2.base = baseCS;
|
538
|
+
return _this2;
|
402
539
|
}
|
403
|
-
|
540
|
+
|
541
|
+
_createClass(PatternCS, [{
|
542
|
+
key: "isDefaultDecode",
|
543
|
+
value: function isDefaultDecode(decodeMap, bpc) {
|
544
|
+
(0, _util.unreachable)('Should not call PatternCS.isDefaultDecode');
|
545
|
+
}
|
546
|
+
}]);
|
547
|
+
|
404
548
|
return PatternCS;
|
405
|
-
}();
|
406
|
-
|
549
|
+
}(ColorSpace);
|
550
|
+
|
551
|
+
var IndexedCS =
|
552
|
+
/*#__PURE__*/
|
553
|
+
function (_ColorSpace3) {
|
554
|
+
_inherits(IndexedCS, _ColorSpace3);
|
555
|
+
|
407
556
|
function IndexedCS(base, highVal, lookup) {
|
408
|
-
|
409
|
-
|
410
|
-
this
|
411
|
-
|
412
|
-
this.
|
557
|
+
var _this3;
|
558
|
+
|
559
|
+
_classCallCheck(this, IndexedCS);
|
560
|
+
|
561
|
+
_this3 = _possibleConstructorReturn(this, _getPrototypeOf(IndexedCS).call(this, 'Indexed', 1));
|
562
|
+
_this3.base = base;
|
563
|
+
_this3.highVal = highVal;
|
413
564
|
var baseNumComps = base.numComps;
|
414
565
|
var length = baseNumComps * highVal;
|
566
|
+
|
415
567
|
if ((0, _primitives.isStream)(lookup)) {
|
416
|
-
|
568
|
+
_this3.lookup = new Uint8Array(length);
|
417
569
|
var bytes = lookup.getBytes(length);
|
418
|
-
|
570
|
+
|
571
|
+
_this3.lookup.set(bytes);
|
419
572
|
} else if ((0, _util.isString)(lookup)) {
|
420
|
-
|
573
|
+
_this3.lookup = new Uint8Array(length);
|
574
|
+
|
421
575
|
for (var i = 0; i < length; ++i) {
|
422
|
-
|
576
|
+
_this3.lookup[i] = lookup.charCodeAt(i);
|
423
577
|
}
|
424
578
|
} else if (lookup instanceof Uint8Array) {
|
425
|
-
|
579
|
+
_this3.lookup = lookup;
|
426
580
|
} else {
|
427
|
-
throw new _util.FormatError(
|
581
|
+
throw new _util.FormatError("Unrecognized lookup table: ".concat(lookup));
|
428
582
|
}
|
583
|
+
|
584
|
+
return _this3;
|
429
585
|
}
|
430
|
-
|
431
|
-
|
432
|
-
|
586
|
+
|
587
|
+
_createClass(IndexedCS, [{
|
588
|
+
key: "getRgbItem",
|
589
|
+
value: function getRgbItem(src, srcOffset, dest, destOffset) {
|
433
590
|
var numComps = this.base.numComps;
|
434
591
|
var start = src[srcOffset] * numComps;
|
435
592
|
this.base.getRgbBuffer(this.lookup, start, 1, dest, destOffset, 8, 0);
|
436
|
-
}
|
437
|
-
|
593
|
+
}
|
594
|
+
}, {
|
595
|
+
key: "getRgbBuffer",
|
596
|
+
value: function getRgbBuffer(src, srcOffset, count, dest, destOffset, bits, alpha01) {
|
438
597
|
var base = this.base;
|
439
598
|
var numComps = base.numComps;
|
440
599
|
var outputDelta = base.getOutputLength(numComps, alpha01);
|
441
600
|
var lookup = this.lookup;
|
601
|
+
|
442
602
|
for (var i = 0; i < count; ++i) {
|
443
603
|
var lookupPos = src[srcOffset++] * numComps;
|
444
604
|
base.getRgbBuffer(lookup, lookupPos, 1, dest, destOffset, 8, alpha01);
|
445
605
|
destOffset += outputDelta;
|
446
606
|
}
|
447
|
-
}
|
448
|
-
|
607
|
+
}
|
608
|
+
}, {
|
609
|
+
key: "getOutputLength",
|
610
|
+
value: function getOutputLength(inputLength, alpha01) {
|
449
611
|
return this.base.getOutputLength(inputLength * this.base.numComps, alpha01);
|
450
|
-
}
|
451
|
-
|
452
|
-
|
453
|
-
|
454
|
-
|
455
|
-
|
456
|
-
|
457
|
-
|
612
|
+
}
|
613
|
+
}, {
|
614
|
+
key: "isDefaultDecode",
|
615
|
+
value: function isDefaultDecode(decodeMap, bpc) {
|
616
|
+
if (!Array.isArray(decodeMap)) {
|
617
|
+
return true;
|
618
|
+
}
|
619
|
+
|
620
|
+
if (decodeMap.length !== 2) {
|
621
|
+
(0, _util.warn)('Decode map length is not correct');
|
622
|
+
return true;
|
623
|
+
}
|
624
|
+
|
625
|
+
if (!Number.isInteger(bpc) || bpc < 1) {
|
626
|
+
(0, _util.warn)('Bits per component is not correct');
|
627
|
+
return true;
|
628
|
+
}
|
629
|
+
|
630
|
+
return decodeMap[0] === 0 && decodeMap[1] === (1 << bpc) - 1;
|
631
|
+
}
|
632
|
+
}]);
|
633
|
+
|
458
634
|
return IndexedCS;
|
459
|
-
}();
|
460
|
-
|
635
|
+
}(ColorSpace);
|
636
|
+
|
637
|
+
var DeviceGrayCS =
|
638
|
+
/*#__PURE__*/
|
639
|
+
function (_ColorSpace4) {
|
640
|
+
_inherits(DeviceGrayCS, _ColorSpace4);
|
641
|
+
|
461
642
|
function DeviceGrayCS() {
|
462
|
-
this
|
463
|
-
|
464
|
-
this.
|
643
|
+
_classCallCheck(this, DeviceGrayCS);
|
644
|
+
|
645
|
+
return _possibleConstructorReturn(this, _getPrototypeOf(DeviceGrayCS).call(this, 'DeviceGray', 1));
|
465
646
|
}
|
466
|
-
|
467
|
-
|
468
|
-
|
469
|
-
|
470
|
-
c =
|
647
|
+
|
648
|
+
_createClass(DeviceGrayCS, [{
|
649
|
+
key: "getRgbItem",
|
650
|
+
value: function getRgbItem(src, srcOffset, dest, destOffset) {
|
651
|
+
var c = src[srcOffset] * 255;
|
471
652
|
dest[destOffset] = dest[destOffset + 1] = dest[destOffset + 2] = c;
|
472
|
-
}
|
473
|
-
|
653
|
+
}
|
654
|
+
}, {
|
655
|
+
key: "getRgbBuffer",
|
656
|
+
value: function getRgbBuffer(src, srcOffset, count, dest, destOffset, bits, alpha01) {
|
474
657
|
var scale = 255 / ((1 << bits) - 1);
|
475
658
|
var j = srcOffset,
|
476
659
|
q = destOffset;
|
660
|
+
|
477
661
|
for (var i = 0; i < count; ++i) {
|
478
|
-
var c = scale * src[j++]
|
662
|
+
var c = scale * src[j++];
|
479
663
|
dest[q++] = c;
|
480
664
|
dest[q++] = c;
|
481
665
|
dest[q++] = c;
|
482
666
|
q += alpha01;
|
483
667
|
}
|
484
|
-
}
|
485
|
-
|
668
|
+
}
|
669
|
+
}, {
|
670
|
+
key: "getOutputLength",
|
671
|
+
value: function getOutputLength(inputLength, alpha01) {
|
486
672
|
return inputLength * (3 + alpha01);
|
487
|
-
}
|
488
|
-
|
489
|
-
|
490
|
-
isDefaultDecode: function DeviceGrayCS_isDefaultDecode(decodeMap) {
|
491
|
-
return ColorSpace.isDefaultDecode(decodeMap, this.numComps);
|
492
|
-
},
|
493
|
-
usesZeroToOneRange: true
|
494
|
-
};
|
673
|
+
}
|
674
|
+
}]);
|
675
|
+
|
495
676
|
return DeviceGrayCS;
|
496
|
-
}();
|
497
|
-
|
677
|
+
}(ColorSpace);
|
678
|
+
|
679
|
+
var DeviceRgbCS =
|
680
|
+
/*#__PURE__*/
|
681
|
+
function (_ColorSpace5) {
|
682
|
+
_inherits(DeviceRgbCS, _ColorSpace5);
|
683
|
+
|
498
684
|
function DeviceRgbCS() {
|
499
|
-
this
|
500
|
-
|
501
|
-
this.
|
685
|
+
_classCallCheck(this, DeviceRgbCS);
|
686
|
+
|
687
|
+
return _possibleConstructorReturn(this, _getPrototypeOf(DeviceRgbCS).call(this, 'DeviceRGB', 3));
|
502
688
|
}
|
503
|
-
|
504
|
-
|
505
|
-
|
506
|
-
|
507
|
-
|
508
|
-
|
509
|
-
dest[destOffset] =
|
510
|
-
|
511
|
-
|
512
|
-
|
513
|
-
|
689
|
+
|
690
|
+
_createClass(DeviceRgbCS, [{
|
691
|
+
key: "getRgbItem",
|
692
|
+
value: function getRgbItem(src, srcOffset, dest, destOffset) {
|
693
|
+
dest[destOffset] = src[srcOffset] * 255;
|
694
|
+
dest[destOffset + 1] = src[srcOffset + 1] * 255;
|
695
|
+
dest[destOffset + 2] = src[srcOffset + 2] * 255;
|
696
|
+
}
|
697
|
+
}, {
|
698
|
+
key: "getRgbBuffer",
|
699
|
+
value: function getRgbBuffer(src, srcOffset, count, dest, destOffset, bits, alpha01) {
|
514
700
|
if (bits === 8 && alpha01 === 0) {
|
515
701
|
dest.set(src.subarray(srcOffset, srcOffset + count * 3), destOffset);
|
516
702
|
return;
|
517
703
|
}
|
704
|
+
|
518
705
|
var scale = 255 / ((1 << bits) - 1);
|
519
706
|
var j = srcOffset,
|
520
707
|
q = destOffset;
|
708
|
+
|
521
709
|
for (var i = 0; i < count; ++i) {
|
522
|
-
dest[q++] = scale * src[j++]
|
523
|
-
dest[q++] = scale * src[j++]
|
524
|
-
dest[q++] = scale * src[j++]
|
710
|
+
dest[q++] = scale * src[j++];
|
711
|
+
dest[q++] = scale * src[j++];
|
712
|
+
dest[q++] = scale * src[j++];
|
525
713
|
q += alpha01;
|
526
714
|
}
|
527
|
-
}
|
528
|
-
|
715
|
+
}
|
716
|
+
}, {
|
717
|
+
key: "getOutputLength",
|
718
|
+
value: function getOutputLength(inputLength, alpha01) {
|
529
719
|
return inputLength * (3 + alpha01) / 3 | 0;
|
530
|
-
}
|
531
|
-
|
720
|
+
}
|
721
|
+
}, {
|
722
|
+
key: "isPassthrough",
|
723
|
+
value: function isPassthrough(bits) {
|
532
724
|
return bits === 8;
|
533
|
-
}
|
534
|
-
|
535
|
-
|
536
|
-
return ColorSpace.isDefaultDecode(decodeMap, this.numComps);
|
537
|
-
},
|
538
|
-
usesZeroToOneRange: true
|
539
|
-
};
|
725
|
+
}
|
726
|
+
}]);
|
727
|
+
|
540
728
|
return DeviceRgbCS;
|
541
|
-
}();
|
729
|
+
}(ColorSpace);
|
730
|
+
|
542
731
|
var DeviceCmykCS = function DeviceCmykCSClosure() {
|
543
732
|
function convertToRgb(src, srcOffset, srcScale, dest, destOffset) {
|
544
|
-
var c = src[srcOffset
|
733
|
+
var c = src[srcOffset] * srcScale;
|
545
734
|
var m = src[srcOffset + 1] * srcScale;
|
546
735
|
var y = src[srcOffset + 2] * srcScale;
|
547
736
|
var k = src[srcOffset + 3] * srcScale;
|
548
|
-
|
549
|
-
|
550
|
-
|
551
|
-
dest[destOffset] = r > 255 ? 255 : r < 0 ? 0 : r;
|
552
|
-
dest[destOffset + 1] = g > 255 ? 255 : g < 0 ? 0 : g;
|
553
|
-
dest[destOffset + 2] = b > 255 ? 255 : b < 0 ? 0 : b;
|
554
|
-
}
|
555
|
-
function DeviceCmykCS() {
|
556
|
-
this.name = 'DeviceCMYK';
|
557
|
-
this.numComps = 4;
|
558
|
-
this.defaultColor = new Float32Array(this.numComps);
|
559
|
-
this.defaultColor[3] = 1;
|
737
|
+
dest[destOffset] = 255 + c * (-4.387332384609988 * c + 54.48615194189176 * m + 18.82290502165302 * y + 212.25662451639585 * k + -285.2331026137004) + m * (1.7149763477362134 * m - 5.6096736904047315 * y + -17.873870861415444 * k - 5.497006427196366) + y * (-2.5217340131683033 * y - 21.248923337353073 * k + 17.5119270841813) + k * (-21.86122147463605 * k - 189.48180835922747);
|
738
|
+
dest[destOffset + 1] = 255 + c * (8.841041422036149 * c + 60.118027045597366 * m + 6.871425592049007 * y + 31.159100130055922 * k + -79.2970844816548) + m * (-15.310361306967817 * m + 17.575251261109482 * y + 131.35250912493976 * k - 190.9453302588951) + y * (4.444339102852739 * y + 9.8632861493405 * k - 24.86741582555878) + k * (-20.737325471181034 * k - 187.80453709719578);
|
739
|
+
dest[destOffset + 2] = 255 + c * (0.8842522430003296 * c + 8.078677503112928 * m + 30.89978309703729 * y - 0.23883238689178934 * k + -14.183576799673286) + m * (10.49593273432072 * m + 63.02378494754052 * y + 50.606957656360734 * k - 112.23884253719248) + y * (0.03296041114873217 * y + 115.60384449646641 * k + -193.58209356861505) + k * (-22.33816807309886 * k - 180.12613974708367);
|
560
740
|
}
|
561
|
-
|
562
|
-
|
563
|
-
|
564
|
-
|
565
|
-
|
566
|
-
|
567
|
-
|
568
|
-
|
569
|
-
|
570
|
-
|
571
|
-
|
572
|
-
|
573
|
-
|
574
|
-
|
575
|
-
|
576
|
-
|
577
|
-
|
578
|
-
|
579
|
-
|
580
|
-
|
581
|
-
|
582
|
-
|
583
|
-
|
741
|
+
|
742
|
+
var DeviceCmykCS =
|
743
|
+
/*#__PURE__*/
|
744
|
+
function (_ColorSpace6) {
|
745
|
+
_inherits(DeviceCmykCS, _ColorSpace6);
|
746
|
+
|
747
|
+
function DeviceCmykCS() {
|
748
|
+
_classCallCheck(this, DeviceCmykCS);
|
749
|
+
|
750
|
+
return _possibleConstructorReturn(this, _getPrototypeOf(DeviceCmykCS).call(this, 'DeviceCMYK', 4));
|
751
|
+
}
|
752
|
+
|
753
|
+
_createClass(DeviceCmykCS, [{
|
754
|
+
key: "getRgbItem",
|
755
|
+
value: function getRgbItem(src, srcOffset, dest, destOffset) {
|
756
|
+
convertToRgb(src, srcOffset, 1, dest, destOffset);
|
757
|
+
}
|
758
|
+
}, {
|
759
|
+
key: "getRgbBuffer",
|
760
|
+
value: function getRgbBuffer(src, srcOffset, count, dest, destOffset, bits, alpha01) {
|
761
|
+
var scale = 1 / ((1 << bits) - 1);
|
762
|
+
|
763
|
+
for (var i = 0; i < count; i++) {
|
764
|
+
convertToRgb(src, srcOffset, scale, dest, destOffset);
|
765
|
+
srcOffset += 4;
|
766
|
+
destOffset += 3 + alpha01;
|
767
|
+
}
|
768
|
+
}
|
769
|
+
}, {
|
770
|
+
key: "getOutputLength",
|
771
|
+
value: function getOutputLength(inputLength, alpha01) {
|
772
|
+
return inputLength / 4 * (3 + alpha01) | 0;
|
773
|
+
}
|
774
|
+
}]);
|
775
|
+
|
776
|
+
return DeviceCmykCS;
|
777
|
+
}(ColorSpace);
|
778
|
+
|
584
779
|
return DeviceCmykCS;
|
585
780
|
}();
|
781
|
+
|
586
782
|
var CalGrayCS = function CalGrayCSClosure() {
|
587
|
-
function CalGrayCS(whitePoint, blackPoint, gamma) {
|
588
|
-
this.name = 'CalGray';
|
589
|
-
this.numComps = 1;
|
590
|
-
this.defaultColor = new Float32Array(this.numComps);
|
591
|
-
if (!whitePoint) {
|
592
|
-
throw new _util.FormatError('WhitePoint missing - required for color space CalGray');
|
593
|
-
}
|
594
|
-
blackPoint = blackPoint || [0, 0, 0];
|
595
|
-
gamma = gamma || 1;
|
596
|
-
this.XW = whitePoint[0];
|
597
|
-
this.YW = whitePoint[1];
|
598
|
-
this.ZW = whitePoint[2];
|
599
|
-
this.XB = blackPoint[0];
|
600
|
-
this.YB = blackPoint[1];
|
601
|
-
this.ZB = blackPoint[2];
|
602
|
-
this.G = gamma;
|
603
|
-
if (this.XW < 0 || this.ZW < 0 || this.YW !== 1) {
|
604
|
-
throw new _util.FormatError('Invalid WhitePoint components for ' + this.name + ', no fallback available');
|
605
|
-
}
|
606
|
-
if (this.XB < 0 || this.YB < 0 || this.ZB < 0) {
|
607
|
-
(0, _util.info)('Invalid BlackPoint for ' + this.name + ', falling back to default');
|
608
|
-
this.XB = this.YB = this.ZB = 0;
|
609
|
-
}
|
610
|
-
if (this.XB !== 0 || this.YB !== 0 || this.ZB !== 0) {
|
611
|
-
(0, _util.warn)(this.name + ', BlackPoint: XB: ' + this.XB + ', YB: ' + this.YB + ', ZB: ' + this.ZB + ', only default values are supported.');
|
612
|
-
}
|
613
|
-
if (this.G < 1) {
|
614
|
-
(0, _util.info)('Invalid Gamma: ' + this.G + ' for ' + this.name + ', falling back to default');
|
615
|
-
this.G = 1;
|
616
|
-
}
|
617
|
-
}
|
618
783
|
function convertToRgb(cs, src, srcOffset, dest, destOffset, scale) {
|
619
784
|
var A = src[srcOffset] * scale;
|
620
785
|
var AG = Math.pow(A, cs.G);
|
621
786
|
var L = cs.YW * AG;
|
622
|
-
var val = Math.max(295.8 * Math.pow(L, 0.333333333333333333) - 40.8, 0)
|
787
|
+
var val = Math.max(295.8 * Math.pow(L, 0.333333333333333333) - 40.8, 0);
|
623
788
|
dest[destOffset] = val;
|
624
789
|
dest[destOffset + 1] = val;
|
625
790
|
dest[destOffset + 2] = val;
|
626
791
|
}
|
627
|
-
|
628
|
-
|
629
|
-
|
630
|
-
|
631
|
-
|
632
|
-
|
633
|
-
|
634
|
-
|
635
|
-
|
636
|
-
|
637
|
-
|
792
|
+
|
793
|
+
var CalGrayCS =
|
794
|
+
/*#__PURE__*/
|
795
|
+
function (_ColorSpace7) {
|
796
|
+
_inherits(CalGrayCS, _ColorSpace7);
|
797
|
+
|
798
|
+
function CalGrayCS(whitePoint, blackPoint, gamma) {
|
799
|
+
var _this4;
|
800
|
+
|
801
|
+
_classCallCheck(this, CalGrayCS);
|
802
|
+
|
803
|
+
_this4 = _possibleConstructorReturn(this, _getPrototypeOf(CalGrayCS).call(this, 'CalGray', 1));
|
804
|
+
|
805
|
+
if (!whitePoint) {
|
806
|
+
throw new _util.FormatError('WhitePoint missing - required for color space CalGray');
|
638
807
|
}
|
639
|
-
|
640
|
-
|
641
|
-
|
642
|
-
|
643
|
-
|
644
|
-
|
645
|
-
|
646
|
-
|
647
|
-
|
648
|
-
|
649
|
-
|
808
|
+
|
809
|
+
blackPoint = blackPoint || [0, 0, 0];
|
810
|
+
gamma = gamma || 1;
|
811
|
+
_this4.XW = whitePoint[0];
|
812
|
+
_this4.YW = whitePoint[1];
|
813
|
+
_this4.ZW = whitePoint[2];
|
814
|
+
_this4.XB = blackPoint[0];
|
815
|
+
_this4.YB = blackPoint[1];
|
816
|
+
_this4.ZB = blackPoint[2];
|
817
|
+
_this4.G = gamma;
|
818
|
+
|
819
|
+
if (_this4.XW < 0 || _this4.ZW < 0 || _this4.YW !== 1) {
|
820
|
+
throw new _util.FormatError("Invalid WhitePoint components for ".concat(_this4.name) + ', no fallback available');
|
821
|
+
}
|
822
|
+
|
823
|
+
if (_this4.XB < 0 || _this4.YB < 0 || _this4.ZB < 0) {
|
824
|
+
(0, _util.info)("Invalid BlackPoint for ".concat(_this4.name, ", falling back to default."));
|
825
|
+
_this4.XB = _this4.YB = _this4.ZB = 0;
|
826
|
+
}
|
827
|
+
|
828
|
+
if (_this4.XB !== 0 || _this4.YB !== 0 || _this4.ZB !== 0) {
|
829
|
+
(0, _util.warn)("".concat(_this4.name, ", BlackPoint: XB: ").concat(_this4.XB, ", YB: ").concat(_this4.YB, ", ") + "ZB: ".concat(_this4.ZB, ", only default values are supported."));
|
830
|
+
}
|
831
|
+
|
832
|
+
if (_this4.G < 1) {
|
833
|
+
(0, _util.info)("Invalid Gamma: ".concat(_this4.G, " for ").concat(_this4.name, ", ") + 'falling back to default.');
|
834
|
+
_this4.G = 1;
|
835
|
+
}
|
836
|
+
|
837
|
+
return _this4;
|
838
|
+
}
|
839
|
+
|
840
|
+
_createClass(CalGrayCS, [{
|
841
|
+
key: "getRgbItem",
|
842
|
+
value: function getRgbItem(src, srcOffset, dest, destOffset) {
|
843
|
+
convertToRgb(this, src, srcOffset, dest, destOffset, 1);
|
844
|
+
}
|
845
|
+
}, {
|
846
|
+
key: "getRgbBuffer",
|
847
|
+
value: function getRgbBuffer(src, srcOffset, count, dest, destOffset, bits, alpha01) {
|
848
|
+
var scale = 1 / ((1 << bits) - 1);
|
849
|
+
|
850
|
+
for (var i = 0; i < count; ++i) {
|
851
|
+
convertToRgb(this, src, srcOffset, dest, destOffset, scale);
|
852
|
+
srcOffset += 1;
|
853
|
+
destOffset += 3 + alpha01;
|
854
|
+
}
|
855
|
+
}
|
856
|
+
}, {
|
857
|
+
key: "getOutputLength",
|
858
|
+
value: function getOutputLength(inputLength, alpha01) {
|
859
|
+
return inputLength * (3 + alpha01);
|
860
|
+
}
|
861
|
+
}]);
|
862
|
+
|
863
|
+
return CalGrayCS;
|
864
|
+
}(ColorSpace);
|
865
|
+
|
650
866
|
return CalGrayCS;
|
651
867
|
}();
|
868
|
+
|
652
869
|
var CalRGBCS = function CalRGBCSClosure() {
|
653
870
|
var BRADFORD_SCALE_MATRIX = new Float32Array([0.8951, 0.2664, -0.1614, -0.7502, 1.7135, 0.0367, 0.0389, -0.0685, 1.0296]);
|
654
871
|
var BRADFORD_SCALE_INVERSE_MATRIX = new Float32Array([0.9869929, -0.1470543, 0.1599627, 0.4323053, 0.5183603, 0.0492912, -0.0085287, 0.0400428, 0.9684867]);
|
@@ -658,63 +875,19 @@ var CalRGBCS = function CalRGBCSClosure() {
|
|
658
875
|
var tempConvertMatrix1 = new Float32Array(3);
|
659
876
|
var tempConvertMatrix2 = new Float32Array(3);
|
660
877
|
var DECODE_L_CONSTANT = Math.pow((8 + 16) / 116, 3) / 8.0;
|
661
|
-
|
662
|
-
this.name = 'CalRGB';
|
663
|
-
this.numComps = 3;
|
664
|
-
this.defaultColor = new Float32Array(this.numComps);
|
665
|
-
if (!whitePoint) {
|
666
|
-
throw new _util.FormatError('WhitePoint missing - required for color space CalRGB');
|
667
|
-
}
|
668
|
-
blackPoint = blackPoint || new Float32Array(3);
|
669
|
-
gamma = gamma || new Float32Array([1, 1, 1]);
|
670
|
-
matrix = matrix || new Float32Array([1, 0, 0, 0, 1, 0, 0, 0, 1]);
|
671
|
-
var XW = whitePoint[0];
|
672
|
-
var YW = whitePoint[1];
|
673
|
-
var ZW = whitePoint[2];
|
674
|
-
this.whitePoint = whitePoint;
|
675
|
-
var XB = blackPoint[0];
|
676
|
-
var YB = blackPoint[1];
|
677
|
-
var ZB = blackPoint[2];
|
678
|
-
this.blackPoint = blackPoint;
|
679
|
-
this.GR = gamma[0];
|
680
|
-
this.GG = gamma[1];
|
681
|
-
this.GB = gamma[2];
|
682
|
-
this.MXA = matrix[0];
|
683
|
-
this.MYA = matrix[1];
|
684
|
-
this.MZA = matrix[2];
|
685
|
-
this.MXB = matrix[3];
|
686
|
-
this.MYB = matrix[4];
|
687
|
-
this.MZB = matrix[5];
|
688
|
-
this.MXC = matrix[6];
|
689
|
-
this.MYC = matrix[7];
|
690
|
-
this.MZC = matrix[8];
|
691
|
-
if (XW < 0 || ZW < 0 || YW !== 1) {
|
692
|
-
throw new _util.FormatError('Invalid WhitePoint components for ' + this.name + ', no fallback available');
|
693
|
-
}
|
694
|
-
if (XB < 0 || YB < 0 || ZB < 0) {
|
695
|
-
(0, _util.info)('Invalid BlackPoint for ' + this.name + ' [' + XB + ', ' + YB + ', ' + ZB + '], falling back to default');
|
696
|
-
this.blackPoint = new Float32Array(3);
|
697
|
-
}
|
698
|
-
if (this.GR < 0 || this.GG < 0 || this.GB < 0) {
|
699
|
-
(0, _util.info)('Invalid Gamma [' + this.GR + ', ' + this.GG + ', ' + this.GB + '] for ' + this.name + ', falling back to default');
|
700
|
-
this.GR = this.GG = this.GB = 1;
|
701
|
-
}
|
702
|
-
if (this.MXA < 0 || this.MYA < 0 || this.MZA < 0 || this.MXB < 0 || this.MYB < 0 || this.MZB < 0 || this.MXC < 0 || this.MYC < 0 || this.MZC < 0) {
|
703
|
-
(0, _util.info)('Invalid Matrix for ' + this.name + ' [' + this.MXA + ', ' + this.MYA + ', ' + this.MZA + this.MXB + ', ' + this.MYB + ', ' + this.MZB + this.MXC + ', ' + this.MYC + ', ' + this.MZC + '], falling back to default');
|
704
|
-
this.MXA = this.MYB = this.MZC = 1;
|
705
|
-
this.MXB = this.MYA = this.MZA = this.MXC = this.MYC = this.MZB = 0;
|
706
|
-
}
|
707
|
-
}
|
878
|
+
|
708
879
|
function matrixProduct(a, b, result) {
|
709
880
|
result[0] = a[0] * b[0] + a[1] * b[1] + a[2] * b[2];
|
710
881
|
result[1] = a[3] * b[0] + a[4] * b[1] + a[5] * b[2];
|
711
882
|
result[2] = a[6] * b[0] + a[7] * b[1] + a[8] * b[2];
|
712
883
|
}
|
884
|
+
|
713
885
|
function convertToFlat(sourceWhitePoint, LMS, result) {
|
714
886
|
result[0] = LMS[0] * 1 / sourceWhitePoint[0];
|
715
887
|
result[1] = LMS[1] * 1 / sourceWhitePoint[1];
|
716
888
|
result[2] = LMS[2] * 1 / sourceWhitePoint[2];
|
717
889
|
}
|
890
|
+
|
718
891
|
function convertToD65(sourceWhitePoint, LMS, result) {
|
719
892
|
var D65X = 0.95047;
|
720
893
|
var D65Y = 1;
|
@@ -723,24 +896,31 @@ var CalRGBCS = function CalRGBCSClosure() {
|
|
723
896
|
result[1] = LMS[1] * D65Y / sourceWhitePoint[1];
|
724
897
|
result[2] = LMS[2] * D65Z / sourceWhitePoint[2];
|
725
898
|
}
|
899
|
+
|
726
900
|
function sRGBTransferFunction(color) {
|
727
901
|
if (color <= 0.0031308) {
|
728
902
|
return adjustToRange(0, 1, 12.92 * color);
|
729
903
|
}
|
904
|
+
|
730
905
|
return adjustToRange(0, 1, (1 + 0.055) * Math.pow(color, 1 / 2.4) - 0.055);
|
731
906
|
}
|
907
|
+
|
732
908
|
function adjustToRange(min, max, value) {
|
733
909
|
return Math.max(min, Math.min(max, value));
|
734
910
|
}
|
911
|
+
|
735
912
|
function decodeL(L) {
|
736
913
|
if (L < 0) {
|
737
914
|
return -decodeL(-L);
|
738
915
|
}
|
916
|
+
|
739
917
|
if (L > 8.0) {
|
740
918
|
return Math.pow((L + 16) / 116, 3);
|
741
919
|
}
|
920
|
+
|
742
921
|
return L * DECODE_L_CONSTANT;
|
743
922
|
}
|
923
|
+
|
744
924
|
function compensateBlackPoint(sourceBlackPoint, XYZ_Flat, result) {
|
745
925
|
if (sourceBlackPoint[0] === 0 && sourceBlackPoint[1] === 0 && sourceBlackPoint[2] === 0) {
|
746
926
|
result[0] = XYZ_Flat[0];
|
@@ -748,6 +928,7 @@ var CalRGBCS = function CalRGBCSClosure() {
|
|
748
928
|
result[2] = XYZ_Flat[2];
|
749
929
|
return;
|
750
930
|
}
|
931
|
+
|
751
932
|
var zeroDecodeL = decodeL(0);
|
752
933
|
var X_DST = zeroDecodeL;
|
753
934
|
var X_SRC = decodeL(sourceBlackPoint[0]);
|
@@ -765,6 +946,7 @@ var CalRGBCS = function CalRGBCSClosure() {
|
|
765
946
|
result[1] = XYZ_Flat[1] * Y_Scale + Y_Offset;
|
766
947
|
result[2] = XYZ_Flat[2] * Z_Scale + Z_Offset;
|
767
948
|
}
|
949
|
+
|
768
950
|
function normalizeWhitePointToFlat(sourceWhitePoint, XYZ_In, result) {
|
769
951
|
if (sourceWhitePoint[0] === 1 && sourceWhitePoint[2] === 1) {
|
770
952
|
result[0] = XYZ_In[0];
|
@@ -772,12 +954,14 @@ var CalRGBCS = function CalRGBCSClosure() {
|
|
772
954
|
result[2] = XYZ_In[2];
|
773
955
|
return;
|
774
956
|
}
|
957
|
+
|
775
958
|
var LMS = result;
|
776
959
|
matrixProduct(BRADFORD_SCALE_MATRIX, XYZ_In, LMS);
|
777
960
|
var LMS_Flat = tempNormalizeMatrix;
|
778
961
|
convertToFlat(sourceWhitePoint, LMS, LMS_Flat);
|
779
962
|
matrixProduct(BRADFORD_SCALE_INVERSE_MATRIX, LMS_Flat, result);
|
780
963
|
}
|
964
|
+
|
781
965
|
function normalizeWhitePointToD65(sourceWhitePoint, XYZ_In, result) {
|
782
966
|
var LMS = result;
|
783
967
|
matrixProduct(BRADFORD_SCALE_MATRIX, XYZ_In, LMS);
|
@@ -785,6 +969,7 @@ var CalRGBCS = function CalRGBCSClosure() {
|
|
785
969
|
convertToD65(sourceWhitePoint, LMS, LMS_D65);
|
786
970
|
matrixProduct(BRADFORD_SCALE_INVERSE_MATRIX, LMS_D65, result);
|
787
971
|
}
|
972
|
+
|
788
973
|
function convertToRgb(cs, src, srcOffset, dest, destOffset, scale) {
|
789
974
|
var A = adjustToRange(0, 1, src[srcOffset] * scale);
|
790
975
|
var B = adjustToRange(0, 1, src[srcOffset + 1] * scale);
|
@@ -807,94 +992,125 @@ var CalRGBCS = function CalRGBCSClosure() {
|
|
807
992
|
normalizeWhitePointToD65(FLAT_WHITEPOINT_MATRIX, XYZ_Black, XYZ_D65);
|
808
993
|
var SRGB = tempConvertMatrix1;
|
809
994
|
matrixProduct(SRGB_D65_XYZ_TO_RGB_MATRIX, XYZ_D65, SRGB);
|
810
|
-
|
811
|
-
|
812
|
-
|
813
|
-
dest[destOffset] = Math.round(sR * 255);
|
814
|
-
dest[destOffset + 1] = Math.round(sG * 255);
|
815
|
-
dest[destOffset + 2] = Math.round(sB * 255);
|
995
|
+
dest[destOffset] = sRGBTransferFunction(SRGB[0]) * 255;
|
996
|
+
dest[destOffset + 1] = sRGBTransferFunction(SRGB[1]) * 255;
|
997
|
+
dest[destOffset + 2] = sRGBTransferFunction(SRGB[2]) * 255;
|
816
998
|
}
|
817
|
-
|
818
|
-
|
819
|
-
|
820
|
-
|
821
|
-
|
822
|
-
|
823
|
-
|
824
|
-
|
825
|
-
|
826
|
-
|
827
|
-
|
999
|
+
|
1000
|
+
var CalRGBCS =
|
1001
|
+
/*#__PURE__*/
|
1002
|
+
function (_ColorSpace8) {
|
1003
|
+
_inherits(CalRGBCS, _ColorSpace8);
|
1004
|
+
|
1005
|
+
function CalRGBCS(whitePoint, blackPoint, gamma, matrix) {
|
1006
|
+
var _this5;
|
1007
|
+
|
1008
|
+
_classCallCheck(this, CalRGBCS);
|
1009
|
+
|
1010
|
+
_this5 = _possibleConstructorReturn(this, _getPrototypeOf(CalRGBCS).call(this, 'CalRGB', 3));
|
1011
|
+
|
1012
|
+
if (!whitePoint) {
|
1013
|
+
throw new _util.FormatError('WhitePoint missing - required for color space CalRGB');
|
828
1014
|
}
|
829
|
-
|
830
|
-
|
831
|
-
|
832
|
-
|
833
|
-
|
834
|
-
|
835
|
-
|
836
|
-
|
837
|
-
|
838
|
-
|
839
|
-
|
1015
|
+
|
1016
|
+
blackPoint = blackPoint || new Float32Array(3);
|
1017
|
+
gamma = gamma || new Float32Array([1, 1, 1]);
|
1018
|
+
matrix = matrix || new Float32Array([1, 0, 0, 0, 1, 0, 0, 0, 1]);
|
1019
|
+
var XW = whitePoint[0];
|
1020
|
+
var YW = whitePoint[1];
|
1021
|
+
var ZW = whitePoint[2];
|
1022
|
+
_this5.whitePoint = whitePoint;
|
1023
|
+
var XB = blackPoint[0];
|
1024
|
+
var YB = blackPoint[1];
|
1025
|
+
var ZB = blackPoint[2];
|
1026
|
+
_this5.blackPoint = blackPoint;
|
1027
|
+
_this5.GR = gamma[0];
|
1028
|
+
_this5.GG = gamma[1];
|
1029
|
+
_this5.GB = gamma[2];
|
1030
|
+
_this5.MXA = matrix[0];
|
1031
|
+
_this5.MYA = matrix[1];
|
1032
|
+
_this5.MZA = matrix[2];
|
1033
|
+
_this5.MXB = matrix[3];
|
1034
|
+
_this5.MYB = matrix[4];
|
1035
|
+
_this5.MZB = matrix[5];
|
1036
|
+
_this5.MXC = matrix[6];
|
1037
|
+
_this5.MYC = matrix[7];
|
1038
|
+
_this5.MZC = matrix[8];
|
1039
|
+
|
1040
|
+
if (XW < 0 || ZW < 0 || YW !== 1) {
|
1041
|
+
throw new _util.FormatError("Invalid WhitePoint components for ".concat(_this5.name) + ', no fallback available');
|
1042
|
+
}
|
1043
|
+
|
1044
|
+
if (XB < 0 || YB < 0 || ZB < 0) {
|
1045
|
+
(0, _util.info)("Invalid BlackPoint for ".concat(_this5.name, " [").concat(XB, ", ").concat(YB, ", ").concat(ZB, "], ") + 'falling back to default.');
|
1046
|
+
_this5.blackPoint = new Float32Array(3);
|
1047
|
+
}
|
1048
|
+
|
1049
|
+
if (_this5.GR < 0 || _this5.GG < 0 || _this5.GB < 0) {
|
1050
|
+
(0, _util.info)("Invalid Gamma [".concat(_this5.GR, ", ").concat(_this5.GG, ", ").concat(_this5.GB, "] for ") + "".concat(_this5.name, ", falling back to default."));
|
1051
|
+
_this5.GR = _this5.GG = _this5.GB = 1;
|
1052
|
+
}
|
1053
|
+
|
1054
|
+
return _this5;
|
1055
|
+
}
|
1056
|
+
|
1057
|
+
_createClass(CalRGBCS, [{
|
1058
|
+
key: "getRgbItem",
|
1059
|
+
value: function getRgbItem(src, srcOffset, dest, destOffset) {
|
1060
|
+
convertToRgb(this, src, srcOffset, dest, destOffset, 1);
|
1061
|
+
}
|
1062
|
+
}, {
|
1063
|
+
key: "getRgbBuffer",
|
1064
|
+
value: function getRgbBuffer(src, srcOffset, count, dest, destOffset, bits, alpha01) {
|
1065
|
+
var scale = 1 / ((1 << bits) - 1);
|
1066
|
+
|
1067
|
+
for (var i = 0; i < count; ++i) {
|
1068
|
+
convertToRgb(this, src, srcOffset, dest, destOffset, scale);
|
1069
|
+
srcOffset += 3;
|
1070
|
+
destOffset += 3 + alpha01;
|
1071
|
+
}
|
1072
|
+
}
|
1073
|
+
}, {
|
1074
|
+
key: "getOutputLength",
|
1075
|
+
value: function getOutputLength(inputLength, alpha01) {
|
1076
|
+
return inputLength * (3 + alpha01) / 3 | 0;
|
1077
|
+
}
|
1078
|
+
}]);
|
1079
|
+
|
1080
|
+
return CalRGBCS;
|
1081
|
+
}(ColorSpace);
|
1082
|
+
|
840
1083
|
return CalRGBCS;
|
841
1084
|
}();
|
1085
|
+
|
842
1086
|
var LabCS = function LabCSClosure() {
|
843
|
-
function LabCS(whitePoint, blackPoint, range) {
|
844
|
-
this.name = 'Lab';
|
845
|
-
this.numComps = 3;
|
846
|
-
this.defaultColor = new Float32Array(this.numComps);
|
847
|
-
if (!whitePoint) {
|
848
|
-
throw new _util.FormatError('WhitePoint missing - required for color space Lab');
|
849
|
-
}
|
850
|
-
blackPoint = blackPoint || [0, 0, 0];
|
851
|
-
range = range || [-100, 100, -100, 100];
|
852
|
-
this.XW = whitePoint[0];
|
853
|
-
this.YW = whitePoint[1];
|
854
|
-
this.ZW = whitePoint[2];
|
855
|
-
this.amin = range[0];
|
856
|
-
this.amax = range[1];
|
857
|
-
this.bmin = range[2];
|
858
|
-
this.bmax = range[3];
|
859
|
-
this.XB = blackPoint[0];
|
860
|
-
this.YB = blackPoint[1];
|
861
|
-
this.ZB = blackPoint[2];
|
862
|
-
if (this.XW < 0 || this.ZW < 0 || this.YW !== 1) {
|
863
|
-
throw new _util.FormatError('Invalid WhitePoint components, no fallback available');
|
864
|
-
}
|
865
|
-
if (this.XB < 0 || this.YB < 0 || this.ZB < 0) {
|
866
|
-
(0, _util.info)('Invalid BlackPoint, falling back to default');
|
867
|
-
this.XB = this.YB = this.ZB = 0;
|
868
|
-
}
|
869
|
-
if (this.amin > this.amax || this.bmin > this.bmax) {
|
870
|
-
(0, _util.info)('Invalid Range, falling back to defaults');
|
871
|
-
this.amin = -100;
|
872
|
-
this.amax = 100;
|
873
|
-
this.bmin = -100;
|
874
|
-
this.bmax = 100;
|
875
|
-
}
|
876
|
-
}
|
877
1087
|
function fn_g(x) {
|
878
1088
|
var result;
|
1089
|
+
|
879
1090
|
if (x >= 6 / 29) {
|
880
1091
|
result = x * x * x;
|
881
1092
|
} else {
|
882
1093
|
result = 108 / 841 * (x - 4 / 29);
|
883
1094
|
}
|
1095
|
+
|
884
1096
|
return result;
|
885
1097
|
}
|
1098
|
+
|
886
1099
|
function decode(value, high1, low2, high2) {
|
887
1100
|
return low2 + value * (high2 - low2) / high1;
|
888
1101
|
}
|
1102
|
+
|
889
1103
|
function convertToRgb(cs, src, srcOffset, maxVal, dest, destOffset) {
|
890
1104
|
var Ls = src[srcOffset];
|
891
1105
|
var as = src[srcOffset + 1];
|
892
1106
|
var bs = src[srcOffset + 2];
|
1107
|
+
|
893
1108
|
if (maxVal !== false) {
|
894
1109
|
Ls = decode(Ls, maxVal, 0, 100);
|
895
1110
|
as = decode(as, maxVal, cs.amin, cs.amax);
|
896
1111
|
bs = decode(bs, maxVal, cs.bmin, cs.bmax);
|
897
1112
|
}
|
1113
|
+
|
898
1114
|
as = as > cs.amax ? cs.amax : as < cs.amin ? cs.amin : as;
|
899
1115
|
bs = bs > cs.bmax ? cs.bmax : bs < cs.bmin ? cs.bmin : bs;
|
900
1116
|
var M = (Ls + 16) / 116;
|
@@ -904,6 +1120,7 @@ var LabCS = function LabCSClosure() {
|
|
904
1120
|
var Y = cs.YW * fn_g(M);
|
905
1121
|
var Z = cs.ZW * fn_g(N);
|
906
1122
|
var r, g, b;
|
1123
|
+
|
907
1124
|
if (cs.ZW < 1) {
|
908
1125
|
r = X * 3.1339 + Y * -1.6170 + Z * -0.4906;
|
909
1126
|
g = X * -0.9785 + Y * 1.9160 + Z * 0.0333;
|
@@ -913,33 +1130,96 @@ var LabCS = function LabCSClosure() {
|
|
913
1130
|
g = X * -0.9689 + Y * 1.8758 + Z * 0.0415;
|
914
1131
|
b = X * 0.0557 + Y * -0.2040 + Z * 1.0570;
|
915
1132
|
}
|
916
|
-
|
917
|
-
dest[destOffset
|
918
|
-
dest[destOffset +
|
1133
|
+
|
1134
|
+
dest[destOffset] = Math.sqrt(r) * 255;
|
1135
|
+
dest[destOffset + 1] = Math.sqrt(g) * 255;
|
1136
|
+
dest[destOffset + 2] = Math.sqrt(b) * 255;
|
919
1137
|
}
|
920
|
-
|
921
|
-
|
922
|
-
|
923
|
-
|
924
|
-
|
925
|
-
|
926
|
-
|
927
|
-
|
928
|
-
|
929
|
-
|
930
|
-
|
931
|
-
|
932
|
-
|
933
|
-
|
934
|
-
|
935
|
-
|
936
|
-
|
937
|
-
|
938
|
-
|
939
|
-
|
940
|
-
|
941
|
-
|
942
|
-
|
1138
|
+
|
1139
|
+
var LabCS =
|
1140
|
+
/*#__PURE__*/
|
1141
|
+
function (_ColorSpace9) {
|
1142
|
+
_inherits(LabCS, _ColorSpace9);
|
1143
|
+
|
1144
|
+
function LabCS(whitePoint, blackPoint, range) {
|
1145
|
+
var _this6;
|
1146
|
+
|
1147
|
+
_classCallCheck(this, LabCS);
|
1148
|
+
|
1149
|
+
_this6 = _possibleConstructorReturn(this, _getPrototypeOf(LabCS).call(this, 'Lab', 3));
|
1150
|
+
|
1151
|
+
if (!whitePoint) {
|
1152
|
+
throw new _util.FormatError('WhitePoint missing - required for color space Lab');
|
1153
|
+
}
|
1154
|
+
|
1155
|
+
blackPoint = blackPoint || [0, 0, 0];
|
1156
|
+
range = range || [-100, 100, -100, 100];
|
1157
|
+
_this6.XW = whitePoint[0];
|
1158
|
+
_this6.YW = whitePoint[1];
|
1159
|
+
_this6.ZW = whitePoint[2];
|
1160
|
+
_this6.amin = range[0];
|
1161
|
+
_this6.amax = range[1];
|
1162
|
+
_this6.bmin = range[2];
|
1163
|
+
_this6.bmax = range[3];
|
1164
|
+
_this6.XB = blackPoint[0];
|
1165
|
+
_this6.YB = blackPoint[1];
|
1166
|
+
_this6.ZB = blackPoint[2];
|
1167
|
+
|
1168
|
+
if (_this6.XW < 0 || _this6.ZW < 0 || _this6.YW !== 1) {
|
1169
|
+
throw new _util.FormatError('Invalid WhitePoint components, no fallback available');
|
1170
|
+
}
|
1171
|
+
|
1172
|
+
if (_this6.XB < 0 || _this6.YB < 0 || _this6.ZB < 0) {
|
1173
|
+
(0, _util.info)('Invalid BlackPoint, falling back to default');
|
1174
|
+
_this6.XB = _this6.YB = _this6.ZB = 0;
|
1175
|
+
}
|
1176
|
+
|
1177
|
+
if (_this6.amin > _this6.amax || _this6.bmin > _this6.bmax) {
|
1178
|
+
(0, _util.info)('Invalid Range, falling back to defaults');
|
1179
|
+
_this6.amin = -100;
|
1180
|
+
_this6.amax = 100;
|
1181
|
+
_this6.bmin = -100;
|
1182
|
+
_this6.bmax = 100;
|
1183
|
+
}
|
1184
|
+
|
1185
|
+
return _this6;
|
1186
|
+
}
|
1187
|
+
|
1188
|
+
_createClass(LabCS, [{
|
1189
|
+
key: "getRgbItem",
|
1190
|
+
value: function getRgbItem(src, srcOffset, dest, destOffset) {
|
1191
|
+
convertToRgb(this, src, srcOffset, false, dest, destOffset);
|
1192
|
+
}
|
1193
|
+
}, {
|
1194
|
+
key: "getRgbBuffer",
|
1195
|
+
value: function getRgbBuffer(src, srcOffset, count, dest, destOffset, bits, alpha01) {
|
1196
|
+
var maxVal = (1 << bits) - 1;
|
1197
|
+
|
1198
|
+
for (var i = 0; i < count; i++) {
|
1199
|
+
convertToRgb(this, src, srcOffset, maxVal, dest, destOffset);
|
1200
|
+
srcOffset += 3;
|
1201
|
+
destOffset += 3 + alpha01;
|
1202
|
+
}
|
1203
|
+
}
|
1204
|
+
}, {
|
1205
|
+
key: "getOutputLength",
|
1206
|
+
value: function getOutputLength(inputLength, alpha01) {
|
1207
|
+
return inputLength * (3 + alpha01) / 3 | 0;
|
1208
|
+
}
|
1209
|
+
}, {
|
1210
|
+
key: "isDefaultDecode",
|
1211
|
+
value: function isDefaultDecode(decodeMap, bpc) {
|
1212
|
+
return true;
|
1213
|
+
}
|
1214
|
+
}, {
|
1215
|
+
key: "usesZeroToOneRange",
|
1216
|
+
get: function get() {
|
1217
|
+
return (0, _util.shadow)(this, 'usesZeroToOneRange', false);
|
1218
|
+
}
|
1219
|
+
}]);
|
1220
|
+
|
1221
|
+
return LabCS;
|
1222
|
+
}(ColorSpace);
|
1223
|
+
|
943
1224
|
return LabCS;
|
944
|
-
}();
|
945
|
-
exports.ColorSpace = ColorSpace;
|
1225
|
+
}();
|