From 71fd0e9fa9572aeb56a4fb7f729f69356620d700 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Sun, 3 Aug 2008 00:36:52 +0000 Subject: [PATCH] don't keep the transparent palette colour from the previous frame for the next one which may not have any transparency at all (#9747) git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/branches/WX_2_8_BRANCH@54944 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- docs/changes.txt | 1 + src/common/gifdecod.cpp | 13 ++++++------- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/docs/changes.txt b/docs/changes.txt index 29320000d9..9f98e8ea1e 100644 --- a/docs/changes.txt +++ b/docs/changes.txt @@ -111,6 +111,7 @@ All (GUI): - Fixed wrapping bug in wxRichTextCtrl when there were images present; now sets the cursor to the next line after pressing Shift+Enter. - Fix crash when reading malformed PCX images. +- Fix bug with wrong transparency in GIF animations (troelsk). All (Unix): diff --git a/src/common/gifdecod.cpp b/src/common/gifdecod.cpp index 5437982d7b..30c214aad6 100644 --- a/src/common/gifdecod.cpp +++ b/src/common/gifdecod.cpp @@ -186,7 +186,7 @@ bool wxGIFDecoder::ConvertToImage(unsigned int frame, wxImage *image) const // Get data for current frame -wxSize wxGIFDecoder::GetFrameSize(unsigned int frame) const +wxSize wxGIFDecoder::GetFrameSize(unsigned int frame) const { return wxSize(GetFrame(frame)->w, GetFrame(frame)->h); } @@ -593,7 +593,7 @@ bool wxGIFDecoder::CanRead(wxInputStream &stream) const wxGIFErrorCode wxGIFDecoder::LoadGIF(wxInputStream& stream) { unsigned int global_ncolors = 0; - int bits, interl, transparent, i; + int bits, interl, i; wxAnimationDisposal disposal; long size; long delay; @@ -655,7 +655,7 @@ wxGIFErrorCode wxGIFDecoder::LoadGIF(wxInputStream& stream) } // transparent colour, disposal method and delay default to unused - transparent = -1; + int transparent = -1; disposal = wxANIM_UNSPECIFIED; delay = -1; @@ -705,8 +705,7 @@ wxGIFErrorCode wxGIFDecoder::LoadGIF(wxInputStream& stream) delay = 10 * (buf[2] + 256 * buf[3]); // read transparent colour index, if used - if (buf[1] & 0x01) - transparent = buf[4]; + transparent = buf[1] & 0x01 ? buf[4] : -1; // read disposal method disposal = (wxAnimationDisposal)(((buf[1] & 0x1C) >> 2) - 1); @@ -756,8 +755,8 @@ wxGIFErrorCode wxGIFDecoder::LoadGIF(wxInputStream& stream) pimg->w = buf[4] + 256 * buf[5]; pimg->h = buf[6] + 256 * buf[7]; - if (anim && ((pimg->w == 0) || (pimg->w > (unsigned int)m_szAnimation.GetWidth()) || - (pimg->h == 0) || (pimg->h > (unsigned int)m_szAnimation.GetHeight()))) + if (anim && ((pimg->w == 0) || (pimg->w > (unsigned int)m_szAnimation.GetWidth()) || + (pimg->h == 0) || (pimg->h > (unsigned int)m_szAnimation.GetHeight()))) { Destroy(); return wxGIF_INVFORMAT;