It works by HTTP requesting a direct link to a PNG to get access to the file’s data. It’s still possible to optimize this decompressor slightly more, but because of Luau’s table element limit it wont be able to load images with more than 2^26 values (each RGB of a pixel counts as a value and an Alpha channel if there is one) without work arounds. This still allows it to decompress images over 4000 by 4000 pixels in RGB. After decoding the image is written onto editable images, which get split up into multiple images if the image is bigger than 1024x1024.
Yes the image is rendered using editable images, it can also use parts but thats way too performance heavy for bigger images. Images over 1024x1024 get split into multiple editable images.
Coding the actual decoder took quite a long time. The compression algorithm PNG uses, which is Zlib and specifically Deflate, doesn’t have the best documentation in my opinion. So finding resources to understand how to undo the compression and understanding them took a while. Also after I got the decoder working I had a bunch of performance issues which I had to fix and I got it quite optimized at this point. Overall it did take over a month, but it was a pretty interesting project lol.
Seems to be the Next Gen Studio Preview in beta settings
Anyway, cool project! A jpeg decoder has been something i’ve wanted to attempt for a while, how do you manage operations on raw bytes?
It’s a shame you can’t really release this in any way, for obvious reasons …
I use string.unpack() to convert binary strings into decimal values, and then you can use the bit32 library in studio for the binary operators. If your working with raw Lua, the newer Lua versions have native binary operators.
Try using buffers, it’s so much faster. You can send the binary data as unsigned 8 bit as the values go from 0-255. Then create buffer from string and readu8.
Yeah I’ll try and update it when I have free time, that should also let me load bigger images since the buffer limit allows a bigger stream than a table.