How can I store sprites(png) or audio files(wav) in the *.dat file format?

  • 4
    \$\begingroup\$ There is no standard *.dat format. The .dat file extension (short for "data") is used by many, many different tools and programs to store all kinds of data in all kinds of formats. Please be more specific for what tool you need this. When you are developing your own engine and are looking for a way to bundle your assets, you might want to look into archive formats like .zip. \$\endgroup\$ – Philipp Nov 1 '15 at 22:46
  • \$\begingroup\$ .png are already compressed .wav are not so much - if you are not content with their size, why not use different format with better compression ratio instead? \$\endgroup\$ – wondra Nov 1 '15 at 22:55
  • \$\begingroup\$ I saw this in a Iot of 2d style games. I once played a small free platformer game and all images(background and sprites) were stored in the dat file format. I extracted the dat with a not very common program called Westside Media Extractor. Another popular 2d game written in C++ (Super Meat Boy) uses two dat archives. The first dat file includes a folder with all image data(png) and the second all audio files in wav format. All png files have the file size of 230Mb and as dat file 90Mb. I just want to know how to store my own sprites with the same method using dat. \$\endgroup\$ – taraz Nov 1 '15 at 23:54
  • 2
    \$\begingroup\$ As Philipp says above, ".dat" isn't a format, just a common 3-letter extension a lot of developers decide to use for labeling a file containing a blob of arbitrary data. Internally, that data could be in whatever mish-mash of formats or compressions were in fashion at the time wherever it was made (eg. the Westside program you describe uses plugins to decode png, avi, etc). The best way to find out how a particular "dat" blob worked would be to ask the developers of the game or tools that use it. Or, tell us about the data you want to compress & we can suggest methods appropriate for your use. \$\endgroup\$ – DMGregory Nov 2 '15 at 1:55
  • \$\begingroup\$ Many games just use run-of-the-mill zip archives, but give them cryptic file extensions. Many archive managers can recognize when they get fed a zip archive with a wrong file extension and will unpack it. \$\endgroup\$ – Philipp Nov 2 '15 at 23:16

Browse other questions tagged or ask your own question.