xbrz-js 1.9.1 → 1.9.2
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 +3 -2
- package/package.json +3 -2
- package/src/xbrz.js +5 -3
- package/src/xbrz_config.js +1 -0
package/README.md
CHANGED
|
@@ -9,8 +9,7 @@ Notes
|
|
|
9
9
|
* Some code semi-automatically converted to JavaScript by Codex (AI)
|
|
10
10
|
* Only tested with `xbrzColorFormat.argb` (expects in-memory byte order of `R, G, B, A` or `B, G, R, A`)
|
|
11
11
|
|
|
12
|
-
<img src="
|
|
13
|
-
<img src="./test/test-out.png">
|
|
12
|
+
<img src="https://github.com/Jimbly/xbrz-js/blob/HEAD/test/test-in-6x-nearest.png"><img src="https://github.com/Jimbly/xbrz-js/blob/HEAD/test/test-out.png">
|
|
14
13
|
|
|
15
14
|
## API
|
|
16
15
|
```ts
|
|
@@ -23,6 +22,7 @@ type XbrzConfig = {
|
|
|
23
22
|
centerDirectionBias: number;
|
|
24
23
|
steepDirectionThreshold: number;
|
|
25
24
|
dominantDirectionThreshold: number;
|
|
25
|
+
oobRead: 'auto' | 'duplicate' | 'transparent',
|
|
26
26
|
};
|
|
27
27
|
function xbrzConfig(opts?: Partial<XbrzConfig>): XbrzConfig;
|
|
28
28
|
|
|
@@ -48,6 +48,7 @@ let config = xbrzConfig({
|
|
|
48
48
|
centerDirectionBias: 4,
|
|
49
49
|
steepDirectionThreshold: 2.4,
|
|
50
50
|
dominantDirectionThreshold: 3.6,
|
|
51
|
+
oobRead: 'auto',
|
|
51
52
|
});
|
|
52
53
|
|
|
53
54
|
let src = new Uint32Array([
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "xbrz-js",
|
|
3
|
-
"version": "1.9.
|
|
3
|
+
"version": "1.9.2",
|
|
4
4
|
"description": "xBRZ - Scale by rules - pure JS implementation of high quality pixel art upscaling by Zenju",
|
|
5
5
|
"main": "lib.js",
|
|
6
6
|
"keywords": [
|
|
@@ -9,9 +9,10 @@
|
|
|
9
9
|
"upscale"
|
|
10
10
|
],
|
|
11
11
|
"author": "Jimb Esser (https://github.com/Jimbly)",
|
|
12
|
+
"homepage": "https://github.com/Jimbly/xbrz-js#readme",
|
|
12
13
|
"repository": {
|
|
13
14
|
"type": "git",
|
|
14
|
-
"url": "git+https://github.com/Jimbly/
|
|
15
|
+
"url": "git+https://github.com/Jimbly/npm-publish.git"
|
|
15
16
|
},
|
|
16
17
|
"scripts": {
|
|
17
18
|
"test": "cd test && node test.js"
|
package/src/xbrz.js
CHANGED
|
@@ -760,6 +760,8 @@ function xbrzScale(factor, src, trg, srcWidth, srcHeight, colFmt, cfg, yFirst, y
|
|
|
760
760
|
const cfgUse = cfg || ScalerCfgDefault;
|
|
761
761
|
const yFirstUse = yFirst == null ? 0 : yFirst;
|
|
762
762
|
const yLastUse = yLast == null ? srcHeight : Math.min(yLast, srcHeight);
|
|
763
|
+
const oobReadUse = cfgUse.oobRead === 'auto' ? colFmt === ColorFormat.rgb ? 'duplicate' : 'transparent' : cfgUse.oobRead;
|
|
764
|
+
const oobReader = oobReadUse === 'duplicate' ? OobReaderDuplicate : OobReaderTransparent;
|
|
763
765
|
|
|
764
766
|
assert.equal(SCALE_FACTOR_MAX, 6);
|
|
765
767
|
|
|
@@ -767,19 +769,19 @@ function xbrzScale(factor, src, trg, srcWidth, srcHeight, colFmt, cfg, yFirst, y
|
|
|
767
769
|
case ColorFormat.rgb: {
|
|
768
770
|
const scaler = makeScalerForFormat(factor, ColorFormat.rgb);
|
|
769
771
|
if (!scaler) break;
|
|
770
|
-
scaleImage(scaler, ColorDistanceRGB,
|
|
772
|
+
scaleImage(scaler, ColorDistanceRGB, oobReader, src, trg, srcWidth, srcHeight, cfgUse, yFirstUse, yLastUse);
|
|
771
773
|
return;
|
|
772
774
|
}
|
|
773
775
|
case ColorFormat.argb: {
|
|
774
776
|
const scaler = makeScalerForFormat(factor, ColorFormat.argb);
|
|
775
777
|
if (!scaler) break;
|
|
776
|
-
scaleImage(scaler, ColorDistanceARGB,
|
|
778
|
+
scaleImage(scaler, ColorDistanceARGB, oobReader, src, trg, srcWidth, srcHeight, cfgUse, yFirstUse, yLastUse);
|
|
777
779
|
return;
|
|
778
780
|
}
|
|
779
781
|
case ColorFormat.argbUnbuffered: {
|
|
780
782
|
const scaler = makeScalerForFormat(factor, ColorFormat.argb);
|
|
781
783
|
if (!scaler) break;
|
|
782
|
-
scaleImage(scaler, ColorDistanceUnbufferedARGB,
|
|
784
|
+
scaleImage(scaler, ColorDistanceUnbufferedARGB, oobReader, src, trg, srcWidth, srcHeight, cfgUse, yFirstUse, yLastUse);
|
|
783
785
|
return;
|
|
784
786
|
}
|
|
785
787
|
}
|