gpl2jascpal

Discuss PoP1 for DOS here.
Post Reply
User avatar
Norbert
The Prince of Persia
The Prince of Persia
Posts: 5743
Joined: April 9th, 2009, 10:58 pm

gpl2jascpal

Post by Norbert »

I have just finished and released the first version (Linux version [Edit: + Windows version]) of gpl2jascpal. This utility converts GIMP gpl palettes to JASC pal palettes. GIMP can already import JASC pal palettes, but it can not yet export palettes to the JASC pal format. PoP1 pal files can now be imported into GIMP, exported as GIMP gpl palettes, and then converted back to JASC pal palettes with this utility.

It is currently only available for GNU/Linux.
David or someone else might port it to Windows at some point.

I will soon publish documentation that explains how to import and export images with PR, and how palettes can be changed using GIMP (and this gpl2jascpal utility).
(I know that Paint Shop Pro can edit JASC pal palettes, but I use GIMP on my GNU/Linux machine. GIMP is also available for Windows and Mac OS X.)
David
The Prince of Persia
The Prince of Persia
Posts: 2846
Joined: December 11th, 2008, 9:48 pm
Location: Hungary

Re: gpl2jascpal

Post by David »

I've ported it to Windows.
Link: http://www.freeweb.hu/princepersia/en/g ... l01_dl.htm

Please note that I haven't tested it, because I don't have .gpl files.
User avatar
Norbert
The Prince of Persia
The Prince of Persia
Posts: 5743
Joined: April 9th, 2009, 10:58 pm

Re: gpl2jascpal

Post by Norbert »

Hey, thanks for taking a look at it. :)

Here are some sample .gpl files (three mirrors, each has the same .zip):
http://www.mediafire.com/?1g7wnd8707m6ozb
http://www.megaupload.com/?d=9FKHU06K
http://www.sendspace.com/file/ayn1me

The Windows version appears to create .pal files which have lines that end with:
0D 0D 0A (\r\r\n).
This should be 0D 0A (\r\n).

Apparently the write function under Windows already adds the \r by itself.
So, \r should be removed from the code everywhere.
(On lines 258, 260, 262 and 266.)
David
The Prince of Persia
The Prince of Persia
Posts: 2846
Joined: December 11th, 2008, 9:48 pm
Location: Hungary

Re: gpl2jascpal

Post by David »

Norbert wrote:So, \r should be removed from the code everywhere.
Another solution is to add |O_BINARY to the flags in the call to the open function.
I also used O_BINARY when porting Apoplexy to Windows.

I've fixed the bug using the latter way.
Link: http://www.freeweb.hu/princepersia/en/g ... l01_dl.htm
User avatar
Norbert
The Prince of Persia
The Prince of Persia
Posts: 5743
Joined: April 9th, 2009, 10:58 pm

Re: gpl2jascpal

Post by Norbert »

Thanks.
zsoltfarago
Scholar Scribe
Scholar Scribe
Posts: 4
Joined: April 21st, 2014, 11:43 am
Location: Hungary

Re: gpl2jascpal

Post by zsoltfarago »

Hello!
I have a problem with gpl2jascpal: I don't know how to use it. Could you send me a description about it? (I know, I'm very bad in things like this, but this is the only obstacle between my mod and me :D)
David
The Prince of Persia
The Prince of Persia
Posts: 2846
Joined: December 11th, 2008, 9:48 pm
Location: Hungary

Re: gpl2jascpal

Post by David »

You need to run it from the command line, and pass the path/name of the .gpl file as a command line parameter.
The converted palette is written into a new file with .pal extension.
User avatar
Norbert
The Prince of Persia
The Prince of Persia
Posts: 5743
Joined: April 9th, 2009, 10:58 pm

Re: gpl2jascpal

Post by Norbert »

If you're on Windows, make sure you're using the Windows version.
Additional information about using gpl2jascpal can be found in this document, although that document is somewhat Linux-oriented.

The easiest thing to do when changing images of PoP for DOS is to not change palettes.
Get GIMP (Windows version here) and only use the Colormap (see "5. Using The Colormap" in the document mentioned above).
If you don't touch any palettes, changing images is a lot easier.
zsoltfarago
Scholar Scribe
Scholar Scribe
Posts: 4
Joined: April 21st, 2014, 11:43 am
Location: Hungary

Re: gpl2jascpal

Post by zsoltfarago »

Thank you! :)
User avatar
Norbert
The Prince of Persia
The Prince of Persia
Posts: 5743
Joined: April 9th, 2009, 10:58 pm

Re: gpl2jascpal

Post by Norbert »

Okay, it looks like this tool only works for customly saved .gpl palettes, because these have a tab+name after the blue color.

Old content of this post:
Spoiler: show
I think I just discovered a major bug in this program.
On line 208,
for (iTemp = 0; iTemp < strlen (sLine); iTemp++)
should be
for (iTemp = 0; iTemp <= strlen (sLine); iTemp++)
And as a result the blue value is always 0 or random.

So now I don't get how this program ever worked for me (e.g. Prince of Wateria) and others.
Looking into this...
Maybe GIMP changed the .gpl newline endings from \r\n to \n.
Last edited by Norbert on December 16th, 2017, 3:28 pm, edited 1 time in total.
User avatar
Norbert
The Prince of Persia
The Prince of Persia
Posts: 5743
Joined: April 9th, 2009, 10:58 pm

Re: gpl2jascpal

Post by Norbert »

Norbert wrote: December 16th, 2017, 2:19 pmOkay, it looks like this tool only works for customly saved .gpl palettes, because these have a tab+name after the blue color.
I just checked whether GIMP's default (non-custom) palettes used to also have tab+name after the blue color back in the day.
(By installing GIMP 2.6.9 for Windows with Wine.)
And they did!

Code: Select all

norbert@stimpy ~ $ cat /home/norbert/.wine/drive_c/Program\ Files\ \(x86\)/GIMP-2.0/share/gimp/2.0/palettes/Web.gpl |tail -n 1
  0   0   0     Untitled
So what has changed is that they no longer do:

Code: Select all

norbert@stimpy ~ $ cat /usr/share/gimp/2.0/palettes/Web.gpl |tail -n 1
  0   0   0
This means I could update the gpl2jascpal tool to properly process the new default (non-custom) palettes.
User avatar
Norbert
The Prince of Persia
The Prince of Persia
Posts: 5743
Joined: April 9th, 2009, 10:58 pm

Re: gpl2jascpal

Post by Norbert »

Norbert wrote: December 16th, 2017, 3:27 pmThis means I could update the gpl2jascpal tool to properly process the new default (non-custom) palettes.
Here's the new release (v0.2): for Windows (mirror) and for GNU/Linux (mirror).

This version changes:

Code: Select all

+ Now also processes, with a warning, input palettes that have neither 16 (4 bit) nor 256 (8 bit) colors.
* Nowadays, GIMP's predefined gpl palettes no longer include "Untitled" color names, making these names optional. Fixed gpl2jascpal accordingly.
User avatar
Emiliano
Wizard Scribe
Wizard Scribe
Posts: 718
Joined: July 31st, 2019, 8:53 pm
Location: Mexico
Contact:

Re: gpl2jascpal

Post by Emiliano »

I didn't need to use this program I can translate RGB numbers to colors and vice versa
Anyway thanks for this program ;)
65536
Post Reply