]>
git.saurik.com Git - wxWidgets.git/blob - src/common/imaggif.cpp
fdb9a4971d1af78c4521d8d47c9fe2bb64c1d961
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: src/common/imaggif.cpp
3 // Purpose: wxGIFHandler
4 // Author: Vaclav Slavik & Guillermo Rodriguez Garcia
6 // Copyright: (c) 1999 Vaclav Slavik & Guillermo Rodriguez Garcia
7 // Licence: wxWindows licence
8 /////////////////////////////////////////////////////////////////////////////
10 // For compilers that support precompilation, includes "wx.h".
11 #include "wx/wxprec.h"
17 #if wxUSE_IMAGE && wxUSE_GIF
24 #include "wx/imaggif.h"
25 #include "wx/gifdecod.h"
26 #include "wx/wfstream.h"
28 IMPLEMENT_DYNAMIC_CLASS(wxGIFHandler
,wxImageHandler
)
30 //-----------------------------------------------------------------------------
32 //-----------------------------------------------------------------------------
36 bool wxGIFHandler::LoadFile(wxImage
*image
, wxInputStream
& stream
,
37 bool verbose
, int index
)
44 decod
= new wxGIFDecoder();
45 error
= decod
->LoadGIF(stream
);
47 if ((error
!= wxGIF_OK
) && (error
!= wxGIF_TRUNCATED
))
54 wxLogError(_("GIF: error in GIF image format."));
57 wxLogError(_("GIF: not enough memory."));
60 wxLogError(_("GIF: unknown error!!!"));
68 if ((error
== wxGIF_TRUNCATED
) && verbose
)
70 wxLogError(_("GIF: data stream seems to be truncated."));
71 /* go on; image data is OK */
76 ok
= decod
->ConvertToImage(index
!= -1 ? (size_t)index
: 0, image
);
80 wxLogError(_("GIF: Invalid gif index."));
88 bool wxGIFHandler::SaveFile( wxImage
* WXUNUSED(image
),
89 wxOutputStream
& WXUNUSED(stream
), bool verbose
)
93 wxLogDebug(wxT("GIF: the handler is read-only!!"));
99 bool wxGIFHandler::DoCanRead( wxInputStream
& stream
)
102 return decod
.CanRead(stream
);
103 // it's ok to modify the stream position here
106 int wxGIFHandler::DoGetImageCount( wxInputStream
& stream
)
109 wxGIFErrorCode error
= decod
.LoadGIF(stream
);
110 if ( (error
!= wxGIF_OK
) && (error
!= wxGIF_TRUNCATED
) )
113 // NOTE: this function modifies the current stream position but it's ok
114 // (see wxImageHandler::GetImageCount)
116 return decod
.GetFrameCount();
119 #endif // wxUSE_STREAMS