• Welcome to Zoo Tycoon Community Download Directory.
 

How does one create a ".pal" file?

Started by johnrn1, August 11, 2010, 11:26:18 PM

0 Members and 1 Guest are viewing this topic.

Jay

#75
Quote from: Jeff on February 16, 2015, 11:12:11 AMThe only thing my small graphic and the large US Flag have in common, is that they were probably both made by APE.

I'm not sure what they represent. Maybe a date/creation time?
Or maybe, something else those images have in common: neither are cropped, like ZT1 graphics usually are, to a rectangle which only contains relevant pixels.
Both of these graphics have a few border lines which are fully transparent.
If I decide to just skip them, the image seems to render perfectly.
Zoot can also perfectly render the same version of the US Flag.

From madscientist's article on the ZT1 Image File Format:

"This *should* be the end of the frame. However, some ZT1 images have an extra 9 or 10 bytes at the end of them, and I have no idea what they represent. Zoot ignores them with no apparent ill effects."

So it sounds like you just skipping them is the correct approach. I do not know what they represent. They do not look like they are time related to me because your examples look too different for such a short period of time. Maybe they mean something to APE. But it is also possible they are garbage bytes created by APE. We know APE creates garbage inside ".ucs" and ".uca" files (although readable garbage). So it would not surprise me if it creates garbage bytes inside ZT image files.


Quote from: Jeffhas anyone ever found out whether the 8 character HEX string APE generates, is that random? I mean, I tried 4 objects within 5 minutes, and each object starts with "23......" .

We do not know the format of that APE ID. But we know that the start of the APE ID represents number of seconds. I feel their algorithm for APE IDs is not good. The number of seconds wraps around too soon. We have seen a number of times where 2 people create things and they happen to get the same APE ID, which causes a conflict. I just used APE 1.1 to create 3 objects based on the in-game Bighorn Statue. I waited 1 minute before creating the second object and waited 5 minutes between the second and third objects. These are the 3 APE IDs that were created: 24BEF026, 24C2B057, and 24D57026. Based on that, it looks like the first 5 characters represent the number of seconds, since 24BEF and 24C2B in hex are 60 apart, which would be 60 seconds or 1 minute, and 24C2B and 24D57 in hex are 300 apart, which would be 300 seconds or 5 minutes. Based on that, it looks like the first 5 characters would wrap around a little over every 12 days. Although I do not know, the last 3 characters might represent a fraction of a second, maybe the number of microseconds wrapped to fit 3 hex bytes. In theory, it is unlikely for 2 people to create something at the exact microsecond. The problem is that most computers cannot handle that fine of a resolution. So we often see repeats at the end, such as the two "026" ends in my test. Therefore, I would have used a different algorithm for an APE ID. I would have chosen the first character randomly. Then I would have used the last 7 characters for the number of seconds, which would not wrap for 8 years, although I would have reversed those 7 characters so that the APE ID changes more rapidly near the beginning.

Jeff

I hadn't seen it in the other official ZT1 Graphics I used, and we know the flag is an APE-test, so it's probably the right thing to ignore them.

You're right, Jay. Whatever meaning they might have - it's not significant.
It's curious to see that the flag wasn't cropped to the relevant pixel area though.
Also, there could have been a small level of compression applied if they kept the flag pole in the last frame.

I'll do an experiment soon with the Umbrella table I mentioned, to see if it's easier to make objects with color replacement in-game.

dr rick

i look forward to hearing how that test goes, and to being able to play with this tool!
Dr Rick<br /><br />How does that work?

Jeff

#78
This umbrella table is not the one that got canned by Blue Fang.

The design has been recycled from one of my very old designs, but I thought it was a perfect test case.

- rotation fixing: works.

- reordering color palette: works.

- using a ZT1 background image in the preview to make sure it lined up with the regular picnic table: works.

It's also helped me fix another issue one would have had in the rotation fixing process of extremely small images (with width and/or height 1px)

Also, since all views here share the same palette, it made me remember to add a feature to have multiple graphics use one palette file.
I also think that there should be an option to remove all colors from the palette file which are not used in the graphic.

I'm pretty psyched about this new object to use. Just for my own use, I made it so that it can be used by guests properly :)

Here you see the test case in ZT1. Just to be clear, it's one object, NOT 4 objects having different colors.



Jeff

I'm currently testing the batch conversion feature with some graphics someone provided of a brand new animal.

However, my program is unable to generate an image. Each frame was limited to 256 colors (including 1 transparent), but it seems that frame 1 and frame 2 consist of slightly different palettes - so it's more than 256 colors.

Are there compression methods in place in APE and Zoot to avoid this, or do they just complain as well?

Jay

APE has color reduction built in. Sometimes it crashes in the process, but it usually works. I do not know how well it does the color reduction, though. For example, I feel it is best not to use dithering in the color reduction process for ZT animations. But I do not know whether or not APE uses dithering, since I have not looked at it that closely. Zoot does not do color reduction. It gives an error if there are more than 256 colors in a single animation.

