]> git.saurik.com Git - wxWidgets.git/blob - src/common/imaggif.cpp
Forgot to add the files.
[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/imaggif.h"
28 #include "wx/gifdecod.h"
29 #include "wx/wfstream.h"
30 #include "wx/module.h"
31 #include "wx/log.h"
32
33 IMPLEMENT_DYNAMIC_CLASS(wxGIFHandler,wxImageHandler)
34
35 #if wxUSE_STREAMS
36
37 //-----------------------------------------------------------------------------
38 // wxGIFHandler
39 //-----------------------------------------------------------------------------
40
41 bool wxGIFHandler::LoadFile( wxImage *image, wxInputStream& stream, bool WXUNUSED(verbose) )
42 {
43 wxGIFDecoder *decod;
44 bool ok;
45
46 decod = new wxGIFDecoder(&stream, TRUE);
47
48 if (decod->ReadGIF() != E_OK)
49 {
50 wxLogDebug(_T("Error reading GIF"));
51 delete decod;
52 return FALSE;
53 }
54
55 image->Destroy();
56 ok = decod->ConvertToImage(image);
57
58 delete decod;
59 return ok;
60 }
61
62 bool wxGIFHandler::SaveFile( wxImage * WXUNUSED(image),
63 wxOutputStream& WXUNUSED(stream), bool verbose )
64 {
65 if (verbose) wxLogDebug(_T("wxGIFHandler is read-only!!"));
66 return FALSE;
67 }
68
69 bool wxGIFHandler::CanRead( wxInputStream& stream )
70 {
71 unsigned char hdr[5];
72
73 stream.Read(&hdr, 5);
74 stream.SeekI(-5, wxFromCurrent);
75 return (hdr[0] == 'G' && hdr[1] == 'I' && hdr[2] == 'F' && hdr[3] == '8' && hdr[4] == '9');
76 }
77
78 #endif