~ubuntu-branches/ubuntu/lucid/graphviz/lucid-security

« back to all changes in this revision

Viewing changes to gd/pngtogd.c

  • Committer: Bazaar Package Importer
  • Author(s): Stephen M Moraco
  • Date: 2002-02-05 18:52:12 UTC
  • Revision ID: james.westby@ubuntu.com-20020205185212-8i04c70te00rc40y
Tags: upstream-1.7.16
ImportĀ upstreamĀ versionĀ 1.7.16

Show diffs side-by-side

added added

removed removed

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