Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable loop #19

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 7 additions & 5 deletions gif.h
Original file line number Diff line number Diff line change
Expand Up @@ -734,8 +734,10 @@ typedef struct

// Creates a gif file.
// The input GIFWriter is assumed to be uninitialized.
// The delay value is the time between frames in hundredths of a second - note that not all viewers pay much attention to this value.
bool GifBegin( GifWriter* writer, const char* filename, uint32_t width, uint32_t height, uint32_t delay, int32_t bitDepth = 8, bool dither = false )
// The delay value is the time between frames in hundredths of a second.
// The repeat value is the number of times the sequence should be repeated (1 to 65535 times) or loop when repeat is zero.
// Note that not all viewers pay much attention to these values.
bool GifBegin( GifWriter* writer, const char* filename, uint32_t width, uint32_t height, uint32_t delay, int32_t bitDepth = 8, bool dither = false, uint16_t repeat = 0)
{
(void)bitDepth; (void)dither; // Mute "Unused argument" warnings
#if defined(_MSC_VER) && (_MSC_VER >= 1400)
Expand Down Expand Up @@ -773,7 +775,7 @@ bool GifBegin( GifWriter* writer, const char* filename, uint32_t width, uint32_t
fputc(0, writer->f);
fputc(0, writer->f);

if( delay != 0 )
if( delay != 0 || repeat != 0 )
{
// animation header
fputc(0x21, writer->f); // extension
Expand All @@ -783,8 +785,8 @@ bool GifBegin( GifWriter* writer, const char* filename, uint32_t width, uint32_t
fputc(3, writer->f); // 3 bytes of NETSCAPE2.0 data

fputc(1, writer->f); // JUST BECAUSE
fputc(0, writer->f); // loop infinitely (byte 0)
fputc(0, writer->f); // loop infinitely (byte 1)
fputc(repeat & 0xFF, writer->f); // repeat (byte 0)
fputc((repeat & 0xFF00) >> 8, writer->f); // repeat (byte 1)

fputc(0, writer->f); // block terminator
}
Expand Down