Skip to content
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

Closed
Metadorius opened this issue Sep 15, 2024 · 9 comments
Closed

PALETTE: C&C 6bit .pal import produces incorrect colors #519

Metadorius opened this issue Sep 15, 2024 · 9 comments
Labels
format Voxel or mesh format related

Comments

@Metadorius
Copy link

When I convert to PNG with my script:

image

When I open the pal directly:

image

@mgerhardy mgerhardy added the format Voxel or mesh format related label Sep 15, 2024
@Metadorius
Copy link
Author

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 pypng.

@mgerhardy
Copy link
Collaborator

For my future me ;): This is a C&C pal file.

Can you maybe please attach the pal file for testing purposes?

@Metadorius
Copy link
Author

Sure thing.
unitsno.zip

Also here's the reference to the format:
https://modenc.renegadeprojects.com/PAL

@mgerhardy
Copy link
Collaborator

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.

@Metadorius
Copy link
Author

How about an option/toggle for specifying bit depth? Or perhaps having multiple .pal formats to choose from?

mgerhardy added a commit that referenced this issue Sep 15, 2024
… RGBPalette format

this improves upon issue #519 to also allow to write such a 6bit palette as it is used in c&c
@mgerhardy
Copy link
Collaborator

Bildschirmfoto vom 2024-09-15 15-51-29

this is the case now - if you select the RGB Palette (*.pal) in the file filter list, you get this option

@mgerhardy
Copy link
Collaborator

Bildschirmfoto vom 2024-09-15 15-54-34

this is with the 6 bit option activated

@Metadorius
Copy link
Author

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).

mgerhardy added a commit that referenced this issue Sep 16, 2024
feedback from issue #519. A new format would also be an option for this.
@mgerhardy mgerhardy changed the title VOXEDIT: .pal import produces incorrect colors PALETTE: .pal import produces incorrect colors Sep 17, 2024
@mgerhardy mgerhardy changed the title PALETTE: .pal import produces incorrect colors PALETTE: C&C 6bit .pal import produces incorrect colors Sep 17, 2024
@mgerhardy
Copy link
Collaborator

see #536 - the idea could also be to load the 6bit colors in the c&c view mode

mgerhardy added a commit that referenced this issue Oct 22, 2024
also ensure that the 6bit palettes are loading in c&c mode

should fix the last issue for #519
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
format Voxel or mesh format related
Projects
None yet
Development

No branches or pull requests

2 participants