-
-
Notifications
You must be signed in to change notification settings - Fork 91
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
PALETTE: C&C 6bit .pal import produces incorrect colors #519
Comments
import png
import struct
fname = input("*.pal to convert: ")
with open(fname, "rb") as pal:
data = pal.read(768)
palette = list(struct.unpack("768B", data))
palette = (palette, )
with open(fname + ".png", "wb") as pngpal:
w = png.Writer(width=256, height=1, bitdepth=6, greyscale=False)
w.write(pngpal, palette) Here's the conversion script in Python, requires |
For my future me ;): This is a C&C Can you maybe please attach the pal file for testing purposes? |
Sure thing. Also here's the reference to the format: |
Thanks a lot - the reading is fixed now by trying to identify whether the pal file is 6 bit only. The problem here is that the pal file is not only used by C&C as 6 bit value - but also by other tools/games that are using 8 bit values. The issue is not yet resolved for writing. This is most likely becoming a cvar to control the behavior and to let it work for both cases. |
How about an option/toggle for specifying bit depth? Or perhaps having multiple .pal formats to choose from? |
… RGBPalette format this improves upon issue #519 to also allow to write such a 6bit palette as it is used in c&c
Can confirm the option works. I think the name would not be intuitive to C&C users though, as they don't have an idea what is 6-bit colors. Perhaps the best thing to do would be to have it as a separate file format, as you already do with JASC palette? Then if the user selected the pal file - ask which of the formats is this file in when opening/saving (if all formats are selected for filtering the view). |
feedback from issue #519. A new format would also be an option for this.
see #536 - the idea could also be to load the 6bit colors in the c&c view mode |
also ensure that the 6bit palettes are loading in c&c mode should fix the last issue for #519
When I convert to PNG with my script:
When I open the pal directly:
The text was updated successfully, but these errors were encountered: