| 1 | #include <stdlib.h>
|
| 2 | #include <stdio.h>
|
| 3 | #include <stdint.h>
|
| 4 | #include "wgif.h"
|
| 5 |
|
| 6 | #define WIDTH 32
|
| 7 | #define HEIGHT 32
|
| 8 |
|
| 9 | int fwr(uint8_t *ptr, size_t bytes, void *wp) {
|
| 10 | return fwrite(ptr, 1, bytes, wp);
|
| 11 | }
|
| 12 |
|
| 13 |
|
| 14 | int main() {
|
| 15 | uint32_t ct[3];
|
| 16 | struct gif_file gf;
|
| 17 | uint8_t bitmap[WIDTH*HEIGHT];
|
| 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, WIDTH, HEIGHT, ct, 3, 0);
|
| 28 | for (y=0;y<HEIGHT;y++) {
|
| 29 | for (x=0;x<WIDTH;x++) {
|
| 30 | if (x<y) {
|
| 31 | bitmap[x+y*WIDTH]=0;
|
| 32 | } else if (x==y) {
|
| 33 | bitmap[x+y*WIDTH]=2;
|
| 34 | } else {
|
| 35 | bitmap[x+y*WIDTH]=1;
|
| 36 | }
|
| 37 | }
|
| 38 | }
|
| 39 | gif_image(&gf, 0, 0, WIDTH, HEIGHT, NULL, 0, bitmap);
|
| 40 | gif_end(&gf);
|
| 41 |
|
| 42 | fclose(gf.wparm);
|
| 43 |
|
| 44 | return 0;
|
| 45 | }
|