There are different approaches to reducing the number of colors for a ZT animation. I use GIMP, which is free and open source. I load the frames of an animation as separate layers in a single image, then have GIMP reduce the number of colors without dithering, then save the individual layers into ".png" files to load in via Zoot. dr rick also uses GIMP to reduce the number of colors for a ZT animation, but he uses different functionality in GIMP. He has GIMP remember the colors in the first frame of an animation as a color palette, and then has GIMP map the rest of the frames of an animation to that color palette. The free and open source programs ImageMagick and GraphicsMagick (which is a fork of ImageMagick) have color reduction functionality, including whether or not to dither. Color reduction is very complicated to implement. ImageMagick has a very long article about the complexities. So rather than trying to implement color reduction, it might be worthwhile if a ".bat" file was created that uses ImageMagick or GraphicsMagick to do the color reduction. Until that is done, if ever done, designers would have to use GIMP, APE (if the animation is not too large), or some other tool to do the color reduction for the animation as a whole.

dr rick

#81
I use Gimp too for this though in a slightly different way (as Jay explained briefly above, and as originally suggested about a million years ago by Jay). I choose an image from the animation set that appears to have all the colours in it that I want and index this to 256 colours (as Jay said, sometimes the first image in the sequence, but other times I use another image if the first image is missing some key colours that ought to appear). I then save that palette in gimp and give it a name, then index each of the other images in the set using that saved palette so that all the images are indexed to have only the same 256 colours in.

This is slightly more time consuming than Jay's method, but it works for me. I have set up Gimp so that a series of keyboard shortcuts (e.g. ctrl1, ctrl2 etc) do the common operations that I use in sequence so I can just hold down the control key and click 1, 2, 3 etc. to carry out these kind of routines.

I always use APE for small images to avoid the faf of having to do this with GIMP, and it rarely crashes for me. I did quite a lot of work on APE's palette creation a while ago (whilst trying to predict how it would make a palette from a particular raw image, and not entirely succeeding) and I can tell you that the colour reduction involved in the palette creation algorithm for the icons and the animations is not the same because if you insert the same raw image as an icon and as an animation, then the palette file created does not give exactly the same result - there's an article somewhere about that, showing the results of my research. I used the in-game horse to test palette files on, and the palette files from icons and animations had the same sort of range of colours in, but were not the same.http://www.ztcdd.org/DG/index.php?topic=5460.0 and also http://www.ztcdd.org/DG/index.php?topic=5461.0
Dr Rick<br /><br />How does that work?

Jeff

Thanks. Shortly after my last post, and since I also like GIMP for basic stuff, I thought of exactly the same method Jay describes. I prefer that one in general, since it generates a palette based on *definitely* all colors in the graphic. I'd combine it with the BIMP plugin.

I really dislike APE. In fact, ever since I could use Zoot, I relied on it. APE makes such a mess of everything...

Just fixed a few more offset bugs, tweaked the program a bit more, tested the batch conversion (non-command line version), added the feature APE and Zoot have which consider the top left pixel to be transparent ...

This morning I already posted a brief "how to" on Zoo Tek on how to use ZT Studio to quickly generate a graphic of which the color can be replaced, but it came to my mind that I was lucky with my graphic. Basically it's just a mirror, so I only loaded the first view - to get exactly the same color palette at my disposal, then replaced the frame's image with a mirrored version, and saved it again. I had to use a hex editor to make it use the same .pal-file (currently it still takes the graphic's name and just adds '.pal', similar to APE and Zoot). So I'll probably add another feature, where you can select multiple images and just create one color palette out of them [given that the number of colors does not exceed 256 colors, otherwise I'll just refer to a how-to document which describes how you can do it with GIMP ).


dr rick

I am really looking forward to playing with this Jeff :eggyes

When a version of it is ready for testing, once you have posted it, please would you be kind enough to put a link to it here (or post a copy of it here!) :praise2 :angel3 :blush :wub2
Dr Rick<br /><br />How does that work?

Jeff

A private version will be shared with Vondell soon for further, very specific testing. After all, he's been kind enough to share some stuff with me too.

A public version with some brief how-to's should be available sometime soon after that.

fern

The updated ape that is in Testing now does not make a mess of everything.

Jeff

Quote from: fern on February 27, 2015, 08:33:06 PM
The updated ape that is in Testing now does not make a mess of everything.

I'm really curious about that version. And to see what's actually been changed :)

dr rick

I think that is the version of APE that I'm using and it is utterly WONDERFUL!!!! :luv :fireworks :praise2 miles better - it has more stuff available in it owing to Jay's clever jiggery-pokery and also there are very few corrections needed to the ucs file which is brilliant (all I do now is delete the excess pal files and then in the ucs, ad any lines like cSwims that I want, check it [no errors found so far] and remove one line of space at the start and end of the file - that is it! - I have not yet tried creating an animal with it so I can't vouch for how well it does that, but if it is anything like the ucs files created, it will no longer have all those idiotic foibles like creating multiples of eververything multiples of everything multiples of ... - you get the picture!)
Dr Rick<br /><br />How does that work?

Jeff

I do. It's why I always started from the original .AI file, and just copy-pasted and adjusted it, since a lot of characteristics were missing in the original APE. It was far less time consuming to have proper files. Only thing needed was adding the language blocks / changing the ID 19000. Although I generally work with a DLL file. I keep wondering why people kept up with (the original version of) APE, and most of its reincarnations so far.


Jay

Quote from: Jeff on February 28, 2015, 06:55:35 AMI always started from the original .AI file, and just copy-pasted and adjusted it, since a lot of characteristics were missing in the original APE. It was far less time consuming to have proper files. Only thing needed was adding the language blocks / changing the ID 19000.

More than that is needed to convert an original ".ai" file to a ".uca", ".ucs", or ".ucb" file.