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