@lexmata/micropdf 0.4.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.
Files changed (170) hide show
  1. package/LICENSE +191 -0
  2. package/README.md +985 -0
  3. package/binding.gyp +73 -0
  4. package/dist/annot.d.ts +458 -0
  5. package/dist/annot.d.ts.map +1 -0
  6. package/dist/annot.js +697 -0
  7. package/dist/annot.js.map +1 -0
  8. package/dist/archive.d.ts +128 -0
  9. package/dist/archive.d.ts.map +1 -0
  10. package/dist/archive.js +268 -0
  11. package/dist/archive.js.map +1 -0
  12. package/dist/buffer.d.ts +572 -0
  13. package/dist/buffer.d.ts.map +1 -0
  14. package/dist/buffer.js +971 -0
  15. package/dist/buffer.js.map +1 -0
  16. package/dist/colorspace.d.ts +287 -0
  17. package/dist/colorspace.d.ts.map +1 -0
  18. package/dist/colorspace.js +542 -0
  19. package/dist/colorspace.js.map +1 -0
  20. package/dist/context.d.ts +184 -0
  21. package/dist/context.d.ts.map +1 -0
  22. package/dist/context.js +320 -0
  23. package/dist/context.js.map +1 -0
  24. package/dist/cookie.d.ts +164 -0
  25. package/dist/cookie.d.ts.map +1 -0
  26. package/dist/cookie.js +306 -0
  27. package/dist/cookie.js.map +1 -0
  28. package/dist/device.d.ts +169 -0
  29. package/dist/device.d.ts.map +1 -0
  30. package/dist/device.js +350 -0
  31. package/dist/device.js.map +1 -0
  32. package/dist/display-list.d.ts +202 -0
  33. package/dist/display-list.d.ts.map +1 -0
  34. package/dist/display-list.js +410 -0
  35. package/dist/display-list.js.map +1 -0
  36. package/dist/document.d.ts +637 -0
  37. package/dist/document.d.ts.map +1 -0
  38. package/dist/document.js +902 -0
  39. package/dist/document.js.map +1 -0
  40. package/dist/easy.d.ts +423 -0
  41. package/dist/easy.d.ts.map +1 -0
  42. package/dist/easy.js +644 -0
  43. package/dist/easy.js.map +1 -0
  44. package/dist/enhanced.d.ts +226 -0
  45. package/dist/enhanced.d.ts.map +1 -0
  46. package/dist/enhanced.js +368 -0
  47. package/dist/enhanced.js.map +1 -0
  48. package/dist/filter.d.ts +51 -0
  49. package/dist/filter.d.ts.map +1 -0
  50. package/dist/filter.js +381 -0
  51. package/dist/filter.js.map +1 -0
  52. package/dist/font.d.ts +222 -0
  53. package/dist/font.d.ts.map +1 -0
  54. package/dist/font.js +381 -0
  55. package/dist/font.js.map +1 -0
  56. package/dist/form.d.ts +214 -0
  57. package/dist/form.d.ts.map +1 -0
  58. package/dist/form.js +497 -0
  59. package/dist/form.js.map +1 -0
  60. package/dist/geometry.d.ts +469 -0
  61. package/dist/geometry.d.ts.map +1 -0
  62. package/dist/geometry.js +780 -0
  63. package/dist/geometry.js.map +1 -0
  64. package/dist/image.d.ts +172 -0
  65. package/dist/image.d.ts.map +1 -0
  66. package/dist/image.js +348 -0
  67. package/dist/image.js.map +1 -0
  68. package/dist/index.d.ts +171 -0
  69. package/dist/index.d.ts.map +1 -0
  70. package/dist/index.js +339 -0
  71. package/dist/index.js.map +1 -0
  72. package/dist/link.d.ts +168 -0
  73. package/dist/link.d.ts.map +1 -0
  74. package/dist/link.js +343 -0
  75. package/dist/link.js.map +1 -0
  76. package/dist/micropdf.d.ts +40 -0
  77. package/dist/micropdf.d.ts.map +1 -0
  78. package/dist/micropdf.js +45 -0
  79. package/dist/micropdf.js.map +1 -0
  80. package/dist/nanopdf.d.ts +40 -0
  81. package/dist/nanopdf.d.ts.map +1 -0
  82. package/dist/nanopdf.js +45 -0
  83. package/dist/nanopdf.js.map +1 -0
  84. package/dist/native.d.ts +242 -0
  85. package/dist/native.d.ts.map +1 -0
  86. package/dist/native.js +509 -0
  87. package/dist/native.js.map +1 -0
  88. package/dist/output.d.ts +166 -0
  89. package/dist/output.d.ts.map +1 -0
  90. package/dist/output.js +365 -0
  91. package/dist/output.js.map +1 -0
  92. package/dist/path.d.ts +420 -0
  93. package/dist/path.d.ts.map +1 -0
  94. package/dist/path.js +687 -0
  95. package/dist/path.js.map +1 -0
  96. package/dist/pdf/object.d.ts +489 -0
  97. package/dist/pdf/object.d.ts.map +1 -0
  98. package/dist/pdf/object.js +1045 -0
  99. package/dist/pdf/object.js.map +1 -0
  100. package/dist/pixmap.d.ts +315 -0
  101. package/dist/pixmap.d.ts.map +1 -0
  102. package/dist/pixmap.js +590 -0
  103. package/dist/pixmap.js.map +1 -0
  104. package/dist/profiler.d.ts +159 -0
  105. package/dist/profiler.d.ts.map +1 -0
  106. package/dist/profiler.js +380 -0
  107. package/dist/profiler.js.map +1 -0
  108. package/dist/render-options.d.ts +227 -0
  109. package/dist/render-options.d.ts.map +1 -0
  110. package/dist/render-options.js +130 -0
  111. package/dist/render-options.js.map +1 -0
  112. package/dist/resource-tracking.d.ts +332 -0
  113. package/dist/resource-tracking.d.ts.map +1 -0
  114. package/dist/resource-tracking.js +653 -0
  115. package/dist/resource-tracking.js.map +1 -0
  116. package/dist/simple.d.ts +276 -0
  117. package/dist/simple.d.ts.map +1 -0
  118. package/dist/simple.js +343 -0
  119. package/dist/simple.js.map +1 -0
  120. package/dist/stext.d.ts +290 -0
  121. package/dist/stext.d.ts.map +1 -0
  122. package/dist/stext.js +312 -0
  123. package/dist/stext.js.map +1 -0
  124. package/dist/stream.d.ts +174 -0
  125. package/dist/stream.d.ts.map +1 -0
  126. package/dist/stream.js +476 -0
  127. package/dist/stream.js.map +1 -0
  128. package/dist/text.d.ts +337 -0
  129. package/dist/text.d.ts.map +1 -0
  130. package/dist/text.js +454 -0
  131. package/dist/text.js.map +1 -0
  132. package/dist/typed-arrays.d.ts +127 -0
  133. package/dist/typed-arrays.d.ts.map +1 -0
  134. package/dist/typed-arrays.js +410 -0
  135. package/dist/typed-arrays.js.map +1 -0
  136. package/dist/types.d.ts +358 -0
  137. package/dist/types.d.ts.map +1 -0
  138. package/dist/types.js +216 -0
  139. package/dist/types.js.map +1 -0
  140. package/native/annot.cc +557 -0
  141. package/native/buffer.cc +204 -0
  142. package/native/colorspace.cc +166 -0
  143. package/native/context.cc +84 -0
  144. package/native/cookie.cc +179 -0
  145. package/native/device.cc +179 -0
  146. package/native/display_list.cc +179 -0
  147. package/native/document.cc +268 -0
  148. package/native/enhanced.cc +70 -0
  149. package/native/font.cc +282 -0
  150. package/native/form.cc +523 -0
  151. package/native/geometry.cc +255 -0
  152. package/native/image.cc +216 -0
  153. package/native/include/micropdf/enhanced.h +38 -0
  154. package/native/include/micropdf/types.h +36 -0
  155. package/native/include/micropdf.h +106 -0
  156. package/native/include/mupdf-ffi.h +39 -0
  157. package/native/include/mupdf.h +11 -0
  158. package/native/include/mupdf_minimal.h +381 -0
  159. package/native/lib/linux-x64/libmicropdf.a +0 -0
  160. package/native/link.cc +234 -0
  161. package/native/micropdf.cc +71 -0
  162. package/native/output.cc +229 -0
  163. package/native/page.cc +572 -0
  164. package/native/path.cc +259 -0
  165. package/native/pixmap.cc +240 -0
  166. package/native/stext.cc +610 -0
  167. package/native/stream.cc +239 -0
  168. package/package.json +120 -0
  169. package/scripts/build-from-rust.js +97 -0
  170. package/scripts/install.js +184 -0
