xbrz-js 1.0.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 ADDED
@@ -0,0 +1,69 @@
1
+ xBRZ JavaScript version
2
+ =======================
3
+
4
+ xBRZ: "Scale by rules" - high quality pixel art upscaling by Zenju
5
+
6
+ Notes
7
+ * Original code is GPL3 licensed, the same license may apply here
8
+ * Currently updated to xBRZ v1.9
9
+ * Some code semi-automatically converted to JavaScript by Codex (AI)
10
+ * Only tested with `xbrzColorFormat.argb` (expects in-memory byte order of `R, G, B, A` or `B, G, R, A`)
11
+
12
+ <img src="./test/test-in.png">
13
+ <img src="./test/test-out.png">
14
+
15
+ ## API
16
+ ```ts
17
+ enum xbrzColorFormat {
18
+ argb,
19
+ };
20
+
21
+ type XbrzConfig = {
22
+ equalColorTolerance: number;
23
+ centerDirectionBias: number;
24
+ steepDirectionThreshold: number;
25
+ dominantDirectionThreshold: number;
26
+ };
27
+ function xbrzConfig(opts?: Partial<XbrzConfig>): XbrzConfig;
28
+
29
+ function xbrzScale(
30
+ scale: number,
31
+ src: Uint32Array,
32
+ dst: Uint32Array,
33
+ width: number,
34
+ height: number,
35
+ colorFormat: xbrzColorFormat,
36
+ config?: XbrzConfig,
37
+ ): void;
38
+ ```
39
+
40
+ ## Example usage
41
+
42
+ ```js
43
+ const { xbrzScale, xbrzColorFormat, xbrzConfig } = require('xbrz');
44
+
45
+ let config = xbrzConfig({
46
+ // these are the defaults, xbrzConfig({}) or null would work as well
47
+ equalColorTolerance: 30,
48
+ centerDirectionBias: 4,
49
+ steepDirectionThreshold: 2.4,
50
+ dominantDirectionThreshold: 3.6,
51
+ });
52
+
53
+ let src = new Uint32Array([
54
+ // White on black "x"
55
+ 0xFFFFFFFF, 0x000000FF, 0xFFFFFFFF,
56
+ 0x000000FF, 0xFFFFFFFF, 0x000000FF,
57
+ 0xFFFFFFFF, 0x000000FF, 0xFFFFFFFF,
58
+ ]);
59
+
60
+ let scale = 6;
61
+ let dst = new Uint32Array(3*scale * 3*scale);
62
+ xbrzScale(scale, src, dst, 3, 3, xbrzColorFormat.argb, config);
63
+ ```
64
+
65
+ See [test/test.js](test/test.js) for an example including reading and writing from a PNG file.
66
+
67
+ ## Links
68
+
69
+ https://sourceforge.net/projects/xbrz/
package/lib.js ADDED
@@ -0,0 +1,9 @@
1
+ const { ScalerCfgDefault } = require('./src/xbrz_config.js');
2
+ exports.xbrzScale = require('./src/xbrz.js').xbrzScale;
3
+ exports.xbrzConfig = function (params) {
4
+ return {
5
+ ...ScalerCfgDefault,
6
+ ...params,
7
+ };
8
+ }
9
+ exports.xbrzColorFormat = require('./src/xbrz_h.js').ColorFormat;
package/package.json ADDED
@@ -0,0 +1,17 @@
1
+ {
2
+ "name": "xbrz-js",
3
+ "version": "1.0.0",
4
+ "descript": "xBRZ - Scale by rules - pure JS implementation of high quality pixel art upscaling by Zenju",
5
+ "main": "lib.js",
6
+ "keywords": [
7
+ "xbrz",
8
+ "pixel",
9
+ "upscale"
10
+ ],
11
+ "author": "Jimb Esser (https://github.com/Jimbly)",
12
+ "repository": {
13
+ "type": "git",
14
+ "url": "git+https://github.com/Jimbly/xbrz-js.git"
15
+ },
16
+ "license": "GPL3"
17
+ }