Pallet Compiler?
So I'm thinking about creating some assets in Chasersgaming's low res syle for a possible upcoming game, and I was wondering if there was a way to create a color pallete by putting his assets through a program. I've looked around and can't find anything like that online, anyone know of something like that?
-Sincerely
FiveBrosStopMosYT
Didn't WithTheLove have a palette analysis game for one of the previous Jams?
...Yeah, here it is: https://withthelove.itch.io/pixelpalettetool
Not sure that's quite what you're looking for, but it might work.
--Medicine Storm
Gimp has some basic tools that can be used to manually swap palettes - you can swap individual colours using the "Select by Color" and "Bucket Fill" tools.
It also has a powerful (but unpredictable) palette creation algorithm which I would guess uses something like the Median Cut algorithm internally. You get at it by changing the image mode to "Indexed".
And it also has some kind of support for saving and loading palettes but I haven't yet bothered to find out how to use that.
chasersgaming's stuff is mostly in the NES style, isn't it? The main feature of NES art is that the machine could use a different 4 colour palette for every 8x8 pixel tile or sprite. So, in every 8x8 pixels you would have only 4 different colours, or only 3 if you were using one of them to indicate fully transparent pixels. However, you could have any number of colours over a larger area, as long as there were only 4 in every 8x8 region. This restriction determined the art style of most NES games, and is the reason why smaller sprites typically only have 3 colours - but if you look closely at big sprites in top-tier games like the Mega Man series, they are carefully laid out so that they can have more colours without exceeding the limit in any 8x8 tile. As for what the limits on the palette entries were, I don't know that, but I'd guess they could be full 24 bit RGB.
To actually automatically extract these palettes you would probably need a tool which is written specifically for extracting palettes from NES art, since no other hardware that I know of ever had this specific limitation!
For low numbers of colours like you would find in most NES sprites, a palette analysis tool seems kind of like overkill, when you ought to be able to get the colours in a few seconds by zooming in and using the colour picker tool which every editor has.
Thanks for the suggestions, guys. I'll have to look around for a NES pallete tool.
-Sincerely
FiveBrosStopMosYT
Hi,
I've put together a small command line tool to handle palettes. Maybe it's going to be useful to you.
https://gitlab.com/bztsrc/pngpal
Cheers,
bzt
if it helps here the actual pallete images i use. :)
Chasersgaming | Support | Monstropolis |
4a0c82dc-3e7f-4823-9e6a-70672d569d36.png 200 b [1 download(s)]
773975f7-276c-4362-9252-60ab559f9512.png 435 b [1 download(s)]
68e40e0b-bf21-4b97-a1c8-2a37d4b87cdf.png 187 b [1 download(s)]
I've modified the code to read or generate palette from any image too. Now one can convert a picture by using @Chasersgaming's pngs from above directly (besides the usual gpl, aco, ase, pal, etc. formats).
Cheers,
bzt
Awesome guys! Thank you! :)
@btz:
When I download the program, I get a harmful program warning and it blocks the download.
Harmful? Or "potentially harmful" "rarely downloaded"?
--Medicine Storm
What browser do you use, and do you have any anti-virus programs running with a "live protection" feature?
Some of them will probably block any executable which is not cryptographically signed and registered with some list of "trusted" programs, so if you try to download a program which someone has developed as a hobby - without doing all the registration stuff - it won't let you. You'll probably have to find and turn that feature off to download the program. It could also be a browser extension... possibly a browser extension that was installed without your knowledge, thanks to a "dark pattern" or "drive-by" installation.
To check that the program is really OK, once you have downloaded the executable file but before you run it, submit it to virustotal.com.
Thanks for the help, I looked closer at it and found that the problem was too little downloads, I just allowed the file and was fine.
Hmm... it went through the analyzer you suggested just fine, but when I ran the program the tab would open then quickly disseapear, don't know if it just doesn't work on my computer or if it's malware, so i deleted it until I can ask the creator.
@FiveBrosStopMosYT: I can assure you it's free of malicious code and viruses, but if you have problems with downloading the binary, you can also download the source and compile it yourself. It's Open Source, MIT licensed.
The compilation is simple and easy, has no dependencies whatsoever. Just install MSYS and the basic mingw toolchain, nothing special needed. To compile pngpal, run "make" in the src directory, that's all, everything is detected and set up automatically for you. (Note: MSYS is a simple to use build environment for Windows which uses FOSS tools like the GNU compiler and GNU make).
I haven't tried, but any ANSI C compiler should do, you should be able to compile it with MSVC too (or LLVM CLang). If you have any problems with the compilation, just use gitlab issues, copy the error message there and I'll make it work.
Cheers,
bzt
Ah yes, because this is a command line tool, run it from CMD.EXE or Total Commander's command line. It needs two arguments, the image you want to convert and the output file name:
pngpal.exe input.png output.png
To specify a custom palette instead of the GIMP Default palette, use the "-p" switch like this:
pngpal.exe -p dawnbringer32.ase input.png output.png
This reads in the palette from "dawnbringer32.ase", replaces each pixel in the input image with the closest color on that palette and then saves the result to output.png. (If sRGB distance isn't good for you, using the "-c" switch will find the closest match on the CIELAB colorspace, a technique called CIE76 method.)
Cheers,
bzt
I just run with XP system, looks good for me. Used legendary Denzi picture from here:
https://opengameart.org/content/denzis-scifi-tilesets
denzitest.png 32.5 Kb [8 download(s)]
Thanks, bzt. I hope you weren't offended by me questioning the program, i just make it a rule to be careful about what software I download.
I don't really understand your explanation, could you simplify it for us lowly non-coders? :)
No, I wasn't offended at all, it is very good that you're careful!
All Windows have an integrated CMD.EXE application where you can type commands. This is the default on UNIX systems btw, but might be unknown to Windows users. Here's how to open it. It is an extremely useful tool.
Let's assume you have the image input.png, pngpal.exe and palette.gpl in your Documents\Sprites folder. Now the required steps are:
1. open the Command Prompt (I usually press [Win]+[R], type "cmd" and press [Enter], but you can find other ways on the link above)
2. you'll see a window with black background and white text on it, and in the last line the current working directory and the cursor (like this).
3. change the working directory to the folder with the files by typing "cd Documents\Sprites" and pressing [Enter]
4. now you can start pngpal by simply typing "pngpal" and pressing [Enter], it will print out its options
5. here's where you should enter the command from my previous post.
Hint: you don't have to type everything, by pressing [Tab] the filenames will automatically appear. If that's not the file you need, just press [Tab] again.
If you prefer a GUI, you can also use Total Commander, which is similar to the Explorer, but more featureful. Navigate to the directory where you have input.png, pngpal.exe and palette.gpl files. Under the two directory list panels, you can see the current working directory and a text input field, there you can type the command from my previous post ([Tab] extension does not work here, but as you type filenames a popup will appear and you can choose the files from there). Again, the command looks like this:
pngpal -p (name of the palette file) (name of the input image file) (name of the desired output file)
Cheers,
bzt
@FiveBrosStopMosYT
Without disrespect, I am nobody, but with no disrespect again you need to know that today technology is based on forgotten technology witch is not learning in school today. So we are using emulators to play older programs on modern computers.
Emulator has to be fluid, for example to play old DOS (Dos box,CMD) emulator has to emulate that old system(sound, graphic, memory ..etc.), so to play programs from Windows 32 bit XP era, you need to run that program in Compatibility mode. Right click on that .exe with picture and set compatibility for earlier version(XP,Win7). If for some reason you are using Win10 spaying product of Mili Gates then you are free to abandon this ship and do whatever you wants, you are practically free, like an bird.
Flap, flap, flap ...joke ...
I'm sorry I'm not really following, it must be frustrating, but are you saying that the program runs on xp?
-Just running now, it`s working. OK, FiveBrosStopMosYT -another chance program called retroeditor_3.0, much more friendly. -found over google.
From right side is Commodore 64 system, but you can use Nes if you want.
retroeditor_3.032-bit.png 42.2 Kb [7 download(s)]
I think Commander was just saying that there is a compatibility mode which you need to invoke in order to run quite old command line apps (ones that were made back when 32-bit Windows OSes were the main ones in use, so back in Win 8.1 era at least). I don't think you should need it for pngpal though, because bzt has obviously been developing this program very recently.
Oh, RetroEditor looks interesting!
BTW FiveBros, this may have been clear to you already - but just in case it isn't, I think that Commander is multi-lingual and English is not their first language (I will let Commander correct me if I am wrong about that).
Some examples given above are about converting an image to use a predefined palette. You can also do this in Gimp. If you have an image which is in "Indexed" mode (meaning that it is palettised), and you paste another image into it as a new layer, all of the colours in the pasted image will be changed to the nearest colour from the palette. However, I don't know if you can change the algorithm which it uses to do this, whereas pngpal clearly gives you two options for which algorithm to use. In reality I would expect that the results are usually identical for both, except for certain combinations of source image and target palette.
Guys, command line program != old program.
pngpal runs on the newest Windows natively, no tricks needed.
I prefer command line because it is a LOT more effective than any GUI, and you can call pngpal from a batch file (on Windows) or shell script (on Linux) to convert all images in a directory at once for example (you can't do that with a GUI app, there you have to click and click and click and click and click again...).
Cheers,
bzt
Not all command line programs are old, but all old programs are command line, so there is a reason the two are associated. :)
--Medicine Storm
Ok, thanks guys.