Fixed CanRead(), which incorrectly forced version 89a, thus preventing
[wxWidgets.git] / src / common / imaggif.cpp
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: imaggif.cpp
3 // Purpose: wxGIFHandler
4 // Author: Vaclav Slavik
5 // Based on wxGIFDecoder by Guillermo Rodriguez Garcia
6 // RCS-ID: $Id$
7 // Licence: wxWindows licence
8 /////////////////////////////////////////////////////////////////////////////
9
10 /*
11 We don't put pragma implement in this file because it is already present in
12 src/common/image.cpp
13 */
14
15 // For compilers that support precompilation, includes "wx.h".
16 #include <wx/wxprec.h>
17
18 #ifdef __BORLANDC__
19 # pragma hdrstop
20 #endif
21
22 #ifndef WX_PRECOMP
23 # include "wx/defs.h"
24 #endif
25
26 #include "wx/image.h"
27 #include "wx/gifdecod.h"
28 #include "wx/wfstream.h"
29 #include "wx/module.h"
30 #include "wx/log.h"
31
32 IMPLEMENT_DYNAMIC_CLASS(wxGIFHandler,wxImageHandler)
33
34 #if wxUSE_STREAMS
35
36 //-----------------------------------------------------------------------------
37 // wxGIFHandler
38 //-----------------------------------------------------------------------------
39
40 bool wxGIFHandler::LoadFile( wxImage *image, wxInputStream& stream, bool WXUNUSED(verbose) )
41 {
42 wxGIFDecoder *decod;
43 bool ok;
44
45 decod = new wxGIFDecoder(&stream, TRUE);
46
47 if (decod->ReadGIF() != E_OK)
48 {
49 wxLogDebug(_T("Error reading GIF"));
50 delete decod;
51 return FALSE;
52 }
53
54 image->Destroy();
55 ok = decod->ConvertToImage(image);
56
57 delete decod;
58 return ok;
59 }
60
61 bool wxGIFHandler::SaveFile( wxImage * WXUNUSED(image),
62 wxOutputStream& WXUNUSED(stream), bool verbose )
63 {
64 if (verbose) wxLogDebug(_T("wxGIFHandler is read-only!!"));
65 return FALSE;
66 }
67
68 bool wxGIFHandler::CanRead( wxInputStream& stream )
69 {
70 wxGIFDecoder *decod;
71 bool ok;
72
73 decod = new wxGIFDecoder(&stream);
74 ok = decod->CanRead();
75
76 delete decod;
77 return ok;
78 }
79
80 #endif