gpl2jascpal

Discuss PoP1 for DOS here.

Moderator: English Moderator Team

Post Reply
User avatar
Norbert
The Prince of Persia
The Prince of Persia
Posts: 3281
Joined: April 9th, 2009, 10:58 pm
Contact:

gpl2jascpal

Post by Norbert » May 21st, 2011, 1:24 pm

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: 1553
Joined: December 11th, 2008, 9:48 pm
Location: Hungary

Re: gpl2jascpal

Post by David » May 24th, 2011, 11:39 am

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: 3281
Joined: April 9th, 2009, 10:58 pm
Contact:

Re: gpl2jascpal

Post by Norbert » May 24th, 2011, 4:48 pm

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: 1553
Joined: December 11th, 2008, 9:48 pm
Location: Hungary

Re: gpl2jascpal

Post by David » May 28th, 2011, 2:45 pm

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: 3281
Joined: April 9th, 2009, 10:58 pm
Contact:

Re: gpl2jascpal

Post by Norbert » May 28th, 2011, 3:47 pm

Thanks.

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

Re: gpl2jascpal

Post by zsoltfarago » May 28th, 2014, 5:42 pm

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: 1553
Joined: December 11th, 2008, 9:48 pm
Location: Hungary

Re: gpl2jascpal

Post by David » May 29th, 2014, 2:17 pm

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: 3281
Joined: April 9th, 2009, 10:58 pm
Contact:

Re: gpl2jascpal

Post by Norbert » May 29th, 2014, 4:41 pm

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 » May 31st, 2014, 11:57 am

Thank you! :)

User avatar
Norbert
The Prince of Persia
The Prince of Persia
Posts: 3281
Joined: April 9th, 2009, 10:58 pm
Contact:

Re: gpl2jascpal

Post by Norbert » December 16th, 2017, 2:19 pm

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: 3281
Joined: April 9th, 2009, 10:58 pm
Contact:

Re: gpl2jascpal

Post by Norbert » December 16th, 2017, 3:27 pm

Norbert wrote:
December 16th, 2017, 2:19 pm
Okay, 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: 3281
Joined: April 9th, 2009, 10:58 pm
Contact:

Re: gpl2jascpal

Post by Norbert » December 26th, 2017, 11:40 am

Norbert wrote:
December 16th, 2017, 3:27 pm
This 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.

Post Reply