~ubuntu-branches/ubuntu/hardy/php5/hardy-updates

« back to all changes in this revision

Viewing changes to ext/gd/libgd/gdtopng.c

  • Committer: Bazaar Package Importer
  • Author(s): Adam Conrad
  • Date: 2005-10-09 03:14:32 UTC
  • Revision ID: james.westby@ubuntu.com-20051009031432-kspik3lobxstafv9
Tags: upstream-5.0.5
ImportĀ upstreamĀ versionĀ 5.0.5

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#include <stdio.h>
 
2
#include "gd.h"
 
3
 
 
4
/* A short program which converts a .png file into a .gd file, for
 
5
   your convenience in creating images on the fly from a
 
6
   basis image that must be loaded quickly. The .gd format
 
7
   is not intended to be a general-purpose format. */
 
8
 
 
9
int
 
10
main (int argc, char **argv)
 
11
{
 
12
  gdImagePtr im;
 
13
  FILE *in, *out;
 
14
  if (argc != 3)
 
15
    {
 
16
      fprintf (stderr, "Usage: gdtopng filename.gd filename.png\n");
 
17
      exit (1);
 
18
    }
 
19
  in = fopen (argv[1], "rb");
 
20
  if (!in)
 
21
    {
 
22
      fprintf (stderr, "Input file does not exist!\n");
 
23
      exit (1);
 
24
    }
 
25
  im = gdImageCreateFromGd (in);
 
26
  fclose (in);
 
27
  if (!im)
 
28
    {
 
29
      fprintf (stderr, "Input is not in PNG format!\n");
 
30
      exit (1);
 
31
    }
 
32
  out = fopen (argv[2], "wb");
 
33
  if (!out)
 
34
    {
 
35
      fprintf (stderr, "Output file cannot be written to!\n");
 
36
      gdImageDestroy (im);
 
37
      exit (1);
 
38
    }
 
39
  gdImagePng (im, out);
 
40
  fclose (out);
 
41
  gdImageDestroy (im);
 
42
 
 
43
  return 0;
 
44
}