php-internal-docs 8.4.8
Unofficial docs for php/php-src
Loading...
Searching...
No Matches
pngtogd2.c
Go to the documentation of this file.
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
11int
12main (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}
fprintf($stream, string $format, mixed ... $values)
fclose($stream)
fopen(string $filename, string $mode, bool $use_include_path=false, $context=null)
void gdImageGd2(gdImagePtr im, FILE *out, int cs, int fmt)
Definition gd_gd2.c:832
gdImagePtr gdImageCreateFromPng(FILE *fd)
gdImage * gdImagePtr
Definition gd.h:248
int main(void)
Definition gddemo.c:7
void gdImageDestroy(gdImagePtr im)
Definition gd.c:247
exit(string|int $status=0)
out($f, $s)