@@ -223,22 +223,10 @@ const updateDemoLogo = (pngPath: string) => {
223
223
}
224
224
}
225
225
226
- const decompressed = Buffer . alloc ( ( width * height ) / 2 , 0 ) ;
227
-
228
- let index = 0 ;
229
- for ( let y = 0 ; y < height ; y ++ ) {
230
- for ( let x = 0 ; x < width ; x += 2 ) {
231
- const lowByte = imgData [ index ++ ] ;
232
- const highByte = imgData [ index ++ ] ;
233
- const byte = ( ( highByte << 4 ) | lowByte ) & 0xff ;
234
- decompressed [ outOfs ++ ] = byte ;
235
- }
236
- }
237
-
238
- // Write the
226
+ // Write the texture to png to confirm it's working'
239
227
const png = new PNG ( { width, height } ) ;
240
228
241
- index = 0 ;
229
+ let index = 0 ;
242
230
let dst = 0 ;
243
231
for ( let y = 0 ; y < height ; y ++ ) {
244
232
for ( var x = 0 ; x < width ; x ++ ) {
@@ -255,6 +243,21 @@ const updateDemoLogo = (pngPath: string) => {
255
243
const dat = PNG . sync . write ( png ) ;
256
244
writeFileSync ( `out/smol.png` , dat ) ;
257
245
246
+ // Convert the image data back to a 4bit encoded buffer
247
+ const decompressed = Buffer . alloc ( ( width * height ) / 2 , 0 ) ;
248
+
249
+ index = 0 ;
250
+ outOfs = 0 ;
251
+ for ( let y = 0 ; y < height ; y ++ ) {
252
+ for ( let x = 0 ; x < width ; x += 2 ) {
253
+ const lowByte = imgData [ index ++ ] ;
254
+ const highByte = imgData [ index ++ ] ;
255
+ const byte = ( ( highByte << 4 ) | lowByte ) & 0xff ;
256
+ decompressed [ outOfs ] = byte ;
257
+ outOfs ++ ;
258
+ }
259
+ }
260
+
258
261
// And then we compress and put it back in
259
262
const [ bodyBitField , compressedBody ] = compressData ( decompressed ) ;
260
263
const len = bodyBitField . length + compressedBody . length ;
0 commit comments