]> git.saurik.com Git - wxWidgets.git/commitdiff
fixes for animated GIFs playing (patch 1097003)
authorVadim Zeitlin <vadim@wxwidgets.org>
Mon, 31 Jan 2005 22:21:11 +0000 (22:21 +0000)
committerVadim Zeitlin <vadim@wxwidgets.org>
Mon, 31 Jan 2005 22:21:11 +0000 (22:21 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@31683 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

contrib/src/animate/animate.cpp
src/common/gifdecod.cpp

index 2bca70edb856075c2cb96934133ecc83f630b097..5c687f927a0f9c85ba257f2d1e18e3eadfffa4b2 100644 (file)
@@ -245,7 +245,7 @@ bool wxAnimationPlayer::PlayFrame(int frame, wxWindow& window, const wxPoint& WX
     // Draw all intermediate frames that haven't been removed from the
     // animation
     int i;
-    for (i = 0; i < (frame - 1); i++)
+    for (i = 0; i < frame; i++)
     {
         if ((GetDisposalMethod(i) == wxANIM_DONOTREMOVE) || (GetDisposalMethod(i) == wxANIM_UNSPECIFIED))
         {
@@ -416,7 +416,7 @@ wxImage* wxGIFAnimation::GetFrame(int i) const
 {
     wxASSERT_MSG( (m_decoder != (wxGIFDecoder*) NULL), _T("m_decoder must be non-NULL"));
 
-    m_decoder->GoFrame(i);
+    m_decoder->GoFrame(i + 1);
 
     wxImage* image = new wxImage;
     m_decoder->ConvertToImage(image);
@@ -427,7 +427,7 @@ wxAnimationDisposal wxGIFAnimation::GetDisposalMethod(int i) const
 {
     wxASSERT_MSG( (m_decoder != (wxGIFDecoder*) NULL), _T("m_decoder must be non-NULL"));
 
-    m_decoder->GoFrame(i);
+    m_decoder->GoFrame(i + 1);
 
     int disposalMethod = m_decoder->GetDisposalMethod();
     return (wxAnimationDisposal) disposalMethod;
@@ -437,7 +437,7 @@ wxRect wxGIFAnimation::GetFrameRect(int i) const
 {
     wxASSERT_MSG( (m_decoder != (wxGIFDecoder*) NULL), _T("m_decoder must be non-NULL"));
 
-    m_decoder->GoFrame(i);
+    m_decoder->GoFrame(i + 1);
 
     wxRect rect(m_decoder->GetLeft(), m_decoder->GetTop(), m_decoder->GetWidth(), m_decoder->GetHeight());
     return rect;
@@ -447,7 +447,7 @@ int wxGIFAnimation::GetDelay(int i) const
 {
     wxASSERT_MSG( (m_decoder != (wxGIFDecoder*) NULL), _T("m_decoder must be non-NULL"));
 
-    m_decoder->GoFrame(i);
+    m_decoder->GoFrame(i + 1);
     return m_decoder->GetDelay();
 }
 
index c9cfe9b16ec1e2fbea84df6901e7d6a2c77d6ffa..f49f473d3baa03e1522ee55ee101b17ca7b9b621 100644 (file)
@@ -271,17 +271,19 @@ bool wxGIFDecoder::GoPrevFrame(bool cyclic)
 
 bool wxGIFDecoder::GoFrame(int which)
 {
-    int i;
-
     if (!IsAnimation())
         return false;
 
     if ((which >= 1) && (which <= m_nimages))
     {
+        m_image = 1;
         m_pimage = m_pfirst;
 
-        for (i = 0; i < which; i++)
+        while (m_image < which)
+        {
+            m_image++;
             m_pimage = m_pimage->next;
+        }
 
         return true;
     }
@@ -752,7 +754,7 @@ int wxGIFDecoder::ReadGIF()
                     transparent = buf[4];
 
                 /* read disposal method */
-                disposal = (buf[1] & 0x1C) - 1;
+                disposal = ((buf[1] & 0x1C) >> 2) - 1;
             }
             else
             /* other extension, skip */