login

<     >

2015-12-05 08:09:02 (UTC-02:00)

Marcel Rodrigues <marcelgmr@gmail.com>

Move example usage into separate file.

diff --git a/example.c b/example.c
new file mode 100644
index 0000000..8b96da0
--- /dev/null
+++ b/example.c
@@ -0,0 +1,31 @@
+#include "gifenc.h"
+
+int
+main()
+{
+    int i, j;
+    int w = 120, h = 90;
+
+    /* create a GIF */
+    GIF *gif = new_gif(
+        "example.gif",  /* file name */
+        w, h,           /* canvas size */
+        (uint8_t []) {  /* palette */
+            0x00, 0x00, 0x00, /* 0 -> black */
+            0xFF, 0x00, 0x00, /* 1 -> red */
+            0x00, 0xFF, 0x00, /* 2 -> green */
+            0x00, 0x00, 0xFF, /* 3 -> blue */
+        },
+        2,              /* palette depth == log2(# of colors) */
+        0               /* infinite loop */
+    );
+    /* draw some frames */
+    for (i = 0; i < 4*6/3; i++) {
+        for (j = 0; j < w*h; j++)
+            gif->frame[j] = (i*3 + j) / 6 % 4;
+        add_frame(gif, 10);
+    }
+    /* remember to close the GIF */
+    close_gif(gif);
+    return 0;
+}

diff --git a/gifenc.c b/gifenc.c
index eb7aa85..0f7db45 100644
--- a/gifenc.c
+++ b/gifenc.c
@@ -266,35 +266,3 @@ close_gif(GIF* gif)
     close(gif->fd);
     free(gif);
 }
-
-#ifdef MAIN
-int
-main()
-{
-    int i, j;
-    int w = 120, h = 90;
-
-    /* create a GIF */
-    GIF *gif = new_gif(
-        "example.gif",  /* file name */
-        w, h,           /* canvas size */
-        (uint8_t []) {  /* palette */
-            0x00, 0x00, 0x00, /* 0 -> black */
-            0xFF, 0x00, 0x00, /* 1 -> red */
-            0x00, 0xFF, 0x00, /* 2 -> green */
-            0x00, 0x00, 0xFF, /* 3 -> blue */
-        },
-        2,              /* palette depth == log2(# of colors) */
-        0               /* infinite loop */
-    );
-    /* draw some frames */
-    for (i = 0; i < 4*6/3; i++) {
-        for (j = 0; j < w*h; j++)
-            gif->frame[j] = (i*3 + j) / 6 % 4;
-        add_frame(gif, 10);
-    }
-    /* remember to close the GIF */
-    close_gif(gif);
-    return 0;
-}
-#endif