I'm working on a project converting images packed into a proprietary container format into individual PNG images which then get repacked into a more flexible container format. One of the odder restrictions for this is that the order of the colormap entries are critical for proper operation of the end application (the palettes of some images depend on the palettes of other images currently displayed).
Is there some way I can, preferably in Perl, directly manipulate the colormap of a PNG? I'm using PerlMagick to generate the PNG files pixel-by-pixel. Please let me know if it would be helpful for me to more directly describe what I'm up to.
(expanding on this because of Mark's suggestion)
The screen is filled first with background elements, like a decorative frame and a compass rose. Parts of the compass rose light up to indicate which direction the player can go. These lit up sections are separate images which take their coloring cues from specific slots in the colormaps for the background element images. Therefore the content and order of the colormaps for the background elements are critical.
(even more expanding)
I'll lay out exactly what I'm doing now. The original container format was created by Infocom in the late 1980s for its graphical text adventures. For each of the graphical games, three graphics files were made, one for CGA, EGA, and MCGA. Some EGA graphics files were spread across two containers. For play on modern Z-machine interpreters, the format was reverse-engineered and the graphics within were converted to PNG and repacked into Blorb containers (https://www.eblong.com/zarf/blorb/). Section 11.3 talks about the color-changing behavior. Just the MCGA packs were repacked like this. I want to create packs for the CGA and EGA packs. Unfortunately, I've been unable to contact the person who prepared these Blorb files to get information about this colormap problem. The reverse-engineering of Infocom's format seems to be lost. So I took existing tools, mainly pix2gif.c
from Ztools (http://ifarchive.org/indexes/if-archive/infocom/tools/ztools/) and translated it to Perl to better understand it. With this Perl program, Imanaged to extract the EGA and CGA data. I've modified my own tools (https://gitlab.com/DavidGriffith/blorbtools) to support the special requirements of these games.
Starting off with the MCGA-targeted graphics, I cannot get to the point of replicating the look of playing a game with the older Blorb files available here: http://ifarchive.org/indexes/if-archive/infocom/media/blorb. The images with changing palettes are drawn with the wrong colors. There are other problems with the EGA and CGA graphics, but have to do with resolution and are not relevant here.
These the specific games involved are Infocom's games "Arthur", "Shogun", "Journey", and "Zork Zero". I maintain one of the Z-machine interpreters capable of playing these games, which can be found at https://gitlab.com/DavidGriffith/frotz.