cortex-command-community / Cortex-Command-Legacy-Mod-Converter

MIT License
4 stars 5 forks source link

Glows are being applied a palette to, even though that shouldn't happen #45

Closed MyNameIsTrez closed 3 years ago

MyNameIsTrez commented 3 years ago

The problem

The problem I'm facing is that I added the ability for people to throw in any randomly 16 million color image, to have all those pixels be rounded to the nearest colors in the CCCP palette and to have the new image saved with the CCCP palette.

It also allows people to reorder the colors in the CCCP palette like I know Gotcha does when he's spriting, and to have the converter apply the real CCCP palette on it while retaining the look.

This means that I currently can't assume sprites are correctly indexed/not indexed.

Planned logic for supporting all of these cases

  1. Loop through all INI files and put all the paths of glow images into a Python list (array).

  2. For every image, check if it's a BMP or PNG. If this is the case, detect whether it is paletted. The converter should only get BMP/PNG images, else it'll just make an exact copy of the file in the case it's just there for non-sprite reasons, like a JPEG which will be used on the Steam Workshop or mod.io.

  3. When the input image is a BMP, the header data should be read to detect whether it's RLE encoded or not. If the BMP is RLE encoded, read the header data to get the RGB palette. If it isn't RLE encoded it should be possible to copy over the palette using a PIL function.

  4. If the image is paletted and a PNG, make the converted image also paletted by applying the input palette on the output image.

  5. If it isn't paletted and it isn't a glow image, apply the CCCP palette onto it.

  6. If it is a glow image, don't apply any palette on it.

BMP compression header info

https://en.wikipedia.org/wiki/BMP_file_format#Compression

image

MyNameIsTrez commented 3 years ago

Manual RLE BMP -> uncompressed BMP code will be written to handle this.