From 39b0f93fb71d415c5061ec46f8bf79e049ede5f1 Mon Sep 17 00:00:00 2001 From: comex Date: Sat, 21 Feb 2009 18:16:34 -0500 Subject: gentpl - move error --- gentpl/gentpl.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) (limited to 'gentpl/gentpl.c') diff --git a/gentpl/gentpl.c b/gentpl/gentpl.c index 9a55f13..35b8a35 100644 --- a/gentpl/gentpl.c +++ b/gentpl/gentpl.c @@ -31,17 +31,18 @@ int main(int argc, char **argv) { } im = gdImageCreateFromPng(in); fclose(in); - FILE *out = fopen(argv[2], "wb"); - if(!out) { - printf("Failed to open %s\n", argv[2]); // why strerror not working? - exit(1); - } if(gdImageSX(im) % 4 != 0 || gdImageSY(im) % 4 != 0) { printf("Bad dimensions\n"); exit(1); } + FILE *out = fopen(argv[2], "wb"); + if(!out) { + printf("Failed to open %s\n", argv[2]); // why strerror not working? + exit(1); + } + char magic[] = {0x00, 0x20, 0xaf, 0x30}; fwrite(magic, 1, 4, out); @@ -87,4 +88,4 @@ int main(int argc, char **argv) { fclose(out); gdImageDestroy(im); -} \ No newline at end of file +} -- cgit v1.3.1