6
/* A short program which converts a .png file into a .gd file, for
7
your convenience in creating images on the fly from a
8
basis image that must be loaded quickly. The .gd format
9
is not intended to be a general-purpose format. */
12
main (int argc, char **argv)
19
fprintf (stderr, "Usage: gd2copypal palettefile.gd2 filename.gd2\n");
22
in = fopen (argv[1], "rb");
25
fprintf (stderr, "Palette file does not exist!\n");
28
pal = gdImageCreateFromGd2 (in);
32
fprintf (stderr, "Palette is not in GD2 format!\n");
36
in = fopen (argv[2], "rb");
39
fprintf (stderr, "Input file does not exist!\n");
42
im = gdImageCreateFromGd2 (in);
46
fprintf (stderr, "Input is not in GD2 format!\n");
50
gdImagePaletteCopy (im, pal);
52
out = fopen (argv[2], "wb");
55
fprintf (stderr, "Output file cannot be written to!\n");
59
gdImageGd2 (im, out, 128, 2);