Build a minimal valid DDS DXT1 buffer
(width = 8, height = 8)
| 133 | |
| 134 | /** Build a minimal valid DDS DXT1 buffer */ |
| 135 | function buildDDS_DXT1(width = 8, height = 8) { |
| 136 | const blockSize = 8; |
| 137 | const dataSize = |
| 138 | Math.max(1, (width + 3) >> 2) * Math.max(1, (height + 3) >> 2) * blockSize; |
| 139 | const buffer = new ArrayBuffer(128 + dataSize); |
| 140 | const view = new DataView(buffer); |
| 141 | view.setUint32(0, 0x20534444, true); // magic |
| 142 | // header at offset 4 (124 bytes) |
| 143 | view.setUint32(4, 124, true); // dwSize |
| 144 | view.setUint32(8, 0x000a1007, true); // dwFlags |
| 145 | view.setUint32(12, height, true); // dwHeight |
| 146 | view.setUint32(16, width, true); // dwWidth |
| 147 | view.setUint32(28, 1, true); // dwMipMapCount |
| 148 | view.setUint32(80, 32, true); // ddspf.dwSize |
| 149 | view.setUint32(84, 0x31545844, true); // ddspf.dwFourCC = "DXT1" |
| 150 | return buffer; |
| 151 | } |
| 152 | |
| 153 | /** Build a minimal valid PKM ETC1 buffer */ |
| 154 | function buildPKM_ETC1(width = 8, height = 8) { |
no outgoing calls
no test coverage detected