emf-converter 4.18.2 → 4.20.0
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.
- package/README.md +42 -10
- package/dist/browser.js +849 -24
- package/dist/browser.mjs +849 -25
- package/dist/index.d.mts +57 -6
- package/dist/index.d.ts +57 -6
- package/dist/index.js +849 -24
- package/dist/index.mjs +849 -25
- package/package.json +4 -2
package/dist/browser.js
CHANGED
|
@@ -46,7 +46,7 @@ var require_encoder = __commonJS({
|
|
|
46
46
|
var YAC_HT;
|
|
47
47
|
var UVAC_HT;
|
|
48
48
|
var bitcode = new Array(65535);
|
|
49
|
-
var
|
|
49
|
+
var category2 = new Array(65535);
|
|
50
50
|
var outputfDCTQuant = new Array(64);
|
|
51
51
|
var DU = new Array(64);
|
|
52
52
|
var byteout = [];
|
|
@@ -655,13 +655,13 @@ var require_encoder = __commonJS({
|
|
|
655
655
|
var nrupper = 2;
|
|
656
656
|
for (var cat = 1; cat <= 15; cat++) {
|
|
657
657
|
for (var nr = nrlower; nr < nrupper; nr++) {
|
|
658
|
-
|
|
658
|
+
category2[32767 + nr] = cat;
|
|
659
659
|
bitcode[32767 + nr] = [];
|
|
660
660
|
bitcode[32767 + nr][1] = cat;
|
|
661
661
|
bitcode[32767 + nr][0] = nr;
|
|
662
662
|
}
|
|
663
663
|
for (var nrneg = -(nrupper - 1); nrneg <= -nrlower; nrneg++) {
|
|
664
|
-
|
|
664
|
+
category2[32767 + nrneg] = cat;
|
|
665
665
|
bitcode[32767 + nrneg] = [];
|
|
666
666
|
bitcode[32767 + nrneg][1] = cat;
|
|
667
667
|
bitcode[32767 + nrneg][0] = nrupper - 1 + nrneg;
|
|
@@ -943,7 +943,7 @@ var require_encoder = __commonJS({
|
|
|
943
943
|
writeBits(HTDC[0]);
|
|
944
944
|
} else {
|
|
945
945
|
pos = 32767 + Diff;
|
|
946
|
-
writeBits(HTDC[
|
|
946
|
+
writeBits(HTDC[category2[pos]]);
|
|
947
947
|
writeBits(bitcode[pos]);
|
|
948
948
|
}
|
|
949
949
|
var end0pos = 63;
|
|
@@ -967,7 +967,7 @@ var require_encoder = __commonJS({
|
|
|
967
967
|
nrzeroes = nrzeroes & 15;
|
|
968
968
|
}
|
|
969
969
|
pos = 32767 + DU[i];
|
|
970
|
-
writeBits(HTAC[(nrzeroes << 4) +
|
|
970
|
+
writeBits(HTAC[(nrzeroes << 4) + category2[pos]]);
|
|
971
971
|
writeBits(bitcode[pos]);
|
|
972
972
|
i++;
|
|
973
973
|
}
|
|
@@ -24852,6 +24852,7 @@ function drawNestedMetafile(rCtx, img, cached, source) {
|
|
|
24852
24852
|
imageCache: caches?.images,
|
|
24853
24853
|
fontFamilyMap: rCtx.fontFamilyMap,
|
|
24854
24854
|
gdiAntialias: rCtx.gdiAntialias,
|
|
24855
|
+
codePages: rCtx.codePages,
|
|
24855
24856
|
nestingDepth: depth + 1
|
|
24856
24857
|
});
|
|
24857
24858
|
} finally {
|
|
@@ -24935,6 +24936,752 @@ function drawEmfPlusImageNow(rCtx, img, draw, source, effect = null) {
|
|
|
24935
24936
|
return bitmap ? paintBitmapRaster(rCtx.ctx, bitmap, draw) : false;
|
|
24936
24937
|
}
|
|
24937
24938
|
|
|
24939
|
+
// src/jpeg-encoder.ts
|
|
24940
|
+
var DEFAULT_JPEG_QUALITY = 0.92;
|
|
24941
|
+
var ZIGZAG2 = [
|
|
24942
|
+
0,
|
|
24943
|
+
1,
|
|
24944
|
+
8,
|
|
24945
|
+
16,
|
|
24946
|
+
9,
|
|
24947
|
+
2,
|
|
24948
|
+
3,
|
|
24949
|
+
10,
|
|
24950
|
+
17,
|
|
24951
|
+
24,
|
|
24952
|
+
32,
|
|
24953
|
+
25,
|
|
24954
|
+
18,
|
|
24955
|
+
11,
|
|
24956
|
+
4,
|
|
24957
|
+
5,
|
|
24958
|
+
12,
|
|
24959
|
+
19,
|
|
24960
|
+
26,
|
|
24961
|
+
33,
|
|
24962
|
+
40,
|
|
24963
|
+
48,
|
|
24964
|
+
41,
|
|
24965
|
+
34,
|
|
24966
|
+
27,
|
|
24967
|
+
20,
|
|
24968
|
+
13,
|
|
24969
|
+
6,
|
|
24970
|
+
7,
|
|
24971
|
+
14,
|
|
24972
|
+
21,
|
|
24973
|
+
28,
|
|
24974
|
+
35,
|
|
24975
|
+
42,
|
|
24976
|
+
49,
|
|
24977
|
+
56,
|
|
24978
|
+
57,
|
|
24979
|
+
50,
|
|
24980
|
+
43,
|
|
24981
|
+
36,
|
|
24982
|
+
29,
|
|
24983
|
+
22,
|
|
24984
|
+
15,
|
|
24985
|
+
23,
|
|
24986
|
+
30,
|
|
24987
|
+
37,
|
|
24988
|
+
44,
|
|
24989
|
+
51,
|
|
24990
|
+
58,
|
|
24991
|
+
59,
|
|
24992
|
+
52,
|
|
24993
|
+
45,
|
|
24994
|
+
38,
|
|
24995
|
+
31,
|
|
24996
|
+
39,
|
|
24997
|
+
46,
|
|
24998
|
+
53,
|
|
24999
|
+
60,
|
|
25000
|
+
61,
|
|
25001
|
+
54,
|
|
25002
|
+
47,
|
|
25003
|
+
55,
|
|
25004
|
+
62,
|
|
25005
|
+
63
|
|
25006
|
+
];
|
|
25007
|
+
var LUMA_QUANT = [
|
|
25008
|
+
16,
|
|
25009
|
+
11,
|
|
25010
|
+
10,
|
|
25011
|
+
16,
|
|
25012
|
+
24,
|
|
25013
|
+
40,
|
|
25014
|
+
51,
|
|
25015
|
+
61,
|
|
25016
|
+
12,
|
|
25017
|
+
12,
|
|
25018
|
+
14,
|
|
25019
|
+
19,
|
|
25020
|
+
26,
|
|
25021
|
+
58,
|
|
25022
|
+
60,
|
|
25023
|
+
55,
|
|
25024
|
+
14,
|
|
25025
|
+
13,
|
|
25026
|
+
16,
|
|
25027
|
+
24,
|
|
25028
|
+
40,
|
|
25029
|
+
57,
|
|
25030
|
+
69,
|
|
25031
|
+
56,
|
|
25032
|
+
14,
|
|
25033
|
+
17,
|
|
25034
|
+
22,
|
|
25035
|
+
29,
|
|
25036
|
+
51,
|
|
25037
|
+
87,
|
|
25038
|
+
80,
|
|
25039
|
+
62,
|
|
25040
|
+
18,
|
|
25041
|
+
22,
|
|
25042
|
+
37,
|
|
25043
|
+
56,
|
|
25044
|
+
68,
|
|
25045
|
+
109,
|
|
25046
|
+
103,
|
|
25047
|
+
77,
|
|
25048
|
+
24,
|
|
25049
|
+
35,
|
|
25050
|
+
55,
|
|
25051
|
+
64,
|
|
25052
|
+
81,
|
|
25053
|
+
104,
|
|
25054
|
+
113,
|
|
25055
|
+
92,
|
|
25056
|
+
49,
|
|
25057
|
+
64,
|
|
25058
|
+
78,
|
|
25059
|
+
87,
|
|
25060
|
+
103,
|
|
25061
|
+
121,
|
|
25062
|
+
120,
|
|
25063
|
+
101,
|
|
25064
|
+
72,
|
|
25065
|
+
92,
|
|
25066
|
+
95,
|
|
25067
|
+
98,
|
|
25068
|
+
112,
|
|
25069
|
+
100,
|
|
25070
|
+
103,
|
|
25071
|
+
99
|
|
25072
|
+
];
|
|
25073
|
+
var CHROMA_QUANT = [
|
|
25074
|
+
17,
|
|
25075
|
+
18,
|
|
25076
|
+
24,
|
|
25077
|
+
47,
|
|
25078
|
+
99,
|
|
25079
|
+
99,
|
|
25080
|
+
99,
|
|
25081
|
+
99,
|
|
25082
|
+
18,
|
|
25083
|
+
21,
|
|
25084
|
+
26,
|
|
25085
|
+
66,
|
|
25086
|
+
99,
|
|
25087
|
+
99,
|
|
25088
|
+
99,
|
|
25089
|
+
99,
|
|
25090
|
+
24,
|
|
25091
|
+
26,
|
|
25092
|
+
56,
|
|
25093
|
+
99,
|
|
25094
|
+
99,
|
|
25095
|
+
99,
|
|
25096
|
+
99,
|
|
25097
|
+
99,
|
|
25098
|
+
47,
|
|
25099
|
+
66,
|
|
25100
|
+
99,
|
|
25101
|
+
99,
|
|
25102
|
+
99,
|
|
25103
|
+
99,
|
|
25104
|
+
99,
|
|
25105
|
+
99,
|
|
25106
|
+
99,
|
|
25107
|
+
99,
|
|
25108
|
+
99,
|
|
25109
|
+
99,
|
|
25110
|
+
99,
|
|
25111
|
+
99,
|
|
25112
|
+
99,
|
|
25113
|
+
99,
|
|
25114
|
+
99,
|
|
25115
|
+
99,
|
|
25116
|
+
99,
|
|
25117
|
+
99,
|
|
25118
|
+
99,
|
|
25119
|
+
99,
|
|
25120
|
+
99,
|
|
25121
|
+
99,
|
|
25122
|
+
99,
|
|
25123
|
+
99,
|
|
25124
|
+
99,
|
|
25125
|
+
99,
|
|
25126
|
+
99,
|
|
25127
|
+
99,
|
|
25128
|
+
99,
|
|
25129
|
+
99,
|
|
25130
|
+
99,
|
|
25131
|
+
99,
|
|
25132
|
+
99,
|
|
25133
|
+
99,
|
|
25134
|
+
99,
|
|
25135
|
+
99,
|
|
25136
|
+
99,
|
|
25137
|
+
99
|
|
25138
|
+
];
|
|
25139
|
+
var DC_LUMA = { bits: [0, 1, 5, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0], values: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11] };
|
|
25140
|
+
var DC_CHROMA = { bits: [0, 3, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0], values: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11] };
|
|
25141
|
+
var AC_LUMA = {
|
|
25142
|
+
bits: [0, 2, 1, 3, 3, 2, 4, 3, 5, 5, 4, 4, 0, 0, 1, 125],
|
|
25143
|
+
values: [
|
|
25144
|
+
1,
|
|
25145
|
+
2,
|
|
25146
|
+
3,
|
|
25147
|
+
0,
|
|
25148
|
+
4,
|
|
25149
|
+
17,
|
|
25150
|
+
5,
|
|
25151
|
+
18,
|
|
25152
|
+
33,
|
|
25153
|
+
49,
|
|
25154
|
+
65,
|
|
25155
|
+
6,
|
|
25156
|
+
19,
|
|
25157
|
+
81,
|
|
25158
|
+
97,
|
|
25159
|
+
7,
|
|
25160
|
+
34,
|
|
25161
|
+
113,
|
|
25162
|
+
20,
|
|
25163
|
+
50,
|
|
25164
|
+
129,
|
|
25165
|
+
145,
|
|
25166
|
+
161,
|
|
25167
|
+
8,
|
|
25168
|
+
35,
|
|
25169
|
+
66,
|
|
25170
|
+
177,
|
|
25171
|
+
193,
|
|
25172
|
+
21,
|
|
25173
|
+
82,
|
|
25174
|
+
209,
|
|
25175
|
+
240,
|
|
25176
|
+
36,
|
|
25177
|
+
51,
|
|
25178
|
+
98,
|
|
25179
|
+
114,
|
|
25180
|
+
130,
|
|
25181
|
+
9,
|
|
25182
|
+
10,
|
|
25183
|
+
22,
|
|
25184
|
+
23,
|
|
25185
|
+
24,
|
|
25186
|
+
25,
|
|
25187
|
+
26,
|
|
25188
|
+
37,
|
|
25189
|
+
38,
|
|
25190
|
+
39,
|
|
25191
|
+
40,
|
|
25192
|
+
41,
|
|
25193
|
+
42,
|
|
25194
|
+
52,
|
|
25195
|
+
53,
|
|
25196
|
+
54,
|
|
25197
|
+
55,
|
|
25198
|
+
56,
|
|
25199
|
+
57,
|
|
25200
|
+
58,
|
|
25201
|
+
67,
|
|
25202
|
+
68,
|
|
25203
|
+
69,
|
|
25204
|
+
70,
|
|
25205
|
+
71,
|
|
25206
|
+
72,
|
|
25207
|
+
73,
|
|
25208
|
+
74,
|
|
25209
|
+
83,
|
|
25210
|
+
84,
|
|
25211
|
+
85,
|
|
25212
|
+
86,
|
|
25213
|
+
87,
|
|
25214
|
+
88,
|
|
25215
|
+
89,
|
|
25216
|
+
90,
|
|
25217
|
+
99,
|
|
25218
|
+
100,
|
|
25219
|
+
101,
|
|
25220
|
+
102,
|
|
25221
|
+
103,
|
|
25222
|
+
104,
|
|
25223
|
+
105,
|
|
25224
|
+
106,
|
|
25225
|
+
115,
|
|
25226
|
+
116,
|
|
25227
|
+
117,
|
|
25228
|
+
118,
|
|
25229
|
+
119,
|
|
25230
|
+
120,
|
|
25231
|
+
121,
|
|
25232
|
+
122,
|
|
25233
|
+
131,
|
|
25234
|
+
132,
|
|
25235
|
+
133,
|
|
25236
|
+
134,
|
|
25237
|
+
135,
|
|
25238
|
+
136,
|
|
25239
|
+
137,
|
|
25240
|
+
138,
|
|
25241
|
+
146,
|
|
25242
|
+
147,
|
|
25243
|
+
148,
|
|
25244
|
+
149,
|
|
25245
|
+
150,
|
|
25246
|
+
151,
|
|
25247
|
+
152,
|
|
25248
|
+
153,
|
|
25249
|
+
154,
|
|
25250
|
+
162,
|
|
25251
|
+
163,
|
|
25252
|
+
164,
|
|
25253
|
+
165,
|
|
25254
|
+
166,
|
|
25255
|
+
167,
|
|
25256
|
+
168,
|
|
25257
|
+
169,
|
|
25258
|
+
170,
|
|
25259
|
+
178,
|
|
25260
|
+
179,
|
|
25261
|
+
180,
|
|
25262
|
+
181,
|
|
25263
|
+
182,
|
|
25264
|
+
183,
|
|
25265
|
+
184,
|
|
25266
|
+
185,
|
|
25267
|
+
186,
|
|
25268
|
+
194,
|
|
25269
|
+
195,
|
|
25270
|
+
196,
|
|
25271
|
+
197,
|
|
25272
|
+
198,
|
|
25273
|
+
199,
|
|
25274
|
+
200,
|
|
25275
|
+
201,
|
|
25276
|
+
202,
|
|
25277
|
+
210,
|
|
25278
|
+
211,
|
|
25279
|
+
212,
|
|
25280
|
+
213,
|
|
25281
|
+
214,
|
|
25282
|
+
215,
|
|
25283
|
+
216,
|
|
25284
|
+
217,
|
|
25285
|
+
218,
|
|
25286
|
+
225,
|
|
25287
|
+
226,
|
|
25288
|
+
227,
|
|
25289
|
+
228,
|
|
25290
|
+
229,
|
|
25291
|
+
230,
|
|
25292
|
+
231,
|
|
25293
|
+
232,
|
|
25294
|
+
233,
|
|
25295
|
+
234,
|
|
25296
|
+
241,
|
|
25297
|
+
242,
|
|
25298
|
+
243,
|
|
25299
|
+
244,
|
|
25300
|
+
245,
|
|
25301
|
+
246,
|
|
25302
|
+
247,
|
|
25303
|
+
248,
|
|
25304
|
+
249,
|
|
25305
|
+
250
|
|
25306
|
+
]
|
|
25307
|
+
};
|
|
25308
|
+
var AC_CHROMA = {
|
|
25309
|
+
bits: [0, 2, 1, 2, 4, 4, 3, 4, 7, 5, 4, 4, 0, 1, 2, 119],
|
|
25310
|
+
values: [
|
|
25311
|
+
0,
|
|
25312
|
+
1,
|
|
25313
|
+
2,
|
|
25314
|
+
3,
|
|
25315
|
+
17,
|
|
25316
|
+
4,
|
|
25317
|
+
5,
|
|
25318
|
+
33,
|
|
25319
|
+
49,
|
|
25320
|
+
6,
|
|
25321
|
+
18,
|
|
25322
|
+
65,
|
|
25323
|
+
81,
|
|
25324
|
+
7,
|
|
25325
|
+
97,
|
|
25326
|
+
113,
|
|
25327
|
+
19,
|
|
25328
|
+
34,
|
|
25329
|
+
50,
|
|
25330
|
+
129,
|
|
25331
|
+
8,
|
|
25332
|
+
20,
|
|
25333
|
+
66,
|
|
25334
|
+
145,
|
|
25335
|
+
161,
|
|
25336
|
+
177,
|
|
25337
|
+
193,
|
|
25338
|
+
9,
|
|
25339
|
+
35,
|
|
25340
|
+
51,
|
|
25341
|
+
82,
|
|
25342
|
+
240,
|
|
25343
|
+
21,
|
|
25344
|
+
98,
|
|
25345
|
+
114,
|
|
25346
|
+
209,
|
|
25347
|
+
10,
|
|
25348
|
+
22,
|
|
25349
|
+
36,
|
|
25350
|
+
52,
|
|
25351
|
+
225,
|
|
25352
|
+
37,
|
|
25353
|
+
241,
|
|
25354
|
+
23,
|
|
25355
|
+
24,
|
|
25356
|
+
25,
|
|
25357
|
+
26,
|
|
25358
|
+
38,
|
|
25359
|
+
39,
|
|
25360
|
+
40,
|
|
25361
|
+
41,
|
|
25362
|
+
42,
|
|
25363
|
+
53,
|
|
25364
|
+
54,
|
|
25365
|
+
55,
|
|
25366
|
+
56,
|
|
25367
|
+
57,
|
|
25368
|
+
58,
|
|
25369
|
+
67,
|
|
25370
|
+
68,
|
|
25371
|
+
69,
|
|
25372
|
+
70,
|
|
25373
|
+
71,
|
|
25374
|
+
72,
|
|
25375
|
+
73,
|
|
25376
|
+
74,
|
|
25377
|
+
83,
|
|
25378
|
+
84,
|
|
25379
|
+
85,
|
|
25380
|
+
86,
|
|
25381
|
+
87,
|
|
25382
|
+
88,
|
|
25383
|
+
89,
|
|
25384
|
+
90,
|
|
25385
|
+
99,
|
|
25386
|
+
100,
|
|
25387
|
+
101,
|
|
25388
|
+
102,
|
|
25389
|
+
103,
|
|
25390
|
+
104,
|
|
25391
|
+
105,
|
|
25392
|
+
106,
|
|
25393
|
+
115,
|
|
25394
|
+
116,
|
|
25395
|
+
117,
|
|
25396
|
+
118,
|
|
25397
|
+
119,
|
|
25398
|
+
120,
|
|
25399
|
+
121,
|
|
25400
|
+
122,
|
|
25401
|
+
130,
|
|
25402
|
+
131,
|
|
25403
|
+
132,
|
|
25404
|
+
133,
|
|
25405
|
+
134,
|
|
25406
|
+
135,
|
|
25407
|
+
136,
|
|
25408
|
+
137,
|
|
25409
|
+
138,
|
|
25410
|
+
146,
|
|
25411
|
+
147,
|
|
25412
|
+
148,
|
|
25413
|
+
149,
|
|
25414
|
+
150,
|
|
25415
|
+
151,
|
|
25416
|
+
152,
|
|
25417
|
+
153,
|
|
25418
|
+
154,
|
|
25419
|
+
162,
|
|
25420
|
+
163,
|
|
25421
|
+
164,
|
|
25422
|
+
165,
|
|
25423
|
+
166,
|
|
25424
|
+
167,
|
|
25425
|
+
168,
|
|
25426
|
+
169,
|
|
25427
|
+
170,
|
|
25428
|
+
178,
|
|
25429
|
+
179,
|
|
25430
|
+
180,
|
|
25431
|
+
181,
|
|
25432
|
+
182,
|
|
25433
|
+
183,
|
|
25434
|
+
184,
|
|
25435
|
+
185,
|
|
25436
|
+
186,
|
|
25437
|
+
194,
|
|
25438
|
+
195,
|
|
25439
|
+
196,
|
|
25440
|
+
197,
|
|
25441
|
+
198,
|
|
25442
|
+
199,
|
|
25443
|
+
200,
|
|
25444
|
+
201,
|
|
25445
|
+
202,
|
|
25446
|
+
210,
|
|
25447
|
+
211,
|
|
25448
|
+
212,
|
|
25449
|
+
213,
|
|
25450
|
+
214,
|
|
25451
|
+
215,
|
|
25452
|
+
216,
|
|
25453
|
+
217,
|
|
25454
|
+
218,
|
|
25455
|
+
226,
|
|
25456
|
+
227,
|
|
25457
|
+
228,
|
|
25458
|
+
229,
|
|
25459
|
+
230,
|
|
25460
|
+
231,
|
|
25461
|
+
232,
|
|
25462
|
+
233,
|
|
25463
|
+
234,
|
|
25464
|
+
242,
|
|
25465
|
+
243,
|
|
25466
|
+
244,
|
|
25467
|
+
245,
|
|
25468
|
+
246,
|
|
25469
|
+
247,
|
|
25470
|
+
248,
|
|
25471
|
+
249,
|
|
25472
|
+
250
|
|
25473
|
+
]
|
|
25474
|
+
};
|
|
25475
|
+
function buildCodes(spec) {
|
|
25476
|
+
const code = new Uint16Array(256);
|
|
25477
|
+
const size = new Uint8Array(256);
|
|
25478
|
+
let next = 0;
|
|
25479
|
+
let k = 0;
|
|
25480
|
+
for (let len = 1; len <= 16; len++) {
|
|
25481
|
+
for (let i = 0; i < spec.bits[len - 1]; i++) {
|
|
25482
|
+
const symbol = spec.values[k++];
|
|
25483
|
+
code[symbol] = next++;
|
|
25484
|
+
size[symbol] = len;
|
|
25485
|
+
}
|
|
25486
|
+
next <<= 1;
|
|
25487
|
+
}
|
|
25488
|
+
return { code, size };
|
|
25489
|
+
}
|
|
25490
|
+
function scaleQuant(base, quality) {
|
|
25491
|
+
const q = Math.min(100, Math.max(1, Math.round(quality * 100)));
|
|
25492
|
+
const scale = q < 50 ? Math.floor(5e3 / q) : 200 - q * 2;
|
|
25493
|
+
return Uint8Array.from(base, (v) => Math.min(255, Math.max(1, Math.floor((v * scale + 50) / 100))));
|
|
25494
|
+
}
|
|
25495
|
+
var COS = (() => {
|
|
25496
|
+
const t = new Float64Array(64);
|
|
25497
|
+
for (let u = 0; u < 8; u++) {
|
|
25498
|
+
const c = u === 0 ? Math.SQRT1_2 : 1;
|
|
25499
|
+
for (let x = 0; x < 8; x++) {
|
|
25500
|
+
t[u * 8 + x] = c / 2 * Math.cos((2 * x + 1) * u * Math.PI / 16);
|
|
25501
|
+
}
|
|
25502
|
+
}
|
|
25503
|
+
return t;
|
|
25504
|
+
})();
|
|
25505
|
+
function fdctQuantize(block, quant, out, tmp) {
|
|
25506
|
+
for (let y = 0; y < 8; y++) {
|
|
25507
|
+
for (let u = 0; u < 8; u++) {
|
|
25508
|
+
let s = 0;
|
|
25509
|
+
for (let x = 0; x < 8; x++) s += COS[u * 8 + x] * block[y * 8 + x];
|
|
25510
|
+
tmp[y * 8 + u] = s;
|
|
25511
|
+
}
|
|
25512
|
+
}
|
|
25513
|
+
for (let k = 0; k < 64; k++) {
|
|
25514
|
+
const n = ZIGZAG2[k];
|
|
25515
|
+
const v = n >> 3;
|
|
25516
|
+
const u = n & 7;
|
|
25517
|
+
let s = 0;
|
|
25518
|
+
for (let y = 0; y < 8; y++) s += COS[v * 8 + y] * tmp[y * 8 + u];
|
|
25519
|
+
out[k] = Math.round(s / quant[n]);
|
|
25520
|
+
}
|
|
25521
|
+
}
|
|
25522
|
+
var BitWriter = class {
|
|
25523
|
+
constructor() {
|
|
25524
|
+
this.buf = new Uint8Array(4096);
|
|
25525
|
+
this.length = 0;
|
|
25526
|
+
this.acc = 0;
|
|
25527
|
+
this.count = 0;
|
|
25528
|
+
}
|
|
25529
|
+
byte(b) {
|
|
25530
|
+
if (this.length === this.buf.length) {
|
|
25531
|
+
const grown = new Uint8Array(this.buf.length * 2);
|
|
25532
|
+
grown.set(this.buf);
|
|
25533
|
+
this.buf = grown;
|
|
25534
|
+
}
|
|
25535
|
+
this.buf[this.length++] = b;
|
|
25536
|
+
}
|
|
25537
|
+
bits(value, size) {
|
|
25538
|
+
for (let i = size - 1; i >= 0; i--) {
|
|
25539
|
+
this.acc = this.acc << 1 | value >> i & 1;
|
|
25540
|
+
if (++this.count === 8) {
|
|
25541
|
+
this.byte(this.acc);
|
|
25542
|
+
if (this.acc === 255) this.byte(0);
|
|
25543
|
+
this.acc = 0;
|
|
25544
|
+
this.count = 0;
|
|
25545
|
+
}
|
|
25546
|
+
}
|
|
25547
|
+
}
|
|
25548
|
+
/** Pads the last byte with 1 bits and returns the segment. */
|
|
25549
|
+
finish() {
|
|
25550
|
+
if (this.count > 0) this.bits((1 << 8 - this.count) - 1, 8 - this.count);
|
|
25551
|
+
return this.buf.subarray(0, this.length);
|
|
25552
|
+
}
|
|
25553
|
+
};
|
|
25554
|
+
function category(v) {
|
|
25555
|
+
let a = v < 0 ? -v : v;
|
|
25556
|
+
let n = 0;
|
|
25557
|
+
while (a) {
|
|
25558
|
+
n++;
|
|
25559
|
+
a >>= 1;
|
|
25560
|
+
}
|
|
25561
|
+
return n;
|
|
25562
|
+
}
|
|
25563
|
+
function writeBlock(w, coef, prevDc, dc, ac) {
|
|
25564
|
+
const diff = coef[0] - prevDc;
|
|
25565
|
+
const dcSize = category(diff);
|
|
25566
|
+
w.bits(dc.code[dcSize], dc.size[dcSize]);
|
|
25567
|
+
if (dcSize) w.bits(diff < 0 ? diff - 1 : diff, dcSize);
|
|
25568
|
+
let run = 0;
|
|
25569
|
+
for (let k = 1; k < 64; k++) {
|
|
25570
|
+
const v = coef[k];
|
|
25571
|
+
if (v === 0) {
|
|
25572
|
+
run++;
|
|
25573
|
+
continue;
|
|
25574
|
+
}
|
|
25575
|
+
while (run > 15) {
|
|
25576
|
+
w.bits(ac.code[240], ac.size[240]);
|
|
25577
|
+
run -= 16;
|
|
25578
|
+
}
|
|
25579
|
+
const size = category(v);
|
|
25580
|
+
const symbol = run << 4 | size;
|
|
25581
|
+
w.bits(ac.code[symbol], ac.size[symbol]);
|
|
25582
|
+
w.bits(v < 0 ? v - 1 : v, size);
|
|
25583
|
+
run = 0;
|
|
25584
|
+
}
|
|
25585
|
+
if (run > 0) w.bits(ac.code[0], ac.size[0]);
|
|
25586
|
+
return coef[0];
|
|
25587
|
+
}
|
|
25588
|
+
function segment(marker, payload) {
|
|
25589
|
+
const len = payload.length + 2;
|
|
25590
|
+
return [255, marker, len >> 8, len & 255, ...payload];
|
|
25591
|
+
}
|
|
25592
|
+
function dhtPayload(tableClass, id, spec) {
|
|
25593
|
+
return [tableClass << 4 | id, ...spec.bits, ...spec.values];
|
|
25594
|
+
}
|
|
25595
|
+
function encodeJpeg(data, width, height, options2 = {}) {
|
|
25596
|
+
if (!(width >= 1 && height >= 1 && width <= 65535 && height <= 65535)) {
|
|
25597
|
+
throw new RangeError(`JPEG dimensions out of range: ${width}x${height}`);
|
|
25598
|
+
}
|
|
25599
|
+
const quality = Number.isFinite(options2.quality) ? Math.min(1, Math.max(0, options2.quality)) : DEFAULT_JPEG_QUALITY;
|
|
25600
|
+
const [bgR, bgG, bgB] = options2.background ?? [255, 255, 255];
|
|
25601
|
+
const sub = options2.chromaSubsampling ?? false;
|
|
25602
|
+
const lumaQuant = scaleQuant(LUMA_QUANT, quality);
|
|
25603
|
+
const chromaQuant = scaleQuant(CHROMA_QUANT, quality);
|
|
25604
|
+
const n = width * height;
|
|
25605
|
+
const Y = new Float64Array(n);
|
|
25606
|
+
const Cb = new Float64Array(n);
|
|
25607
|
+
const Cr = new Float64Array(n);
|
|
25608
|
+
for (let i = 0; i < n; i++) {
|
|
25609
|
+
const a = data[i * 4 + 3] / 255;
|
|
25610
|
+
const r = data[i * 4] * a + bgR * (1 - a);
|
|
25611
|
+
const g = data[i * 4 + 1] * a + bgG * (1 - a);
|
|
25612
|
+
const b = data[i * 4 + 2] * a + bgB * (1 - a);
|
|
25613
|
+
Y[i] = 0.299 * r + 0.587 * g + 0.114 * b;
|
|
25614
|
+
Cb[i] = -0.168736 * r - 0.331264 * g + 0.5 * b + 128;
|
|
25615
|
+
Cr[i] = 0.5 * r - 0.418688 * g - 0.081312 * b + 128;
|
|
25616
|
+
}
|
|
25617
|
+
const dcL = buildCodes(DC_LUMA);
|
|
25618
|
+
const acL = buildCodes(AC_LUMA);
|
|
25619
|
+
const dcC = buildCodes(DC_CHROMA);
|
|
25620
|
+
const acC = buildCodes(AC_CHROMA);
|
|
25621
|
+
const factor = sub ? 2 : 1;
|
|
25622
|
+
const mcu = 8 * factor;
|
|
25623
|
+
const block = new Float64Array(64);
|
|
25624
|
+
const tmp = new Float64Array(64);
|
|
25625
|
+
const coef = new Int32Array(64);
|
|
25626
|
+
const w = new BitWriter();
|
|
25627
|
+
let dcY = 0;
|
|
25628
|
+
let dcCb = 0;
|
|
25629
|
+
let dcCr = 0;
|
|
25630
|
+
const lumaBlock = (x0, y0) => {
|
|
25631
|
+
for (let y = 0; y < 8; y++) {
|
|
25632
|
+
const row2 = Math.min(height - 1, y0 + y) * width;
|
|
25633
|
+
for (let x = 0; x < 8; x++) block[y * 8 + x] = Y[row2 + Math.min(width - 1, x0 + x)] - 128;
|
|
25634
|
+
}
|
|
25635
|
+
};
|
|
25636
|
+
const chromaBlock = (plane, x0, y0) => {
|
|
25637
|
+
for (let y = 0; y < 8; y++) {
|
|
25638
|
+
for (let x = 0; x < 8; x++) {
|
|
25639
|
+
let s = 0;
|
|
25640
|
+
for (let dy = 0; dy < factor; dy++) {
|
|
25641
|
+
const row2 = Math.min(height - 1, y0 + y * factor + dy) * width;
|
|
25642
|
+
for (let dx = 0; dx < factor; dx++) s += plane[row2 + Math.min(width - 1, x0 + x * factor + dx)];
|
|
25643
|
+
}
|
|
25644
|
+
block[y * 8 + x] = s / (factor * factor) - 128;
|
|
25645
|
+
}
|
|
25646
|
+
}
|
|
25647
|
+
};
|
|
25648
|
+
for (let my = 0; my < height; my += mcu) {
|
|
25649
|
+
for (let mx = 0; mx < width; mx += mcu) {
|
|
25650
|
+
for (let by = 0; by < factor; by++) {
|
|
25651
|
+
for (let bx = 0; bx < factor; bx++) {
|
|
25652
|
+
lumaBlock(mx + bx * 8, my + by * 8);
|
|
25653
|
+
fdctQuantize(block, lumaQuant, coef, tmp);
|
|
25654
|
+
dcY = writeBlock(w, coef, dcY, dcL, acL);
|
|
25655
|
+
}
|
|
25656
|
+
}
|
|
25657
|
+
chromaBlock(Cb, mx, my);
|
|
25658
|
+
fdctQuantize(block, chromaQuant, coef, tmp);
|
|
25659
|
+
dcCb = writeBlock(w, coef, dcCb, dcC, acC);
|
|
25660
|
+
chromaBlock(Cr, mx, my);
|
|
25661
|
+
fdctQuantize(block, chromaQuant, coef, tmp);
|
|
25662
|
+
dcCr = writeBlock(w, coef, dcCr, dcC, acC);
|
|
25663
|
+
}
|
|
25664
|
+
}
|
|
25665
|
+
const scan = w.finish();
|
|
25666
|
+
const sampling = factor << 4 | factor;
|
|
25667
|
+
const header = [
|
|
25668
|
+
255,
|
|
25669
|
+
216,
|
|
25670
|
+
// APP0 JFIF 1.01, no density (aspect ratio 1:1), no thumbnail.
|
|
25671
|
+
...segment(224, [74, 70, 73, 70, 0, 1, 1, 0, 0, 1, 0, 1, 0, 0]),
|
|
25672
|
+
...segment(219, [0, ...ZIGZAG2.map((i) => lumaQuant[i]), 1, ...ZIGZAG2.map((i) => chromaQuant[i])]),
|
|
25673
|
+
...segment(192, [8, height >> 8, height & 255, width >> 8, width & 255, 3, 1, sampling, 0, 2, 17, 1, 3, 17, 1]),
|
|
25674
|
+
...segment(196, [...dhtPayload(0, 0, DC_LUMA), ...dhtPayload(1, 0, AC_LUMA), ...dhtPayload(0, 1, DC_CHROMA), ...dhtPayload(1, 1, AC_CHROMA)]),
|
|
25675
|
+
...segment(218, [3, 1, 0, 2, 17, 3, 17, 0, 63, 0])
|
|
25676
|
+
];
|
|
25677
|
+
const out = new Uint8Array(header.length + scan.length + 2);
|
|
25678
|
+
out.set(header, 0);
|
|
25679
|
+
out.set(scan, header.length);
|
|
25680
|
+
out[out.length - 2] = 255;
|
|
25681
|
+
out[out.length - 1] = 217;
|
|
25682
|
+
return out;
|
|
25683
|
+
}
|
|
25684
|
+
|
|
24938
25685
|
// src/fnt-font.ts
|
|
24939
25686
|
function parseFnt(view, base, end) {
|
|
24940
25687
|
if (base + 118 > end) {
|
|
@@ -36049,6 +36796,20 @@ function handleEmfGdiBlendBlitRecord(rCtx, recType, offset, dataOff, recSize) {
|
|
|
36049
36796
|
|
|
36050
36797
|
// src/emf-ansi-tables.ts
|
|
36051
36798
|
var OEM437_HIGH = "\xC7\xFC\xE9\xE2\xE4\xE0\xE5\xE7\xEA\xEB\xE8\xEF\xEE\xEC\xC4\xC5\xC9\xE6\xC6\xF4\xF6\xF2\xFB\xF9\xFF\xD6\xDC\xA2\xA3\xA5\u20A7\u0192\xE1\xED\xF3\xFA\xF1\xD1\xAA\xBA\xBF\u2310\xAC\xBD\xBC\xA1\xAB\xBB\u2591\u2592\u2593\u2502\u2524\u2561\u2562\u2556\u2555\u2563\u2551\u2557\u255D\u255C\u255B\u2510\u2514\u2534\u252C\u251C\u2500\u253C\u255E\u255F\u255A\u2554\u2569\u2566\u2560\u2550\u256C\u2567\u2568\u2564\u2565\u2559\u2558\u2552\u2553\u256B\u256A\u2518\u250C\u2588\u2584\u258C\u2590\u2580\u03B1\xDF\u0393\u03C0\u03A3\u03C3\xB5\u03C4\u03A6\u0398\u03A9\u03B4\u221E\u03C6\u03B5\u2229\u2261\xB1\u2265\u2264\u2320\u2321\xF7\u2248\xB0\u2219\xB7\u221A\u207F\xB2\u25A0\xA0";
|
|
36799
|
+
var OEM_HIGH = {
|
|
36800
|
+
737: "\u0391\u0392\u0393\u0394\u0395\u0396\u0397\u0398\u0399\u039A\u039B\u039C\u039D\u039E\u039F\u03A0\u03A1\u03A3\u03A4\u03A5\u03A6\u03A7\u03A8\u03A9\u03B1\u03B2\u03B3\u03B4\u03B5\u03B6\u03B7\u03B8\u03B9\u03BA\u03BB\u03BC\u03BD\u03BE\u03BF\u03C0\u03C1\u03C3\u03C2\u03C4\u03C5\u03C6\u03C7\u03C8\u2591\u2592\u2593\u2502\u2524\u2561\u2562\u2556\u2555\u2563\u2551\u2557\u255D\u255C\u255B\u2510\u2514\u2534\u252C\u251C\u2500\u253C\u255E\u255F\u255A\u2554\u2569\u2566\u2560\u2550\u256C\u2567\u2568\u2564\u2565\u2559\u2558\u2552\u2553\u256B\u256A\u2518\u250C\u2588\u2584\u258C\u2590\u2580\u03C9\u03AC\u03AD\u03AE\u03CA\u03AF\u03CC\u03CD\u03CB\u03CE\u0386\u0388\u0389\u038A\u038C\u038E\u038F\xB1\u2265\u2264\u03AA\u03AB\xF7\u2248\xB0\u2219\xB7\u221A\u207F\xB2\u25A0\xA0",
|
|
36801
|
+
775: "\u0106\xFC\xE9\u0101\xE4\u0123\xE5\u0107\u0142\u0113\u0156\u0157\u012B\u0179\xC4\xC5\xC9\xE6\xC6\u014D\xF6\u0122\xA2\u015A\u015B\xD6\xDC\xF8\xA3\xD8\xD7\xA4\u0100\u012A\xF3\u017B\u017C\u017A\u201D\xA6\xA9\xAE\xAC\xBD\xBC\u0141\xAB\xBB\u2591\u2592\u2593\u2502\u2524\u0104\u010C\u0118\u0116\u2563\u2551\u2557\u255D\u012E\u0160\u2510\u2514\u2534\u252C\u251C\u2500\u253C\u0172\u016A\u255A\u2554\u2569\u2566\u2560\u2550\u256C\u017D\u0105\u010D\u0119\u0117\u012F\u0161\u0173\u016B\u017E\u2518\u250C\u2588\u2584\u258C\u2590\u2580\xD3\xDF\u014C\u0143\xF5\xD5\xB5\u0144\u0136\u0137\u013B\u013C\u0146\u0112\u0145\u2019\xAD\xB1\u201C\xBE\xB6\xA7\xF7\u201E\xB0\u2219\xB7\xB9\xB3\xB2\u25A0\xA0",
|
|
36802
|
+
850: "\xC7\xFC\xE9\xE2\xE4\xE0\xE5\xE7\xEA\xEB\xE8\xEF\xEE\xEC\xC4\xC5\xC9\xE6\xC6\xF4\xF6\xF2\xFB\xF9\xFF\xD6\xDC\xF8\xA3\xD8\xD7\u0192\xE1\xED\xF3\xFA\xF1\xD1\xAA\xBA\xBF\xAE\xAC\xBD\xBC\xA1\xAB\xBB\u2591\u2592\u2593\u2502\u2524\xC1\xC2\xC0\xA9\u2563\u2551\u2557\u255D\xA2\xA5\u2510\u2514\u2534\u252C\u251C\u2500\u253C\xE3\xC3\u255A\u2554\u2569\u2566\u2560\u2550\u256C\xA4\xF0\xD0\xCA\xCB\xC8\u0131\xCD\xCE\xCF\u2518\u250C\u2588\u2584\xA6\xCC\u2580\xD3\xDF\xD4\xD2\xF5\xD5\xB5\xFE\xDE\xDA\xDB\xD9\xFD\xDD\xAF\xB4\xAD\xB1\u2017\xBE\xB6\xA7\xF7\xB8\xB0\xA8\xB7\xB9\xB3\xB2\u25A0\xA0",
|
|
36803
|
+
852: "\xC7\xFC\xE9\xE2\xE4\u016F\u0107\xE7\u0142\xEB\u0150\u0151\xEE\u0179\xC4\u0106\xC9\u0139\u013A\xF4\xF6\u013D\u013E\u015A\u015B\xD6\xDC\u0164\u0165\u0141\xD7\u010D\xE1\xED\xF3\xFA\u0104\u0105\u017D\u017E\u0118\u0119\xAC\u017A\u010C\u015F\xAB\xBB\u2591\u2592\u2593\u2502\u2524\xC1\xC2\u011A\u015E\u2563\u2551\u2557\u255D\u017B\u017C\u2510\u2514\u2534\u252C\u251C\u2500\u253C\u0102\u0103\u255A\u2554\u2569\u2566\u2560\u2550\u256C\xA4\u0111\u0110\u010E\xCB\u010F\u0147\xCD\xCE\u011B\u2518\u250C\u2588\u2584\u0162\u016E\u2580\xD3\xDF\xD4\u0143\u0144\u0148\u0160\u0161\u0154\xDA\u0155\u0170\xFD\xDD\u0163\xB4\xAD\u02DD\u02DB\u02C7\u02D8\xA7\xF7\xB8\xB0\xA8\u02D9\u0171\u0158\u0159\u25A0\xA0",
|
|
36804
|
+
855: "\u0452\u0402\u0453\u0403\u0451\u0401\u0454\u0404\u0455\u0405\u0456\u0406\u0457\u0407\u0458\u0408\u0459\u0409\u045A\u040A\u045B\u040B\u045C\u040C\u045E\u040E\u045F\u040F\u044E\u042E\u044A\u042A\u0430\u0410\u0431\u0411\u0446\u0426\u0434\u0414\u0435\u0415\u0444\u0424\u0433\u0413\xAB\xBB\u2591\u2592\u2593\u2502\u2524\u0445\u0425\u0438\u0418\u2563\u2551\u2557\u255D\u0439\u0419\u2510\u2514\u2534\u252C\u251C\u2500\u253C\u043A\u041A\u255A\u2554\u2569\u2566\u2560\u2550\u256C\xA4\u043B\u041B\u043C\u041C\u043D\u041D\u043E\u041E\u043F\u2518\u250C\u2588\u2584\u041F\u044F\u2580\u042F\u0440\u0420\u0441\u0421\u0442\u0422\u0443\u0423\u0436\u0416\u0432\u0412\u044C\u042C\u2116\xAD\u044B\u042B\u0437\u0417\u0448\u0428\u044D\u042D\u0449\u0429\u0447\u0427\xA7\u25A0\xA0",
|
|
36805
|
+
858: "\xC7\xFC\xE9\xE2\xE4\xE0\xE5\xE7\xEA\xEB\xE8\xEF\xEE\xEC\xC4\xC5\xC9\xE6\xC6\xF4\xF6\xF2\xFB\xF9\xFF\xD6\xDC\xF8\xA3\xD8\xD7\u0192\xE1\xED\xF3\xFA\xF1\xD1\xAA\xBA\xBF\xAE\xAC\xBD\xBC\xA1\xAB\xBB\u2591\u2592\u2593\u2502\u2524\xC1\xC2\xC0\xA9\u2563\u2551\u2557\u255D\xA2\xA5\u2510\u2514\u2534\u252C\u251C\u2500\u253C\xE3\xC3\u255A\u2554\u2569\u2566\u2560\u2550\u256C\xA4\xF0\xD0\xCA\xCB\xC8\u20AC\xCD\xCE\xCF\u2518\u250C\u2588\u2584\xA6\xCC\u2580\xD3\xDF\xD4\xD2\xF5\xD5\xB5\xFE\xDE\xDA\xDB\xD9\xFD\xDD\xAF\xB4\xAD\xB1\u2017\xBE\xB6\xA7\xF7\xB8\xB0\xA8\xB7\xB9\xB3\xB2\u25A0\xA0",
|
|
36806
|
+
860: "\xC7\xFC\xE9\xE2\xE3\xE0\xC1\xE7\xEA\xCA\xE8\xCD\xD4\xEC\xC3\xC2\xC9\xC0\xC8\xF4\xF5\xF2\xDA\xF9\xCC\xD5\xDC\xA2\xA3\xD9\u20A7\xD3\xE1\xED\xF3\xFA\xF1\xD1\xAA\xBA\xBF\xD2\xAC\xBD\xBC\xA1\xAB\xBB\u2591\u2592\u2593\u2502\u2524\u2561\u2562\u2556\u2555\u2563\u2551\u2557\u255D\u255C\u255B\u2510\u2514\u2534\u252C\u251C\u2500\u253C\u255E\u255F\u255A\u2554\u2569\u2566\u2560\u2550\u256C\u2567\u2568\u2564\u2565\u2559\u2558\u2552\u2553\u256B\u256A\u2518\u250C\u2588\u2584\u258C\u2590\u2580\u03B1\xDF\u0393\u03C0\u03A3\u03C3\xB5\u03C4\u03A6\u0398\u03A9\u03B4\u221E\u03C6\u03B5\u2229\u2261\xB1\u2265\u2264\u2320\u2321\xF7\u2248\xB0\u2219\xB7\u221A\u207F\xB2\u25A0\xA0",
|
|
36807
|
+
861: "\xC7\xFC\xE9\xE2\xE4\xE0\xE5\xE7\xEA\xEB\xE8\xD0\xF0\xDE\xC4\xC5\xC9\xE6\xC6\xF4\xF6\xFE\xFB\xDD\xFD\xD6\xDC\xF8\xA3\xD8\u20A7\u0192\xE1\xED\xF3\xFA\xC1\xCD\xD3\xDA\xBF\u2310\xAC\xBD\xBC\xA1\xAB\xBB\u2591\u2592\u2593\u2502\u2524\u2561\u2562\u2556\u2555\u2563\u2551\u2557\u255D\u255C\u255B\u2510\u2514\u2534\u252C\u251C\u2500\u253C\u255E\u255F\u255A\u2554\u2569\u2566\u2560\u2550\u256C\u2567\u2568\u2564\u2565\u2559\u2558\u2552\u2553\u256B\u256A\u2518\u250C\u2588\u2584\u258C\u2590\u2580\u03B1\xDF\u0393\u03C0\u03A3\u03C3\xB5\u03C4\u03A6\u0398\u03A9\u03B4\u221E\u03C6\u03B5\u2229\u2261\xB1\u2265\u2264\u2320\u2321\xF7\u2248\xB0\u2219\xB7\u221A\u207F\xB2\u25A0\xA0",
|
|
36808
|
+
862: "\u05D0\u05D1\u05D2\u05D3\u05D4\u05D5\u05D6\u05D7\u05D8\u05D9\u05DA\u05DB\u05DC\u05DD\u05DE\u05DF\u05E0\u05E1\u05E2\u05E3\u05E4\u05E5\u05E6\u05E7\u05E8\u05E9\u05EA\xA2\xA3\xA5\u20A7\u0192\xE1\xED\xF3\xFA\xF1\xD1\xAA\xBA\xBF\u2310\xAC\xBD\xBC\xA1\xAB\xBB\u2591\u2592\u2593\u2502\u2524\u2561\u2562\u2556\u2555\u2563\u2551\u2557\u255D\u255C\u255B\u2510\u2514\u2534\u252C\u251C\u2500\u253C\u255E\u255F\u255A\u2554\u2569\u2566\u2560\u2550\u256C\u2567\u2568\u2564\u2565\u2559\u2558\u2552\u2553\u256B\u256A\u2518\u250C\u2588\u2584\u258C\u2590\u2580\u03B1\xDF\u0393\u03C0\u03A3\u03C3\xB5\u03C4\u03A6\u0398\u03A9\u03B4\u221E\u03C6\u03B5\u2229\u2261\xB1\u2265\u2264\u2320\u2321\xF7\u2248\xB0\u2219\xB7\u221A\u207F\xB2\u25A0\xA0",
|
|
36809
|
+
863: "\xC7\xFC\xE9\xE2\xC2\xE0\xB6\xE7\xEA\xEB\xE8\xEF\xEE\u2017\xC0\xA7\xC9\xC8\xCA\xF4\xCB\xCF\xFB\xF9\xA4\xD4\xDC\xA2\xA3\xD9\xDB\u0192\xA6\xB4\xF3\xFA\xA8\xB8\xB3\xAF\xCE\u2310\xAC\xBD\xBC\xBE\xAB\xBB\u2591\u2592\u2593\u2502\u2524\u2561\u2562\u2556\u2555\u2563\u2551\u2557\u255D\u255C\u255B\u2510\u2514\u2534\u252C\u251C\u2500\u253C\u255E\u255F\u255A\u2554\u2569\u2566\u2560\u2550\u256C\u2567\u2568\u2564\u2565\u2559\u2558\u2552\u2553\u256B\u256A\u2518\u250C\u2588\u2584\u258C\u2590\u2580\u03B1\xDF\u0393\u03C0\u03A3\u03C3\xB5\u03C4\u03A6\u0398\u03A9\u03B4\u221E\u03C6\u03B5\u2229\u2261\xB1\u2265\u2264\u2320\u2321\xF7\u2248\xB0\u2219\xB7\u221A\u207F\xB2\u25A0\xA0",
|
|
36810
|
+
865: "\xC7\xFC\xE9\xE2\xE4\xE0\xE5\xE7\xEA\xEB\xE8\xEF\xEE\xEC\xC4\xC5\xC9\xE6\xC6\xF4\xF6\xF2\xFB\xF9\xFF\xD6\xDC\xF8\xA3\xD8\u20A7\u0192\xE1\xED\xF3\xFA\xF1\xD1\xAA\xBA\xBF\u2310\xAC\xBD\xBC\xA1\xAB\xA4\u2591\u2592\u2593\u2502\u2524\u2561\u2562\u2556\u2555\u2563\u2551\u2557\u255D\u255C\u255B\u2510\u2514\u2534\u252C\u251C\u2500\u253C\u255E\u255F\u255A\u2554\u2569\u2566\u2560\u2550\u256C\u2567\u2568\u2564\u2565\u2559\u2558\u2552\u2553\u256B\u256A\u2518\u250C\u2588\u2584\u258C\u2590\u2580\u03B1\xDF\u0393\u03C0\u03A3\u03C3\xB5\u03C4\u03A6\u0398\u03A9\u03B4\u221E\u03C6\u03B5\u2229\u2261\xB1\u2265\u2264\u2320\u2321\xF7\u2248\xB0\u2219\xB7\u221A\u207F\xB2\u25A0\xA0",
|
|
36811
|
+
866: "\u0410\u0411\u0412\u0413\u0414\u0415\u0416\u0417\u0418\u0419\u041A\u041B\u041C\u041D\u041E\u041F\u0420\u0421\u0422\u0423\u0424\u0425\u0426\u0427\u0428\u0429\u042A\u042B\u042C\u042D\u042E\u042F\u0430\u0431\u0432\u0433\u0434\u0435\u0436\u0437\u0438\u0439\u043A\u043B\u043C\u043D\u043E\u043F\u2591\u2592\u2593\u2502\u2524\u2561\u2562\u2556\u2555\u2563\u2551\u2557\u255D\u255C\u255B\u2510\u2514\u2534\u252C\u251C\u2500\u253C\u255E\u255F\u255A\u2554\u2569\u2566\u2560\u2550\u256C\u2567\u2568\u2564\u2565\u2559\u2558\u2552\u2553\u256B\u256A\u2518\u250C\u2588\u2584\u258C\u2590\u2580\u0440\u0441\u0442\u0443\u0444\u0445\u0446\u0447\u0448\u0449\u044A\u044B\u044C\u044D\u044E\u044F\u0401\u0451\u0404\u0454\u0407\u0457\u040E\u045E\xB0\u2219\xB7\u221A\u2116\xA4\u25A0\xA0"
|
|
36812
|
+
};
|
|
36052
36813
|
var JOHAB_ROWS = {
|
|
36053
36814
|
132: "\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\u11A8\u11A9\u11AA\u11AB\u11AC\u11AD\u11AE\u11AF\u11B0\u11B1\u11B2\u11B3\u11B4\u11B5\u11B6\u11B7\uFFFD\u11B8\u11B9\u11BA\u11BB\u11BC\u11BD\u11BE\u11BF\u11C0\u11C1\u11C2\uFFFD\uFFFD\uFFFD\u1161\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\u1162\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\u1163\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\u1164\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\u1165\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD",
|
|
36054
36815
|
133: "\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\u1166\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\u1167\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\u1168\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\u1169\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\u116A\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\u116B\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD\uFFFD",
|
|
@@ -36241,12 +37002,23 @@ var ANSI_CODE_PAGE_ENCODING = {
|
|
|
36241
37002
|
54936: "gb18030",
|
|
36242
37003
|
65001: "utf-8"
|
|
36243
37004
|
};
|
|
36244
|
-
|
|
37005
|
+
var OEM_CODE_PAGE_ENCODING = {
|
|
37006
|
+
874: "windows-874",
|
|
37007
|
+
932: "shift_jis",
|
|
37008
|
+
936: "gbk",
|
|
37009
|
+
949: "euc-kr",
|
|
37010
|
+
950: "big5"
|
|
37011
|
+
};
|
|
37012
|
+
function decodeOemTable(bytes, high) {
|
|
37013
|
+
return { codes: bytes.map((b) => b < 128 ? b : high.charCodeAt(b - 128)), byteLengths: bytes.map(() => 1) };
|
|
37014
|
+
}
|
|
37015
|
+
function decodeAnsiRecord(bytes, charSet, codePages) {
|
|
36245
37016
|
if (charSet === 2) {
|
|
36246
37017
|
return { codes: [...bytes], byteLengths: bytes.map(() => 1) };
|
|
36247
37018
|
}
|
|
36248
|
-
|
|
36249
|
-
|
|
37019
|
+
const oemCodePage = codePages?.oem;
|
|
37020
|
+
if (charSet === 255 && (oemCodePage === void 0 || !(oemCodePage in OEM_CODE_PAGE_ENCODING))) {
|
|
37021
|
+
return decodeOemTable(bytes, (oemCodePage !== void 0 ? OEM_HIGH[oemCodePage] : void 0) ?? OEM437_HIGH);
|
|
36250
37022
|
}
|
|
36251
37023
|
if (charSet === 130) {
|
|
36252
37024
|
const codes = [];
|
|
@@ -36262,7 +37034,8 @@ function decodeAnsiRecord(bytes, charSet, ansiCodePage) {
|
|
|
36262
37034
|
}
|
|
36263
37035
|
return { codes, byteLengths };
|
|
36264
37036
|
}
|
|
36265
|
-
const
|
|
37037
|
+
const ansiCodePage = codePages?.ansi;
|
|
37038
|
+
const label = charSet === 255 && oemCodePage !== void 0 ? OEM_CODE_PAGE_ENCODING[oemCodePage] : (charSet === 0 || charSet === 1) && ansiCodePage !== void 0 ? ANSI_CODE_PAGE_ENCODING[ansiCodePage] ?? "windows-1252" : CHARSET_ENCODING[charSet] ?? "windows-1252";
|
|
36266
37039
|
if (label === "windows-1252") {
|
|
36267
37040
|
return { codes: bytes.map((b) => ansiToCode(b, charSet)), byteLengths: bytes.map(() => 1) };
|
|
36268
37041
|
}
|
|
@@ -37082,8 +37855,9 @@ function drawTextCall(rCtx, x, y, codes, options2, rect, dx) {
|
|
|
37082
37855
|
const child = { ...rCtx, view };
|
|
37083
37856
|
handleExtTextOutW(child, 0, 8, size);
|
|
37084
37857
|
}
|
|
37085
|
-
function readAnsiRecord(
|
|
37086
|
-
|
|
37858
|
+
function readAnsiRecord(rCtx, start, count, charSet) {
|
|
37859
|
+
const { view } = rCtx;
|
|
37860
|
+
return decodeAnsiRecord(Array.from({ length: count }, (_, i) => view.getUint8(start + i)), charSet, rCtx.codePages);
|
|
37087
37861
|
}
|
|
37088
37862
|
function collapseAnsiDx(dx, byteLengths, pdy) {
|
|
37089
37863
|
if (!dx) return null;
|
|
@@ -37118,7 +37892,7 @@ function handlePolyText(rCtx, offset, dataOff, recSize, wide) {
|
|
|
37118
37892
|
const offDx = view.getUint32(e + 36, true);
|
|
37119
37893
|
const unit = wide ? 2 : 1;
|
|
37120
37894
|
if (!offString || offString > end - offset || n > Math.floor((end - (offset + offString)) / unit)) continue;
|
|
37121
|
-
const ansi = wide ? null : readAnsiRecord(
|
|
37895
|
+
const ansi = wide ? null : readAnsiRecord(rCtx, offset + offString, n, charSet);
|
|
37122
37896
|
const codes = wide ? Array.from({ length: n }, (_, j) => view.getUint16(offset + offString + j * 2, true)) : ansi.codes;
|
|
37123
37897
|
let dx = null;
|
|
37124
37898
|
const pdy = (options2 & ETO_PDY) !== 0;
|
|
@@ -37159,7 +37933,7 @@ function handleEmfGdiDrawTextRecord(rCtx, recType, offset, dataOff, recSize) {
|
|
|
37159
37933
|
const n = view.getUint32(dataOff + 36, true), strOff = view.getUint32(dataOff + 40, true), options2 = view.getUint32(dataOff + 44, true);
|
|
37160
37934
|
if (!strOff || strOff > end - offset) return true;
|
|
37161
37935
|
if (n > end - (offset + strOff)) return true;
|
|
37162
|
-
const ansi = readAnsiRecord(
|
|
37936
|
+
const ansi = readAnsiRecord(rCtx, offset + strOff, n, state.fontDetails?.charSet ?? 1);
|
|
37163
37937
|
const rect = [view.getInt32(dataOff + 48, true), view.getInt32(dataOff + 52, true), view.getInt32(dataOff + 56, true), view.getInt32(dataOff + 60, true)];
|
|
37164
37938
|
const offDx = view.getUint32(dataOff + 64, true);
|
|
37165
37939
|
let dx = null;
|
|
@@ -40914,6 +41688,7 @@ function replayEmfPlusRecords(view, offset, length, ctx, canvasW, canvasH, state
|
|
|
40914
41688
|
imageCache: s.imageCache,
|
|
40915
41689
|
nestingDepth: s.nestingDepth,
|
|
40916
41690
|
gdiAntialias: s.gdiAntialias,
|
|
41691
|
+
codePages: s.codePages,
|
|
40917
41692
|
antiAlias: s.antiAlias,
|
|
40918
41693
|
ext: s.ext ?? (s.ext = {})
|
|
40919
41694
|
};
|
|
@@ -41091,6 +41866,7 @@ function replayEmfRecords(view, ctx, bounds, canvasW, canvasH, dpiScale = 1, rep
|
|
|
41091
41866
|
const plusScale = dpiScale > 0 ? dpiScale : 1;
|
|
41092
41867
|
emfPlusState.imageCache = replayOptions.imageCache;
|
|
41093
41868
|
emfPlusState.gdiAntialias = replayOptions.gdiAntialias;
|
|
41869
|
+
emfPlusState.codePages = replayOptions.codePages;
|
|
41094
41870
|
emfPlusState.baseTransform = replayOptions.plusBaseTransform ?? [
|
|
41095
41871
|
sx / plusScale,
|
|
41096
41872
|
0,
|
|
@@ -41130,7 +41906,8 @@ function replayEmfRecords(view, ctx, bounds, canvasW, canvasH, dpiScale = 1, rep
|
|
|
41130
41906
|
sy,
|
|
41131
41907
|
pathCmds: [],
|
|
41132
41908
|
gdiAntialias: replayOptions.gdiAntialias,
|
|
41133
|
-
fonts: replayOptions.fonts
|
|
41909
|
+
fonts: replayOptions.fonts,
|
|
41910
|
+
codePages: replayOptions.codePages
|
|
41134
41911
|
};
|
|
41135
41912
|
let offset = 0;
|
|
41136
41913
|
const maxOffset = view.byteLength;
|
|
@@ -41535,7 +42312,7 @@ function createFont(p, dataOff, recSize, recEnd) {
|
|
|
41535
42312
|
}
|
|
41536
42313
|
faceBytes.push(ch);
|
|
41537
42314
|
}
|
|
41538
|
-
const family = String.fromCharCode(...decodeAnsiRecord(faceBytes, 1, p.ansiCodePage).codes);
|
|
42315
|
+
const family = String.fromCharCode(...decodeAnsiRecord(faceBytes, 1, { ansi: p.ansiCodePage }).codes);
|
|
41539
42316
|
const font = {
|
|
41540
42317
|
kind: "font",
|
|
41541
42318
|
// Sign kept: resolveFontPixelHeight() tells cell from character height by it.
|
|
@@ -42562,7 +43339,7 @@ function drawWithFontEngine2(p, call, codes, dx) {
|
|
|
42562
43339
|
}
|
|
42563
43340
|
function playText(p, call) {
|
|
42564
43341
|
const charSet = p.rCtx.state.fontDetails?.charSet ?? 1;
|
|
42565
|
-
const { codes, byteLengths } = decodeAnsiRecord(call.bytes, charSet, p.ansiCodePage);
|
|
43342
|
+
const { codes, byteLengths } = decodeAnsiRecord(call.bytes, charSet, { ansi: p.ansiCodePage, oem: p.oemCodePage });
|
|
42566
43343
|
const n = codes.length;
|
|
42567
43344
|
if (n === 0) {
|
|
42568
43345
|
return;
|
|
@@ -42694,7 +43471,8 @@ function createWmfPlayer(view, ctx, header, canvasW, canvasH, replayOptions = {}
|
|
|
42694
43471
|
};
|
|
42695
43472
|
const p = {
|
|
42696
43473
|
rCtx,
|
|
42697
|
-
ansiCodePage: replayOptions.wmfAnsiCodePage,
|
|
43474
|
+
ansiCodePage: replayOptions.wmfAnsiCodePage ?? replayOptions.codePages?.ansi,
|
|
43475
|
+
oemCodePage: replayOptions.codePages?.oem,
|
|
42698
43476
|
view,
|
|
42699
43477
|
kx,
|
|
42700
43478
|
ky,
|
|
@@ -43193,6 +43971,7 @@ async function replayMetafile(buffer, options2, createSurface) {
|
|
|
43193
43971
|
maxRecords: opts.maxRecords,
|
|
43194
43972
|
maxRecordsEmfPlus: opts.maxRecords,
|
|
43195
43973
|
fontFamilyMap: opts.fontFamilyMap,
|
|
43974
|
+
codePages: { ansi: opts.ansiCodePage, oem: opts.oemCodePage },
|
|
43196
43975
|
textureCache,
|
|
43197
43976
|
imageCache,
|
|
43198
43977
|
gdiAntialias: opts.gdiAntialias,
|
|
@@ -43227,6 +44006,7 @@ async function replayMetafile(buffer, options2, createSurface) {
|
|
|
43227
44006
|
replayWmfRecords(view, surface.ctx, header, surface.width, surface.height, {
|
|
43228
44007
|
wmfReferenceDpi: opts.wmfReferenceDpi,
|
|
43229
44008
|
wmfAnsiCodePage: opts.wmfAnsiCodePage,
|
|
44009
|
+
codePages: { ansi: opts.ansiCodePage, oem: opts.oemCodePage },
|
|
43230
44010
|
maxRecords: opts.maxRecords,
|
|
43231
44011
|
fontFamilyMap: opts.fontFamilyMap,
|
|
43232
44012
|
gdiAntialias: opts.gdiAntialias,
|
|
@@ -43347,6 +44127,54 @@ async function processDeferredImages(ctx, deferredImages, recursionDepth) {
|
|
|
43347
44127
|
return complete;
|
|
43348
44128
|
}
|
|
43349
44129
|
async function convertMetafileToDataUrl(buffer, options2, recursionDepth = 0) {
|
|
44130
|
+
const raster = await renderRaster(buffer, options2, recursionDepth, "convertMetafileToDataUrl");
|
|
44131
|
+
if (!raster) {
|
|
44132
|
+
return null;
|
|
44133
|
+
}
|
|
44134
|
+
try {
|
|
44135
|
+
const url = await exportCanvasToPngDataUrl(raster.canvas);
|
|
44136
|
+
if (!url) {
|
|
44137
|
+
emfWarn("convertMetafileToDataUrl: exportCanvasToPngDataUrl returned null");
|
|
44138
|
+
}
|
|
44139
|
+
return url;
|
|
44140
|
+
} catch (err) {
|
|
44141
|
+
emfWarn("convertMetafileToDataUrl: EXCEPTION:", err instanceof Error ? err.message : err);
|
|
44142
|
+
console.warn("[emf-converter] Conversion failed:", err instanceof Error ? err.message : err);
|
|
44143
|
+
return null;
|
|
44144
|
+
}
|
|
44145
|
+
}
|
|
44146
|
+
async function convertMetafileToJpegDataUrl(buffer, options2) {
|
|
44147
|
+
const raster = await renderRaster(buffer, options2, 0, "convertMetafileToJpegDataUrl");
|
|
44148
|
+
if (!raster) {
|
|
44149
|
+
return null;
|
|
44150
|
+
}
|
|
44151
|
+
try {
|
|
44152
|
+
const { canvas, ctx } = raster;
|
|
44153
|
+
const pixels = canvas instanceof SoftwareRasterCanvas ? canvas.pixels : canvasGetImageData(ctx, 0, 0, canvas.width, canvas.height).data;
|
|
44154
|
+
const jpeg = encodeJpeg(pixels, canvas.width, canvas.height, {
|
|
44155
|
+
quality: options2?.quality,
|
|
44156
|
+
background: parseBackground(options2?.background),
|
|
44157
|
+
chromaSubsampling: options2?.chromaSubsampling
|
|
44158
|
+
});
|
|
44159
|
+
return `data:image/jpeg;base64,${bytesToBase64(jpeg)}`;
|
|
44160
|
+
} catch (err) {
|
|
44161
|
+
emfWarn("convertMetafileToJpegDataUrl: EXCEPTION:", err instanceof Error ? err.message : err);
|
|
44162
|
+
console.warn("[emf-converter] Conversion failed:", err instanceof Error ? err.message : err);
|
|
44163
|
+
return null;
|
|
44164
|
+
}
|
|
44165
|
+
}
|
|
44166
|
+
function parseBackground(color) {
|
|
44167
|
+
if (color === void 0) {
|
|
44168
|
+
return [255, 255, 255];
|
|
44169
|
+
}
|
|
44170
|
+
const hex5 = /^#([0-9a-f]{3}|[0-9a-f]{6})$/i.exec(color.trim())?.[1];
|
|
44171
|
+
if (!hex5) {
|
|
44172
|
+
return [255, 255, 255];
|
|
44173
|
+
}
|
|
44174
|
+
const full = hex5.length === 3 ? [...hex5].map((c) => c + c).join("") : hex5;
|
|
44175
|
+
return [0, 2, 4].map((i) => parseInt(full.slice(i, i + 2), 16));
|
|
44176
|
+
}
|
|
44177
|
+
async function renderRaster(buffer, options2, recursionDepth, caller) {
|
|
43350
44178
|
await ensureNodeCanvasModule();
|
|
43351
44179
|
if (recursionDepth > MAX_METAFILE_RECURSION) {
|
|
43352
44180
|
return null;
|
|
@@ -43376,17 +44204,13 @@ async function convertMetafileToDataUrl(buffer, options2, recursionDepth = 0) {
|
|
|
43376
44204
|
const soft = canvas instanceof SoftwareRasterCanvas ? canvas : null;
|
|
43377
44205
|
if (soft && (soft.textDraws > 0 || !complete)) {
|
|
43378
44206
|
emfWarn(
|
|
43379
|
-
|
|
44207
|
+
`${caller}: no canvas backend and the drawing ${soft.textDraws > 0 ? `contains text (${soft.textDraws} runs)` : "contains an image only a canvas can decode"}; install @napi-rs/canvas for raster output, or use SVG output`
|
|
43380
44208
|
);
|
|
43381
44209
|
return null;
|
|
43382
44210
|
}
|
|
43383
|
-
|
|
43384
|
-
if (!url) {
|
|
43385
|
-
emfWarn("convertMetafileToDataUrl: exportCanvasToPngDataUrl returned null");
|
|
43386
|
-
}
|
|
43387
|
-
return url;
|
|
44211
|
+
return { canvas, ctx: result.surface.ctx };
|
|
43388
44212
|
} catch (err) {
|
|
43389
|
-
emfWarn(
|
|
44213
|
+
emfWarn(`${caller}: EXCEPTION:`, err instanceof Error ? err.message : err);
|
|
43390
44214
|
console.warn("[emf-converter] Conversion failed:", err instanceof Error ? err.message : err);
|
|
43391
44215
|
return null;
|
|
43392
44216
|
}
|
|
@@ -43537,6 +44361,7 @@ async function convertMetafileToSvgDataUrl(buffer, options2) {
|
|
|
43537
44361
|
|
|
43538
44362
|
exports.DEFAULT_DPI_SCALE = DEFAULT_DPI_SCALE;
|
|
43539
44363
|
exports.convertMetafileToDataUrl = convertMetafileToDataUrl;
|
|
44364
|
+
exports.convertMetafileToJpegDataUrl = convertMetafileToJpegDataUrl;
|
|
43540
44365
|
exports.convertMetafileToSvg = convertMetafileToSvg;
|
|
43541
44366
|
exports.convertMetafileToSvgDataUrl = convertMetafileToSvgDataUrl;
|
|
43542
44367
|
exports.convertMetafileToSvgTree = convertMetafileToSvgTree;
|