From 491da41173b536bcb27ccddf81d8e70b8bffaf3e Mon Sep 17 00:00:00 2001 From: Dimitri Schoolwerth Date: Fri, 28 Jan 2011 07:27:34 +0000 Subject: [PATCH] Changed the procedure for writing a comment to a GIF image. Use wxImage.SetOption with newly introduced wxIMAGE_OPTION_GIF_COMMENT to set a GIF's image comment now. Formerly this was done (since recently) using wxGIFHandler::ms_comment which has now been removed. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@66800 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- include/wx/imaggif.h | 10 +++++----- src/common/imaggif.cpp | 15 +++++---------- 2 files changed, 10 insertions(+), 15 deletions(-) diff --git a/include/wx/imaggif.h b/include/wx/imaggif.h index 103e934fb6..0f30653699 100644 --- a/include/wx/imaggif.h +++ b/include/wx/imaggif.h @@ -19,6 +19,8 @@ #if wxUSE_GIF +#define wxIMAGE_OPTION_GIF_COMMENT wxT("GifComment") + struct wxRGB; struct GifHashTableType; class WXDLLIMPEXP_FWD_CORE wxImageArray; // anidecod.h @@ -43,8 +45,7 @@ public: // Save animated gif bool SaveAnimation(const wxImageArray& images, wxOutputStream *stream, - bool verbose = true, int delayMilliSecs = 1000, - const wxString& comment = wxEmptyString); + bool verbose = true, int delayMilliSecs = 1000); protected: virtual int DoGetImageCount(wxInputStream& stream); @@ -53,7 +54,7 @@ protected: bool DoSaveFile(const wxImage&, wxOutputStream *, bool verbose, bool first, int delayMilliSecs, bool loop, const wxRGB *pal, int palCount, - int mask_index, const wxString& comment = wxEmptyString); + int mask_index); #endif // wxUSE_STREAMS protected: @@ -82,8 +83,7 @@ protected: bool SetupCompress(wxOutputStream *, int bpp); bool CompressLine(wxOutputStream *, const wxUint8 *line, int lineLen); #endif -public: - static wxString ms_comment; + private: DECLARE_DYNAMIC_CLASS(wxGIFHandler) }; diff --git a/src/common/imaggif.cpp b/src/common/imaggif.cpp index e07eb27cb0..75e8f73def 100644 --- a/src/common/imaggif.cpp +++ b/src/common/imaggif.cpp @@ -69,8 +69,6 @@ struct GifHashTableType wxUint32 HTable[HT_SIZE]; }; -/*static*/ wxString wxGIFHandler::ms_comment; - IMPLEMENT_DYNAMIC_CLASS(wxGIFHandler,wxImageHandler) //---------------------------------------------------------------------------- @@ -179,7 +177,7 @@ bool wxGIFHandler::SaveFile(wxImage *image, return wxGIFHandler_GetPalette(*image, pal, &palCount, &maskIndex) && DoSaveFile(*image, &stream, verbose, true /*first?*/, 0, - false /*loop?*/, pal, palCount, maskIndex, ms_comment) + false /*loop?*/, pal, palCount, maskIndex) && wxGIFHandler_WriteTerm(&stream); #else wxUnusedVar(image); @@ -211,7 +209,7 @@ int wxGIFHandler::DoGetImageCount( wxInputStream& stream ) bool wxGIFHandler::DoSaveFile(const wxImage& image, wxOutputStream *stream, bool WXUNUSED(verbose), bool first, int delayMilliSecs, bool loop, - const wxRGB *pal, int palCount, int maskIndex, const wxString& comment) + const wxRGB *pal, int palCount, int maskIndex) { const unsigned long colorcount = image.CountColours(256+1); bool ok = colorcount && (colorcount <= 256); @@ -227,7 +225,7 @@ bool wxGIFHandler::DoSaveFile(const wxImage& image, wxOutputStream *stream, if (first) { ok = wxGIFHandler_WriteHeader(stream, width, height, loop, - pal, palCount, comment); + pal, palCount, image.GetOption(wxIMAGE_OPTION_GIF_COMMENT)); } ok = ok && wxGIFHandler_WriteControl(stream, maskIndex, delayMilliSecs) @@ -301,8 +299,7 @@ bool wxGIFHandler::DoSaveFile(const wxImage& image, wxOutputStream *stream, } bool wxGIFHandler::SaveAnimation(const wxImageArray& images, - wxOutputStream *stream, bool verbose, int delayMilliSecs, - const wxString& comment) + wxOutputStream *stream, bool verbose, int delayMilliSecs) { #if wxUSE_PALETTE bool ok = true; @@ -334,8 +331,7 @@ bool wxGIFHandler::SaveAnimation(const wxImageArray& images, ok = wxGIFHandler_GetPalette(image, pal, &palCount, &maskIndex) && DoSaveFile(image, stream, verbose, i == 0 /*first?*/, delayMilliSecs, - true /*loop?*/, pal, palCount, maskIndex, - comment.length() ? comment : ms_comment); + true /*loop?*/, pal, palCount, maskIndex); } return ok && wxGIFHandler_WriteTerm(stream); @@ -344,7 +340,6 @@ bool wxGIFHandler::SaveAnimation(const wxImageArray& images, wxUnusedVar(stream); wxUnusedVar(verbose); wxUnusedVar(delayMilliSecs); - wxUnusedVar(comment); return false; #endif -- 2.47.2