1#include <stdlib.h>
2#include <stdio.h>
3#include <stdint.h>
4#include "wgif.h"
5
6#define WIDTH32 32
7#define HEIGHT32 32
8
9int fwr(uint8_t *ptr, size_t bytes, void *wp) {
10 return fwrite(ptr, 1, bytes, wp);
11}
12
13
14int main() {
15 uint32_t ct[3];
16 struct gif_file gf;
17 uint8_t bitmap[WIDTH32*HEIGHT32];
18 int x, y;
19
20 ct[0]=0x00ffff;
21 ct[1]=0xcccccc;
22 ct[2]=0x000000;
23
24 gf.wr_fnct=fwr;
25 gf.wparm=fopen("helloworld.gif", "wb");
26
27 gif_init(&gf, WIDTH32, HEIGHT32, ct, 3, 0);
28 for (y=0;y<HEIGHT32;y++) {
29 for (x=0;x<WIDTH32;x++) {
30 if (x<y) {
31 bitmap[x+y*WIDTH32]=0;
32 } else if (x==y) {
33 bitmap[x+y*WIDTH32]=2;
34 } else {
35 bitmap[x+y*WIDTH32]=1;
36 }
37 }
38 }
39 gif_image(&gf, 0, 0, WIDTH32, HEIGHT32, NULL((void *)0), 0, bitmap);
40 gif_end(&gf);
41
42 fclose(gf.wparm);
43
44 return 0;
45}