diff --git a/sdk/Windows/SMXGif.cpp b/sdk/Windows/SMXGif.cpp index b3b47f5..5e02fc9 100644 --- a/sdk/Windows/SMXGif.cpp +++ b/sdk/Windows/SMXGif.cpp @@ -47,6 +47,13 @@ void SMXGif::GIFImage::Blit(SMXGif::GIFImage &src, int dst_left, int dst_top, in get(x + dst_left, y + dst_top) = src.get(x, y); } } +bool SMXGif::GIFImage::operator==(const GIFImage &rhs) const +{ + return + width == rhs.width && + height == rhs.height && + image == rhs.image; +} class DataStream { @@ -394,6 +401,14 @@ void GIFDecoder::ReadAllFrames(vector &frames) gif_frame.height = global_data.height; gif_frame.milliseconds = global_data.duration * 10; gif_frame.frame = frame_image; + + // If this frame is identical to the previous one, just extend the previous frame. + if(!frames.empty() && gif_frame.frame == frames.back().frame) + { + frames.back().milliseconds += gif_frame.milliseconds; + continue; + } + frames.push_back(gif_frame); frame++; diff --git a/sdk/Windows/SMXGif.h b/sdk/Windows/SMXGif.h index e02f27c..4415305 100644 --- a/sdk/Windows/SMXGif.h +++ b/sdk/Windows/SMXGif.h @@ -47,6 +47,8 @@ namespace SMXGif // Copy src into a rectangle in this image. void Blit(GIFImage &src, int dst_left, int dst_top, int dst_width, int dst_height); + bool operator==(const GIFImage &rhs) const; + private: std::vector image; }; diff --git a/sdk/Windows/SMXPanelAnimation.cpp b/sdk/Windows/SMXPanelAnimation.cpp index 3ee4a07..3826f26 100644 --- a/sdk/Windows/SMXPanelAnimation.cpp +++ b/sdk/Windows/SMXPanelAnimation.cpp @@ -320,7 +320,6 @@ void SMXPanelAnimation::Load(const vector &frames, int pane ConvertToPanelGraphic16(gif_frame.frame, panel_graphic, panel); else ConvertToPanelGraphic25(gif_frame.frame, panel_graphic, panel); - m_aPanelGraphics.push_back(panel_graphic); // GIFs have a very low-resolution duration field, with 10ms units. // The panels run at 30 FPS internally, or 33 1/3 ms, but GIF can only @@ -333,6 +332,7 @@ void SMXPanelAnimation::Load(const vector &frames, int pane else seconds = gif_frame.milliseconds / 1000.0; + m_aPanelGraphics.push_back(panel_graphic); m_iFrameDurations.push_back(seconds); }