@bis-toolkit/bcn 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,63 @@
1
+ # @bis-toolkit/bcn
2
+
3
+ Block Compression (BC1-BC5, BC7) texture decoders for TypeScript.
4
+
5
+ ## Features
6
+
7
+ - **BC1 (DXT1)**: RGB/RGBA compression with 1-bit alpha
8
+ - **BC2 (DXT3)**: RGBA compression with explicit alpha
9
+ - **BC3 (DXT5)**: RGBA compression with interpolated alpha
10
+ - **BC4**: Single channel compression
11
+ - **BC5**: Two channel compression (normal maps)
12
+ - **BC6H**: HDR compression _(not yet implemented - complex 14-mode HDR format)_
13
+ - **BC7**: High quality RGBA compression
14
+
15
+ ## Installation
16
+
17
+ ```bash
18
+ npm install @bis-toolkit/bcn
19
+ ```
20
+
21
+ ## Usage
22
+
23
+ ```typescript
24
+ import { decodeBC1, decodeBC3, decodeBC7 } from '@bis-toolkit/bcn';
25
+
26
+ // Decode BC7 compressed data
27
+ const rgba = decodeBC7(compressedData, width, height);
28
+
29
+ // Decode BC1 (DXT1)
30
+ const rgba = decodeBC1(compressedData, width, height);
31
+
32
+ // Decode BC3 (DXT5)
33
+ const rgba = decodeBC3(compressedData, width, height);
34
+ ```
35
+
36
+ All decoders return a `Uint8Array` containing RGBA data (4 bytes per pixel).
37
+
38
+ ## API
39
+
40
+ ### decodeBC1(data: DataView, width: number, height: number, useAlpha?: boolean): Uint8Array
41
+ ### decodeBC2(data: DataView, width: number, height: number): Uint8Array
42
+ ### decodeBC3(data: DataView, width: number, height: number): Uint8Array
43
+ ### decodeBC4(data: DataView, width: number, height: number, channel?: 'r' | 'g' | 'b' | 'a'): Uint8Array
44
+ ### decodeBC5(data: DataView, width: number, height: number, channel1?: 'r' | 'g' | 'b' | 'a', channel2?: 'r' | 'g' | 'b' | 'a'): Uint8Array
45
+ ### decodeBC7(data: DataView, width: number, height: number): Uint8Array
46
+
47
+ **Note:** BC6H (HDR) decoder is not yet implemented due to its complexity (14 modes with signed/unsigned variants).
48
+
49
+ ## Attribution
50
+
51
+ This library is a direct TypeScript port of [BCnEncoder.NET](https://github.com/Nominom/BCnEncoder.NET), originally created by Nominom and licensed under the MIT License.
52
+
53
+ ```
54
+ Copyright © 2025 Nominom
55
+ Licensed under the MIT License
56
+ ```
57
+
58
+ ## License
59
+
60
+ GPLv3 © Alpine Labs - see [LICENSE](LICENSE).
61
+
62
+ This work is derived from BCnEncoder.NET (MIT License) and is redistributed under GPLv3.
63
+
package/dist/bc1.d.ts ADDED
@@ -0,0 +1,5 @@
1
+ /**
2
+ * BC1 (DXT1) Decoder
3
+ * Source: https://github.com/Nominom/BCnEncoder.NET
4
+ */
5
+ export declare function decodeBC1(data: DataView, width: number, height: number, useAlpha?: boolean): Uint8Array;
package/dist/bc2.d.ts ADDED
@@ -0,0 +1,5 @@
1
+ /**
2
+ * BC2 (DXT3) Decoder - RGBA with explicit alpha
3
+ * Source: https://github.com/Nominom/BCnEncoder.NET
4
+ */
5
+ export declare function decodeBC2(data: DataView, width: number, height: number): Uint8Array;
package/dist/bc3.d.ts ADDED
@@ -0,0 +1,5 @@
1
+ /**
2
+ * BC3 (DXT5) Decoder - RGBA with interpolated alpha
3
+ * Source: https://github.com/Nominom/BCnEncoder.NET
4
+ */
5
+ export declare function decodeBC3(data: DataView, width: number, height: number): Uint8Array;
package/dist/bc4.d.ts ADDED
@@ -0,0 +1,5 @@
1
+ /**
2
+ * BC4 Decoder - Single channel compression
3
+ * Source: https://github.com/Nominom/BCnEncoder.NET
4
+ */
5
+ export declare function decodeBC4(data: DataView, width: number, height: number, channel?: 'r' | 'g' | 'b' | 'a'): Uint8Array;
package/dist/bc5.d.ts ADDED
@@ -0,0 +1,5 @@
1
+ /**
2
+ * BC5 Decoder - Two channel compression (typically for normal maps)
3
+ * Source: https://github.com/Nominom/BCnEncoder.NET
4
+ */
5
+ export declare function decodeBC5(data: DataView, width: number, height: number, channel1?: 'r' | 'g' | 'b' | 'a', channel2?: 'r' | 'g' | 'b' | 'a'): Uint8Array;
package/dist/bc7.d.ts ADDED
@@ -0,0 +1,5 @@
1
+ /**
2
+ * BC7 Decoder - Direct port from BCnEnc.Net
3
+ * Source: https://github.com/Nominom/BCnEncoder.NET
4
+ */
5
+ export declare function decodeBC7(imageData: DataView, width: number, height: number): Uint8Array;
@@ -0,0 +1,11 @@
1
+ /**
2
+ * BCn (BC1-BC7) Texture Decoders
3
+ * Source: https://github.com/Nominom/BCnEncoder.NET
4
+ */
5
+ export { decodeBC1 } from './bc1';
6
+ export { decodeBC2 } from './bc2';
7
+ export { decodeBC3 } from './bc3';
8
+ export { decodeBC4 } from './bc4';
9
+ export { decodeBC5 } from './bc5';
10
+ export { decodeBC7 } from './bc7';
11
+ export type { ColorRgba32, ColorRgb24 } from './utils';