MC84, on 16 May 2023 - 10:43 PM, said:
I'm running into some unexpected behaviour - I've been importing a bunch of HUD artwork, all scaled at 777 x 437 pixels. The total filesize for the .png files come to approx 1.7 megs.... yet once imported into BAFED the .art file is over 35Mb?... Has anyone run into this issue before?
dwtietz, on 17 May 2023 - 02:15 PM, said:
Interesting. Even with my tests earlier today, I absolutely expected there to be some overhead when I imported an image that was already 8-bit since it stores additional information about the tile's image, like animation settings, x/y offset values, etc. So while I did expect the imported images to turn out being larger than the original source file, I was quite surprised to see that the 2MB of combined image files had inflated 3 times as much to being just over 6 MB. The dimensions of these test tiles were much larger than I would actually use, but still... I didn't expect to see it grow as much as I did.
Maybe the file structure has something akin to allocation units, and some image widths or heights still end up taking a lot more space than is actually contained in the image data by padding regions of the file with filler/junk data? I don't know for sure... Just a guess as to what might account for that.
Reaper_Man, on 18 May 2023 - 01:19 PM, said:
Bit depth of images or anything like that isn't really taken into account, as all image data stored in the ART file is 8-bit pixel data.
The additional bytes come from other array data of how the data is stored - tile dimensions and animation type and other fun stuff like that.
If I had to guess, what's happening here is all of the tile sizes are being padded to conform to the largest tile in the ART file. So for example if you have 255 tiles that are 8x8 and 1 tile that is 512x512, all of the tiles are being padded to conform to the max 512 x 512 size. That shouldn't be what it's doing, that isn't how the actual ART format is structured, but BAFed has some issues and this may be a bug or oversight. You can test this by putting 1 of your large images in the first tile position, check the file size, then move it to the last tile position, and see if the size is different.
Alternatively, you can setup extra ART files with just your large HUD tile ranges. It's a myth that ART files must be 256 tiles in size, they can be basically any length you want. That way, if BAFed is padding out the tile dimension array, it will only be a few dozen tiles instead of 256 that are affected.
Or really, just use the DEF file format and texture / tilefromtexture your assets. It's superior in every way, weird personal hangups about "how the filesystem structure looks" included.
No, the added size is not because of padding or metadata. The answer is very simple:
PNG files are compressed, ART files are uncompressed. Try resaving your PNGs as BMPs and observe that the filesize of the uncompressed BMP matches that of the ART file:
This is entirely expected, BAFed is doing everything correctly here.
Reaper_Man, on 19 May 2023 - 05:39 AM, said:
That's because the PNG file format is infinitely better than an image storage format written by a high school kid in the early 90s, and one more reason that loading image data at runtime via tilefromtexture is a better method on basically every front.
This is incorrect. Using tilefromtexture for every tile generally results in worse performance, as the game needs to look up each individual file from disk and is forced to decompress it before being able to use it.
This overhead is skipped when using an ART file. This is why Fury makes use of them as well -- it's not just for obfuscation.