TeWu / CelesteExtractor

Converts Celeste's .data files to .png losslessly
The Unlicense
13 stars 0 forks source link

Is it possible to do the reverse? From a .png to a .data? #1

Open PerryTute opened 2 years ago

TeWu commented 2 years ago

It should be possible to convert from .png to .data. I'm not up for it, but if you want to try implementing it yourself, here are few directions on how to approach this:

PerryTute commented 1 year ago

It should be possible to convert from .png to .data. I'm not up for it, but if you want to try implementing it yourself, here are few directions on how to approach this:

* Most importantly, [DataFileConverter.convert](https://github.com/TeWu/CelesteExtractor/blob/master/src/pl/geek/tewu/celeste_extractor/DataFileConverter.java#L14) method must be modified to do the opposite, of what it's doing.

* [`DATA_FILES_GLOB_PATTERN`](https://github.com/TeWu/CelesteExtractor/blob/master/src/pl/geek/tewu/celeste_extractor/FileProcessor.java#L15) must be changed to `"**/*.png"`, so that PNG files are what `FileProcessor` is looking for.

* In line defining [`targetFilePath`](https://github.com/TeWu/CelesteExtractor/blob/master/src/pl/geek/tewu/celeste_extractor/FileProcessor.java#L25), `".png"` must be replaced with `".data"`, so that output file names end with `.data` extension.

Hey so I was fairly busy but getting back to having a looksie at doing this, how did you figure out what the run-length encoding algorithim was? I built a solution for the only result I got for "RunLengthEncoding" when de-compiling the executable with ILSpy

{ List<byte> list = new List<byte>(); for (int i = 0; i < str.Length; i++) { byte b = 1; char c; for (c = str[i]; i + 1 < str.Length && str[i + 1] == c; i++) { if (b >= byte.MaxValue) { break; } b = (byte)(b + 1); } list.Add(b); list.Add((byte)c); } return list.ToArray(); }

And this specific algorithim works fine, but after encoding and then decoding with your tool its obvious this isn't the one used for the .data assets.

ghost commented 1 year ago

You discover how? I want to do it too