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
This commit is contained in:
Dimitri Schoolwerth
2011-01-28 07:27:34 +00:00
parent d4280c0282
commit 491da41173
2 changed files with 10 additions and 15 deletions

View File

@@ -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)
};

View File

@@ -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