Annotation of embedaddon/php/ext/gd/libgd/pngtogd2.c, revision 1.1.1.1

1.1       misho       1: 
                      2: #include <stdio.h>
                      3: #include <stdlib.h>
                      4: #include "gd.h"
                      5: 
                      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. */
                     10: 
                     11: int
                     12: main (int argc, char **argv)
                     13: {
                     14:   gdImagePtr im;
                     15:   FILE *in, *out;
                     16:   int cs, fmt;
                     17: 
                     18:   if (argc != 5)
                     19:     {
                     20:       fprintf (stderr, "Usage: pngtogd2 filename.png filename.gd2 cs fmt\n");
                     21:       fprintf (stderr, "    where cs is the chunk size\n");
                     22:       fprintf (stderr, "          fmt is 1 for raw, 2 for compressed\n");
                     23:       exit (1);
                     24:     }
                     25:   in = fopen (argv[1], "rb");
                     26:   if (!in)
                     27:     {
                     28:       fprintf (stderr, "Input file does not exist!\n");
                     29:       exit (1);
                     30:     }
                     31:   im = gdImageCreateFromPng (in);
                     32:   fclose (in);
                     33:   if (!im)
                     34:     {
                     35:       fprintf (stderr, "Input is not in PNG format!\n");
                     36:       exit (1);
                     37:     }
                     38:   out = fopen (argv[2], "wb");
                     39:   if (!out)
                     40:     {
                     41:       fprintf (stderr, "Output file cannot be written to!\n");
                     42:       gdImageDestroy (im);
                     43:       exit (1);
                     44:     }
                     45:   cs = atoi (argv[3]);
                     46:   fmt = atoi (argv[4]);
                     47:   gdImageGd2 (im, out, cs, fmt);
                     48:   fclose (out);
                     49:   gdImageDestroy (im);
                     50: 
                     51:   return 0;
                     52: }

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>