package/dist/pixmap.js ADDED
@@ -0,0 +1,590 @@
1
+ /**
2
+ * Pixmap - Raster image handling and pixel manipulation
3
+ *
4
+ * This module provides comprehensive support for working with raster images (pixmaps)
5
+ * in PDF documents. Pixmaps represent pixel-based images with support for various
6
+ * colorspaces, alpha channels, and pixel-level manipulation.
7
+ *
8
+ * This module provides 100% API compatibility with MuPDF's pixmap operations.
9
+ *
10
+ * @module pixmap
11
+ * @example
12
+ * ```typescript
13
+ * import { Pixmap, Colorspace, Rect } from 'micropdf';
14
+ *
15
+ * // Create a pixmap from a page
16
+ * const page = doc.loadPage(0);
17
+ * const pixmap = page.toPixmap(Matrix.identity());
18
+ *
19
+ * // Create an empty pixmap
20
+ * const empty = Pixmap.create(Colorspace.deviceRGB(), 100, 100, true);
21
+ *
22
+ * // Get pixel data
23
+ * const width = pixmap.width;
24
+ * const height = pixmap.height;
25
+ * const data = pixmap.samples;
26
+ *
27
+ * // Manipulate pixels
28
+ * for (let y = 0; y < height; y++) {
29
+ * for (let x = 0; x < width; x++) {
30
+ * const pixel = pixmap.getPixel(x, y);
31
+ * // Modify pixel...
32
+ * pixmap.setPixel(x, y, [r, g, b, a]);
33
+ * }
34
+ * }
35
+ *
36
+ * // Convert colorspace
37
+ * const gray = pixmap.convert(Colorspace.deviceGray());
38
+ *
39
+ * // Scale
40
+ * const thumbnail = pixmap.scale(50, 50);
41
+ *
42
+ * // Clean up
43
+ * pixmap.drop();
44
+ * gray.drop();
45
+ * thumbnail.drop();
46
+ * ```
47
+ */
48
+ import { Rect, IRect } from './geometry.js';
49
+ /**
50
+ * A raster image with pixel-level manipulation capabilities.
51
+ *
52
+ * Pixmap represents a rectangular array of pixels with an associated colorspace
53
+ * and optional alpha channel. Pixmaps are used for rendering PDF pages, working
54
+ * with images, and performing pixel-level image processing.
55
+ *
56
+ * **Key Features:**
57
+ * - Multiple colorspace support (Gray, RGB, CMYK, etc.)
58
+ * - Optional alpha channel for transparency
59
+ * - Pixel-level read/write access
60
+ * - Colorspace conversion
61
+ * - Scaling and transformation
62
+ * - Tinting and color manipulation
63
+ *
64
+ * **Memory Layout**: Pixels are stored row-by-row, left-to-right, with components
65
+ * interleaved. For RGB with alpha, the order is: R₁G₁B₁A₁, R₂G₂B₂A₂, ...
66
+ *
67
+ * **Reference Counting**: Pixmaps use manual reference counting. Call `keep()` to
68
+ * increment the reference count and `drop()` to decrement it.
69
+ *
70
+ * @class Pixmap
71
+ * @example
72
+ * ```typescript
73
+ * // Render a PDF page to a pixmap
74
+ * const doc = Document.open('document.pdf');
75
+ * const page = doc.loadPage(0);
76
+ * const matrix = Matrix.scale(2, 2); // 2x zoom
77
+ * const pixmap = page.toPixmap(matrix, Colorspace.deviceRGB(), true);
78
+ *
79
+ * console.log(`Size: ${pixmap.width} x ${pixmap.height}`);
80
+ * console.log(`Components: ${pixmap.n}`); // 4 for RGBA
81
+ * console.log(`Has alpha: ${pixmap.alpha}`);
82
+ *
83
+ * // Access pixel data
84
+ * const samples = pixmap.samples; // Uint8Array
85
+ * const pixel = pixmap.getPixel(10, 10); // [r, g, b, a]
86
+ *
87
+ * // Modify a pixel
88
+ * pixmap.setPixel(10, 10, [255, 0, 0, 255]); // Red pixel
89
+ *
90
+ * // Convert to grayscale
91
+ * const gray = pixmap.convert(Colorspace.deviceGray());
92
+ *
93
+ * // Create thumbnail
94
+ * const thumb = pixmap.scale(100, 100);
95
+ *
96
+ * // Clean up
97
+ * pixmap.drop();
98
+ * gray.drop();
99
+ * thumb.drop();
100
+ * page.drop();
101
+ * doc.close();
102
+ * ```
103
+ *
104
+ * @example
105
+ * ```typescript
106
+ * // Create a blank red image
107
+ * const pixmap = Pixmap.create(
108
+ * Colorspace.deviceRGB(),
109
+ * 200,
110
+ * 200,
111
+ * false // No alpha
112
+ * );
113
+ *
114
+ * // Fill with red
115
+ * for (let y = 0; y < pixmap.height; y++) {
116
+ * for (let x = 0; x < pixmap.width; x++) {
117
+ * pixmap.setPixel(x, y, [255, 0, 0]); // Red
118
+ * }
119
+ * }
120
+ *
121
+ * // Convert to RGBA
122
+ * const rgba = pixmap.toRGBA();
123
+ * console.log(rgba.length); // 200 * 200 * 4 = 160,000 bytes
124
+ * ```
125
+ *
126
+ * @example
127
+ * ```typescript
128
+ * // Load from raw sample data
129
+ * const width = 2, height = 2;
130
+ * const samples = new Uint8Array([
131
+ * 255, 0, 0, 255, // Red pixel
132
+ * 0, 255, 0, 255, // Green pixel
133
+ * 0, 0, 255, 255, // Blue pixel
134
+ * 255, 255, 0, 255 // Yellow pixel
135
+ * ]);
136
+ *
137
+ * const pixmap = Pixmap.fromSamples(
138
+ * Colorspace.deviceRGB(),
139
+ * width,
140
+ * height,
141
+ * true,
142
+ * samples
143
+ * );
144
+ *
145
+ * // Tint with red and white
146
+ * pixmap.tint([255, 0, 0], [255, 255, 255]);
147
+ * ```
148
+ */
149
+ export class Pixmap {
150
+ _width;
151
+ _height;
152
+ _x = 0;
153
+ _y = 0;
154
+ _colorspace;
155
+ _alpha;
156
+ _data;
157
+ _xres = 96;
158
+ _yres = 96;
159
+ _refCount = 1;
160
+ constructor(colorspace, width, height, alpha = true, x = 0, y = 0) {
161
+ this._colorspace = colorspace;
162
+ this._width = width;
163
+ this._height = height;
164
+ this._alpha = alpha;
165
+ this._x = x;
166
+ this._y = y;
167
+ const stride = colorspace.n + (alpha ? 1 : 0);
168
+ this._data = new Uint8Array(width * height * stride);
169
+ }
170
+ /**
171
+ * Create a new pixmap
172
+ */
173
+ static create(colorspace, width, height, alpha = true) {
174
+ return new Pixmap(colorspace, width, height, alpha);
175
+ }
176
+ /**
177
+ * Create pixmap with bounding box
178
+ */
179
+ static createWithBBox(colorspace, bbox, alpha = true) {
180
+ const b = IRect.from(bbox);
181
+ return new Pixmap(colorspace, b.width, b.height, alpha, b.x0, b.y0);
182
+ }
183
+ /**
184
+ * Create pixmap with bounding box (lowercase alias)
185
+ */
186
+ static createWithBbox(colorspace, bbox, alpha = true) {
187
+ return Pixmap.createWithBBox(colorspace, bbox, alpha);
188
+ }
189
+ /**
190
+ * Create pixmap from sample data
191
+ */
192
+ static fromSamples(colorspace, width, height, alpha, samples) {
193
+ const pixmap = new Pixmap(colorspace, width, height, alpha);
194
+ pixmap._data = new Uint8Array(samples);
195
+ return pixmap;
196
+ }
197
+ // ============================================================================
198
+ // Reference Counting
199
+ // ============================================================================
200
+ keep() {
201
+ this._refCount++;
202
+ return this;
203
+ }
204
+ drop() {
205
+ if (this._refCount > 0) {
206
+ this._refCount--;
207
+ }
208
+ }
209
+ /**
210
+ * Clone this pixmap
211
+ */
212
+ clone() {
213
+ const cloned = new Pixmap(this._colorspace, this._width, this._height, this._alpha, this._x, this._y);
214
+ cloned._data = new Uint8Array(this._data);
215
+ cloned._xres = this._xres;
216
+ cloned._yres = this._yres;
217
+ return cloned;
218
+ }
219
+ // ============================================================================
220
+ // Properties
221
+ // ============================================================================
222
+ get x() {
223
+ return this._x;
224
+ }
225
+ get y() {
226
+ return this._y;
227
+ }
228
+ get width() {
229
+ return this._width;
230
+ }
231
+ get height() {
232
+ return this._height;
233
+ }
234
+ get colorspace() {
235
+ return this._colorspace;
236
+ }
237
+ /**
238
+ * Get number of components (colorants + alpha if present)
239
+ */
240
+ get components() {
241
+ return this._colorspace.n + (this._alpha ? 1 : 0);
242
+ }
243
+ /**
244
+ * Get number of colorant components (excluding alpha) - alias for components
245
+ */
246
+ get n() {
247
+ return this.components;
248
+ }
249
+ /**
250
+ * Get number of colorant components (excluding alpha)
251
+ */
252
+ get colorants() {
253
+ return this._colorspace.n;
254
+ }
255
+ /**
256
+ * Check if pixmap has alpha channel
257
+ */
258
+ get hasAlpha() {
259
+ return this._alpha;
260
+ }
261
+ /**
262
+ * Check if pixmap has alpha channel (short alias)
263
+ */
264
+ get alpha() {
265
+ return this._alpha;
266
+ }
267
+ /**
268
+ * Get stride (bytes per row)
269
+ */
270
+ get stride() {
271
+ return this._width * this.components;
272
+ }
273
+ /**
274
+ * Get raw pixel data
275
+ */
276
+ get data() {
277
+ return this._data;
278
+ }
279
+ /**
280
+ * Get samples (pixel data) - alias for data
281
+ */
282
+ get samples() {
283
+ return this._data;
284
+ }
285
+ /**
286
+ * Get bounding box
287
+ */
288
+ getBounds() {
289
+ return new Rect(this._x, this._y, this._x + this._width, this._y + this._height);
290
+ }
291
+ /**
292
+ * Get integer bounding box
293
+ */
294
+ getBBox() {
295
+ return new IRect(this._x, this._y, this._x + this._width, this._y + this._height);
296
+ }
297
+ // ============================================================================
298
+ // Resolution
299
+ // ============================================================================
300
+ get xres() {
301
+ return this._xres;
302
+ }
303
+ set xres(res) {
304
+ this._xres = Math.max(1, res);
305
+ }
306
+ get yres() {
307
+ return this._yres;
308
+ }
309
+ set yres(res) {
310
+ this._yres = Math.max(1, res);
311
+ }
312
+ /**
313
+ * Get resolution as [xres, yres]
314
+ */
315
+ getResolution() {
316
+ return [this._xres, this._yres];
317
+ }
318
+ /**
319
+ * Set resolution
320
+ */
321
+ setResolution(xres, yres) {
322
+ this._xres = Math.max(1, xres);
323
+ this._yres = Math.max(1, yres);
324
+ }
325
+ // ============================================================================
326
+ // Sample Access
327
+ // ============================================================================
328
+ /**
329
+ * Get a single sample value
330
+ */
331
+ getSample(x, y, component) {
332
+ if (x < 0 || x >= this._width || y < 0 || y >= this._height) {
333
+ return 0;
334
+ }
335
+ if (component < 0 || component >= this.components) {
336
+ return 0;
337
+ }
338
+ const offset = (y * this._width + x) * this.components + component;
339
+ return this._data[offset] || 0;
340
+ }
341
+ /**
342
+ * Set a single sample value
343
+ */
344
+ setSample(x, y, component, value) {
345
+ if (x < 0 || x >= this._width || y < 0 || y >= this._height) {
346
+ return;
347
+ }
348
+ if (component < 0 || component >= this.components) {
349
+ return;
350
+ }
351
+ const offset = (y * this._width + x) * this.components + component;
352
+ this._data[offset] = Math.max(0, Math.min(255, value));
353
+ }
354
+ /**
355
+ * Get all samples for a pixel
356
+ */
357
+ getPixel(x, y) {
358
+ const pixel = [];
359
+ for (let c = 0; c < this.components; c++) {
360
+ pixel.push(this.getSample(x, y, c));
361
+ }
362
+ return pixel;
363
+ }
364
+ /**
365
+ * Set all samples for a pixel
366
+ */
367
+ setPixel(x, y, values) {
368
+ for (let c = 0; c < Math.min(this.components, values.length); c++) {
369
+ this.setSample(x, y, c, values[c]);
370
+ }
371
+ }
372
+ // ============================================================================
373
+ // Clearing and Filling
374
+ // ============================================================================
375
+ /**
376
+ * Clear pixmap to transparent/white
377
+ */
378
+ clear() {
379
+ if (this._alpha) {
380
+ // Clear to transparent (all zeros)
381
+ this._data.fill(0);
382
+ }
383
+ else {
384
+ // Clear to white (all 255)
385
+ this._data.fill(255);
386
+ }
387
+ }
388
+ /**
389
+ * Clear pixmap to specific value
390
+ */
391
+ clearWithValue(value) {
392
+ this._data.fill(value);
393
+ }
394
+ // ============================================================================
395
+ // Transformations
396
+ // ============================================================================
397
+ /**
398
+ * Invert pixmap colors
399
+ */
400
+ invert() {
401
+ const colorants = this._colorspace.n;
402
+ for (let i = 0; i < this._data.length; i++) {
403
+ // Invert colorants but not alpha
404
+ if (i % this.components < colorants) {
405
+ this._data[i] = 255 - this._data[i];
406
+ }
407
+ }
408
+ }
409
+ /**
410
+ * Apply gamma correction
411
+ */
412
+ gamma(gamma) {
413
+ const colorants = this._colorspace.n;
414
+ const invGamma = 1.0 / gamma;
415
+ for (let i = 0; i < this._data.length; i++) {
416
+ // Apply gamma to colorants but not alpha
417
+ if (i % this.components < colorants) {
418
+ const normalized = this._data[i] / 255;
419
+ const corrected = Math.pow(normalized, invGamma);
420
+ this._data[i] = Math.round(corrected * 255);
421
+ }
422
+ }
423
+ }
424
+ /**
425
+ * Tint pixmap with a color
426
+ */
427
+ tint(black, white) {
428
+ if (!this._colorspace) {
429
+ return; // No colorspace, cannot tint
430
+ }
431
+ if (black.length !== this._colorspace.n || white.length !== this._colorspace.n) {
432
+ return;
433
+ }
434
+ const colorants = this._colorspace.n;
435
+ const components = this.components;
436
+ for (let y = 0; y < this._height; y++) {
437
+ for (let x = 0; x < this._width; x++) {
438
+ const offset = (y * this._width + x) * components;
439
+ for (let c = 0; c < colorants; c++) {
440
+ const gray = this._data[offset + c] / 255;
441
+ const tinted = black[c] * (1 - gray) + white[c] * gray;
442
+ this._data[offset + c] = Math.round(tinted * 255);
443
+ }
444
+ }
445
+ }
446
+ }
447
+ // ============================================================================
448
+ // Conversion
449
+ // ============================================================================
450
+ /**
451
+ * Convert pixmap to another colorspace
452
+ */
453
+ convert(destColorspace) {
454
+ const converted = new Pixmap(destColorspace, this._width, this._height, this._alpha, this._x, this._y);
455
+ converted._xres = this._xres;
456
+ converted._yres = this._yres;
457
+ const srcComponents = this.components;
458
+ const dstComponents = converted.components;
459
+ const srcColorants = this._colorspace.n;
460
+ const dstColorants = destColorspace.n;
461
+ for (let y = 0; y < this._height; y++) {
462
+ for (let x = 0; x < this._width; x++) {
463
+ const srcOffset = (y * this._width + x) * srcComponents;
464
+ const dstOffset = (y * this._width + x) * dstComponents;
465
+ // Extract source color
466
+ const srcColor = [];
467
+ for (let c = 0; c < srcColorants; c++) {
468
+ srcColor.push(this._data[srcOffset + c] / 255);
469
+ }
470
+ // Convert color
471
+ const dstColor = this._colorspace.convertColor(destColorspace, srcColor);
472
+ // Store destination color
473
+ for (let c = 0; c < dstColorants; c++) {
474
+ converted._data[dstOffset + c] = Math.round(dstColor[c] * 255);
475
+ }
476
+ // Copy alpha if present
477
+ if (this._alpha && converted._alpha) {
478
+ converted._data[dstOffset + dstColorants] = this._data[srcOffset + srcColorants];
479
+ }
480
+ }
481
+ }
482
+ return converted;
483
+ }
484
+ /**
485
+ * Convert pixmap to RGBA format
486
+ */
487
+ toRGBA() {
488
+ // If already RGBA, return a copy
489
+ if (this._colorspace.n === 3 && this._alpha) {
490
+ return new Uint8Array(this._data);
491
+ }
492
+ // Convert to RGB with alpha
493
+ const rgbaData = new Uint8Array(this._width * this._height * 4);
494
+ const srcComponents = this.components;
495
+ for (let y = 0; y < this._height; y++) {
496
+ for (let x = 0; x < this._width; x++) {
497
+ const srcOffset = (y * this._width + x) * srcComponents;
498
+ const dstOffset = (y * this._width + x) * 4;
499
+ if (this._colorspace.n === 1) {
500
+ // Grayscale to RGB
501
+ const gray = this._data[srcOffset];
502
+ rgbaData[dstOffset] = gray; // R
503
+ rgbaData[dstOffset + 1] = gray; // G
504
+ rgbaData[dstOffset + 2] = gray; // B
505
+ rgbaData[dstOffset + 3] = this._alpha ? this._data[srcOffset + 1] : 255; // A
506
+ }
507
+ else if (this._colorspace.n === 3) {
508
+ // RGB to RGBA
509
+ rgbaData[dstOffset] = this._data[srcOffset]; // R
510
+ rgbaData[dstOffset + 1] = this._data[srcOffset + 1]; // G
511
+ rgbaData[dstOffset + 2] = this._data[srcOffset + 2]; // B
512
+ rgbaData[dstOffset + 3] = this._alpha ? this._data[srcOffset + 3] : 255; // A
513
+ }
514
+ else {
515
+ // Other colorspaces - default to white with alpha
516
+ rgbaData[dstOffset] = 255;
517
+ rgbaData[dstOffset + 1] = 255;
518
+ rgbaData[dstOffset + 2] = 255;
519
+ rgbaData[dstOffset + 3] = this._alpha ? this._data[srcOffset + this._colorspace.n] : 255;
520
+ }
521
+ }
522
+ }
523
+ return rgbaData;
524
+ }
525
+ /**
526
+ * Scale pixmap to new dimensions
527
+ */
528
+ scale(width, height) {
529
+ const scaled = new Pixmap(this._colorspace, width, height, this._alpha, this._x, this._y);
530
+ scaled._xres = this._xres;
531
+ scaled._yres = this._yres;
532
+ const xRatio = this._width / width;
533
+ const yRatio = this._height / height;
534
+ const components = this.components;
535
+ // Nearest neighbor scaling (simplified)
536
+ for (let y = 0; y < height; y++) {
537
+ for (let x = 0; x < width; x++) {
538
+ const srcX = Math.floor(x * xRatio);
539
+ const srcY = Math.floor(y * yRatio);
540
+ const srcOffset = (srcY * this._width + srcX) * components;
541
+ const dstOffset = (y * width + x) * components;
542
+ for (let c = 0; c < components; c++) {
543
+ scaled._data[dstOffset + c] = this._data[srcOffset + c];
544
+ }
545
+ }
546
+ }
547
+ return scaled;
548
+ }
549
+ // ============================================================================
550
+ // Validation
551
+ // ============================================================================
552
+ /**
553
+ * Check if pixmap is valid
554
+ */
555
+ isValid() {
556
+ if (this._width <= 0 || this._height <= 0) {
557
+ return false;
558
+ }
559
+ if (!this._colorspace?.isValid()) {
560
+ return false;
561
+ }
562
+ if (this._data.length !== this._width * this._height * this.components) {
563
+ return false;
564
+ }
565
+ return true;
566
+ }
567
+ // ============================================================================
568
+ // Information
569
+ // ============================================================================
570
+ /**
571
+ * Get pixmap info
572
+ */
573
+ getInfo() {
574
+ return {
575
+ x: this._x,
576
+ y: this._y,
577
+ width: this._width,
578
+ height: this._height,
579
+ colorspace: this._colorspace,
580
+ components: this.components,
581
+ colorants: this.colorants,
582
+ hasAlpha: this._alpha,
583
+ stride: this.stride,
584
+ xres: this._xres,
585
+ yres: this._yres,
586
+ size: this._data.length
587
+ };
588
+ }
589
+ }
590
+ //# sourceMappingURL=pixmap.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pixmap.js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