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