Skip to content

Commit 3569322

Browse files
committed
README: improve the "Putting it all together" section.
1 parent 162a1d6 commit 3569322

File tree

1 file changed

+15
-12
lines changed

1 file changed

+15
-12
lines changed

README

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -125,19 +125,22 @@ GIF file without closing and reopening it.
125125

126126
6. Putting it all together
127127

128-
gd_GIF *gif = gd_open_gif("some_animation.gif");
129-
char *buffer = malloc(gif->width * gif->height * 3);
130-
for (unsigned looped = 1;; looped++) {
131-
while (gd_get_frame(gif)) {
132-
gd_render_frame(gif, buffer);
133-
/* insert code to render buffer to screen here */
128+
A simplified skeleton of a GIF viewer may look like this:
129+
130+
gd_GIF *gif = gd_open_gif("some_animation.gif");
131+
char *buffer = malloc(gif->width * gif->height * 3);
132+
for (unsigned looped = 1;; looped++) {
133+
while (gd_get_frame(gif)) {
134+
gd_render_frame(gif, buffer);
135+
/* insert code to render buffer to screen
136+
and wait for delay time to pass here */
137+
}
138+
if (looped == gif->loop_count)
139+
break;
140+
gd_rewind(gif);
134141
}
135-
if (looped == gif->loop_count)
136-
break;
137-
gd_rewind(gif);
138-
}
139-
free(buffer);
140-
gd_close_gif(gif);
142+
free(buffer);
143+
gd_close_gif(gif);
141144

142145
7. Reading streamed metadata with extension hooks
143146

0 commit comments

Comments
 (0)