~ubuntu-branches/ubuntu/natty/ntop/natty

« back to all changes in this revision

Viewing changes to gdchart0.94c/gd-1.8.3/pngtogd2.c

  • Committer: Bazaar Package Importer
  • Author(s): Ola Lundqvist
  • Date: 2005-01-30 21:59:13 UTC
  • mfrom: (2.1.1 warty)
  • Revision ID: james.westby@ubuntu.com-20050130215913-xc3ke963bw49b3k4
Tags: 2:3.0-5
* Updated README.Debian file so users will understand what to do at
  install, closes: #291794, #287802.
* Updated ntop init script to give better output.
* Also changed log directory from /var/lib/ntop to /var/log/ntop,
  closes: #252352.
* Quoted the interface list to allow whitespace, closes: #267248.
* Added a couple of logcheck ignores, closes: #269321, #269319.

Show diffs side-by-side

added added

removed removed

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