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:
@@ -19,6 +19,8 @@
|
|||||||
|
|
||||||
#if wxUSE_GIF
|
#if wxUSE_GIF
|
||||||
|
|
||||||
|
#define wxIMAGE_OPTION_GIF_COMMENT wxT("GifComment")
|
||||||
|
|
||||||
struct wxRGB;
|
struct wxRGB;
|
||||||
struct GifHashTableType;
|
struct GifHashTableType;
|
||||||
class WXDLLIMPEXP_FWD_CORE wxImageArray; // anidecod.h
|
class WXDLLIMPEXP_FWD_CORE wxImageArray; // anidecod.h
|
||||||
@@ -43,8 +45,7 @@ public:
|
|||||||
|
|
||||||
// Save animated gif
|
// Save animated gif
|
||||||
bool SaveAnimation(const wxImageArray& images, wxOutputStream *stream,
|
bool SaveAnimation(const wxImageArray& images, wxOutputStream *stream,
|
||||||
bool verbose = true, int delayMilliSecs = 1000,
|
bool verbose = true, int delayMilliSecs = 1000);
|
||||||
const wxString& comment = wxEmptyString);
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual int DoGetImageCount(wxInputStream& stream);
|
virtual int DoGetImageCount(wxInputStream& stream);
|
||||||
@@ -53,7 +54,7 @@ protected:
|
|||||||
bool DoSaveFile(const wxImage&, wxOutputStream *, bool verbose,
|
bool DoSaveFile(const wxImage&, wxOutputStream *, bool verbose,
|
||||||
bool first, int delayMilliSecs, bool loop,
|
bool first, int delayMilliSecs, bool loop,
|
||||||
const wxRGB *pal, int palCount,
|
const wxRGB *pal, int palCount,
|
||||||
int mask_index, const wxString& comment = wxEmptyString);
|
int mask_index);
|
||||||
#endif // wxUSE_STREAMS
|
#endif // wxUSE_STREAMS
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
@@ -82,8 +83,7 @@ protected:
|
|||||||
bool SetupCompress(wxOutputStream *, int bpp);
|
bool SetupCompress(wxOutputStream *, int bpp);
|
||||||
bool CompressLine(wxOutputStream *, const wxUint8 *line, int lineLen);
|
bool CompressLine(wxOutputStream *, const wxUint8 *line, int lineLen);
|
||||||
#endif
|
#endif
|
||||||
public:
|
|
||||||
static wxString ms_comment;
|
|
||||||
private:
|
private:
|
||||||
DECLARE_DYNAMIC_CLASS(wxGIFHandler)
|
DECLARE_DYNAMIC_CLASS(wxGIFHandler)
|
||||||
};
|
};
|
||||||
|
@@ -69,8 +69,6 @@ struct GifHashTableType
|
|||||||
wxUint32 HTable[HT_SIZE];
|
wxUint32 HTable[HT_SIZE];
|
||||||
};
|
};
|
||||||
|
|
||||||
/*static*/ wxString wxGIFHandler::ms_comment;
|
|
||||||
|
|
||||||
IMPLEMENT_DYNAMIC_CLASS(wxGIFHandler,wxImageHandler)
|
IMPLEMENT_DYNAMIC_CLASS(wxGIFHandler,wxImageHandler)
|
||||||
|
|
||||||
//----------------------------------------------------------------------------
|
//----------------------------------------------------------------------------
|
||||||
@@ -179,7 +177,7 @@ bool wxGIFHandler::SaveFile(wxImage *image,
|
|||||||
|
|
||||||
return wxGIFHandler_GetPalette(*image, pal, &palCount, &maskIndex)
|
return wxGIFHandler_GetPalette(*image, pal, &palCount, &maskIndex)
|
||||||
&& DoSaveFile(*image, &stream, verbose, true /*first?*/, 0,
|
&& DoSaveFile(*image, &stream, verbose, true /*first?*/, 0,
|
||||||
false /*loop?*/, pal, palCount, maskIndex, ms_comment)
|
false /*loop?*/, pal, palCount, maskIndex)
|
||||||
&& wxGIFHandler_WriteTerm(&stream);
|
&& wxGIFHandler_WriteTerm(&stream);
|
||||||
#else
|
#else
|
||||||
wxUnusedVar(image);
|
wxUnusedVar(image);
|
||||||
@@ -211,7 +209,7 @@ int wxGIFHandler::DoGetImageCount( wxInputStream& stream )
|
|||||||
|
|
||||||
bool wxGIFHandler::DoSaveFile(const wxImage& image, wxOutputStream *stream,
|
bool wxGIFHandler::DoSaveFile(const wxImage& image, wxOutputStream *stream,
|
||||||
bool WXUNUSED(verbose), bool first, int delayMilliSecs, bool loop,
|
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);
|
const unsigned long colorcount = image.CountColours(256+1);
|
||||||
bool ok = colorcount && (colorcount <= 256);
|
bool ok = colorcount && (colorcount <= 256);
|
||||||
@@ -227,7 +225,7 @@ bool wxGIFHandler::DoSaveFile(const wxImage& image, wxOutputStream *stream,
|
|||||||
if (first)
|
if (first)
|
||||||
{
|
{
|
||||||
ok = wxGIFHandler_WriteHeader(stream, width, height, loop,
|
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)
|
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,
|
bool wxGIFHandler::SaveAnimation(const wxImageArray& images,
|
||||||
wxOutputStream *stream, bool verbose, int delayMilliSecs,
|
wxOutputStream *stream, bool verbose, int delayMilliSecs)
|
||||||
const wxString& comment)
|
|
||||||
{
|
{
|
||||||
#if wxUSE_PALETTE
|
#if wxUSE_PALETTE
|
||||||
bool ok = true;
|
bool ok = true;
|
||||||
@@ -334,8 +331,7 @@ bool wxGIFHandler::SaveAnimation(const wxImageArray& images,
|
|||||||
|
|
||||||
ok = wxGIFHandler_GetPalette(image, pal, &palCount, &maskIndex)
|
ok = wxGIFHandler_GetPalette(image, pal, &palCount, &maskIndex)
|
||||||
&& DoSaveFile(image, stream, verbose, i == 0 /*first?*/, delayMilliSecs,
|
&& DoSaveFile(image, stream, verbose, i == 0 /*first?*/, delayMilliSecs,
|
||||||
true /*loop?*/, pal, palCount, maskIndex,
|
true /*loop?*/, pal, palCount, maskIndex);
|
||||||
comment.length() ? comment : ms_comment);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return ok && wxGIFHandler_WriteTerm(stream);
|
return ok && wxGIFHandler_WriteTerm(stream);
|
||||||
@@ -344,7 +340,6 @@ bool wxGIFHandler::SaveAnimation(const wxImageArray& images,
|
|||||||
wxUnusedVar(stream);
|
wxUnusedVar(stream);
|
||||||
wxUnusedVar(verbose);
|
wxUnusedVar(verbose);
|
||||||
wxUnusedVar(delayMilliSecs);
|
wxUnusedVar(delayMilliSecs);
|
||||||
wxUnusedVar(comment);
|
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
#endif
|
#endif
|
||||||
|
Reference in New Issue
Block a user