summaryrefslogtreecommitdiff
path: root/src/gdparttopng.c
diff options
context:
space:
mode:
authorpierre <none@none>2006-04-05 15:42:56 +0000
committerpierre <none@none>2006-04-05 15:42:56 +0000
commit1cdea7482e810bfb1d8deb439a52a20c7db7ebd9 (patch)
tree4985f6ab8c60688b650cf40ea87d4f6670c4b3c5 /src/gdparttopng.c
parentff50323cfa78527876c9efaff1a828c9694c817b (diff)
downloadlibgd-1cdea7482e810bfb1d8deb439a52a20c7db7ebd9.tar.gz
- sync to 2.0.1GD_2_0_1
Diffstat (limited to 'src/gdparttopng.c')
-rw-r--r--src/gdparttopng.c92
1 files changed, 48 insertions, 44 deletions
diff --git a/src/gdparttopng.c b/src/gdparttopng.c
index 971c82d..03386b8 100644
--- a/src/gdparttopng.c
+++ b/src/gdparttopng.c
@@ -1,51 +1,55 @@
#include <stdio.h>
-#include <stdlib.h> /* For atoi */
+#include <stdlib.h> /* For atoi */
#include "gd.h"
/* A short program which converts a .png file into a .gd file, for
- your convenience in creating images on the fly from a
- basis image that must be loaded quickly. The .gd format
- is not intended to be a general-purpose format. */
+ your convenience in creating images on the fly from a
+ basis image that must be loaded quickly. The .gd format
+ is not intended to be a general-purpose format. */
-int main(int argc, char **argv)
+int
+main (int argc, char **argv)
{
- gdImagePtr im;
- FILE *in, *out;
- int x, y, w, h;
-
- if (argc != 7) {
- fprintf(stderr, "Usage: gdparttopng filename.gd filename.png x y w h\n");
- exit(1);
- }
- in = fopen(argv[1], "rb");
- if (!in) {
- fprintf(stderr, "Input file does not exist!\n");
- exit(1);
- }
-
- x = atoi(argv[3]);
- y = atoi(argv[4]);
- w = atoi(argv[5]);
- h = atoi(argv[6]);
-
- printf("Extracting from (%d, %d), size is %dx%d\n", x, y, w, h);
-
- im = gdImageCreateFromGd2Part(in, x, y, w, h);
- fclose(in);
- if (!im) {
- fprintf(stderr, "Input is not in PNG format!\n");
- exit(1);
- }
- out = fopen(argv[2], "wb");
- if (!out) {
- fprintf(stderr, "Output file cannot be written to!\n");
- gdImageDestroy(im);
- exit(1);
- }
- gdImagePng(im, out);
- fclose(out);
- gdImageDestroy(im);
-
- return 0;
+ gdImagePtr im;
+ FILE *in, *out;
+ int x, y, w, h;
+
+ if (argc != 7)
+ {
+ fprintf (stderr, "Usage: gdparttopng filename.gd filename.png x y w h\n");
+ exit (1);
+ }
+ in = fopen (argv[1], "rb");
+ if (!in)
+ {
+ fprintf (stderr, "Input file does not exist!\n");
+ exit (1);
+ }
+
+ x = atoi (argv[3]);
+ y = atoi (argv[4]);
+ w = atoi (argv[5]);
+ h = atoi (argv[6]);
+
+ printf ("Extracting from (%d, %d), size is %dx%d\n", x, y, w, h);
+
+ im = gdImageCreateFromGd2Part (in, x, y, w, h);
+ fclose (in);
+ if (!im)
+ {
+ fprintf (stderr, "Input is not in PNG format!\n");
+ exit (1);
+ }
+ out = fopen (argv[2], "wb");
+ if (!out)
+ {
+ fprintf (stderr, "Output file cannot be written to!\n");
+ gdImageDestroy (im);
+ exit (1);
+ }
+ gdImagePng (im, out);
+ fclose (out);
+ gdImageDestroy (im);
+
+ return 0;
}
-