depixel 0.0.1

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 (3) hide show
  1. package/README.md +61 -0
  2. package/lib.js +1861 -0
  3. package/package.json +20 -0
package/README.md ADDED
@@ -0,0 +1,61 @@
1
+ Kopf-Lischinski "Depixelizing Pixel Art" Node.js version
2
+ =======================
3
+
4
+ Based on the following paper:
5
+ * [Depixelizing Pixel Art](https://johanneskopf.de/publications/pixelart/)
6
+
7
+ And the [source code](https://github.com/falichs/Depixelizing-Pixel-Art-on-GPUs) included with this paper:
8
+ * [Depixelizing Pixel Art on GPUs](https://www.cg.tuwien.ac.at/research/publications/2014/KREUZER-2014-DPA/)
9
+
10
+ Notes
11
+ * Original GPU code is MIT licensed, the same license may apply here, all original code in this project is additionally released under the MIT License
12
+ * Most GPU code semi-automatically converted to JavaScript by Codex (AI)
13
+ * Example below is expanded to 12x via Depixel and then shrunk by 2x with linear filtering (e.g. 2xAA)
14
+
15
+ <img src="./test/test-in-6x-nearest.png"><img src="./test/test-out-6x-bilinear.png">
16
+
17
+ ## API
18
+ ```ts
19
+ type Image = {
20
+ data: Buffer; // Or Uint8Array - pixels in RGBA byte order
21
+ width: number;
22
+ height: number;
23
+ };
24
+
25
+ type Opts = {
26
+ height: number;
27
+ threshold?: number; // 0..255, lower = fewer similarity edges
28
+ borderPx?: number; // pad input with this many pixels (1-2) - useful with `threshold=0` for complete hard edges
29
+ }
30
+
31
+ function scaleImage(src: Image, opts: Opts): Image;
32
+ ```
33
+
34
+ ## Example usage
35
+
36
+ ```js
37
+ const { scaleImage } = require('depixel');
38
+
39
+ let src = new Uint32Array([
40
+ // White on black "x"
41
+ 0xFFFFFFFF, 0x000000FF, 0xFFFFFFFF,
42
+ 0x000000FF, 0xFFFFFFFF, 0x000000FF,
43
+ 0xFFFFFFFF, 0x000000FF, 0xFFFFFFFF,
44
+ ]);
45
+
46
+ let result = scaleImage({
47
+ data: src,
48
+ width: 3,
49
+ height: 3,
50
+ }, {
51
+ height: 3 * 6,
52
+ });
53
+ ```
54
+
55
+ See [test/test.js](test/test.js) for an example including reading and writing from a PNG file.
56
+
57
+ ## Links
58
+
59
+ * https://johanneskopf.de/publications/pixelart/
60
+ * https://github.com/falichs/Depixelizing-Pixel-Art-on-GPUs
61
+ * https://www.cg.tuwien.ac.at/research/publications/2014/KREUZER-2014-DPA/