]>
Commit | Line | Data |
---|---|---|
b59bf2db JS |
1 | ///////////////////////////////////////////////////////////////////////////// |
2 | // Name: imaggif.cpp | |
3 | // Purpose: wxGIFHandler | |
8a68d8b6 | 4 | // Author: Vaclav Slavik & Guillermo Rodriguez Garcia |
464122b6 | 5 | // RCS-ID: $Id$ |
e08e239b | 6 | // Copyright: (c) 1999 Vaclav Slavik & Guillermo Rodriguez Garcia |
b59bf2db JS |
7 | // Licence: wxWindows licence |
8 | ///////////////////////////////////////////////////////////////////////////// | |
9 | ||
ce4169a4 | 10 | /* |
bd2fdefe GRG |
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". | |
3096bd2f | 16 | #include "wx/wxprec.h" |
b59bf2db JS |
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 | |
9ab6ee85 | 26 | #if wxUSE_GIF |
8a68d8b6 | 27 | |
ce4169a4 | 28 | #include "wx/image.h" |
464122b6 | 29 | #include "wx/gifdecod.h" |
ce4169a4 | 30 | #include "wx/wfstream.h" |
ce4169a4 | 31 | #include "wx/log.h" |
f6b77239 | 32 | #include "wx/intl.h" |
b59bf2db | 33 | |
ce4169a4 RR |
34 | IMPLEMENT_DYNAMIC_CLASS(wxGIFHandler,wxImageHandler) |
35 | ||
b59bf2db JS |
36 | //----------------------------------------------------------------------------- |
37 | // wxGIFHandler | |
38 | //----------------------------------------------------------------------------- | |
39 | ||
9ab6ee85 GRG |
40 | #if wxUSE_STREAMS |
41 | ||
700ec454 | 42 | bool wxGIFHandler::LoadFile( wxImage *image, wxInputStream& stream, bool verbose, int WXUNUSED(index) ) |
b59bf2db | 43 | { |
464122b6 | 44 | wxGIFDecoder *decod; |
e08e239b | 45 | int error; |
464122b6 | 46 | bool ok; |
b59bf2db | 47 | |
464122b6 | 48 | decod = new wxGIFDecoder(&stream, TRUE); |
8a68d8b6 | 49 | |
e4b8154a | 50 | if ((error = decod->ReadGIF()) != wxGIF_OK) |
995612e2 | 51 | { |
e08e239b GRG |
52 | if (verbose) |
53 | { | |
54 | switch (error) | |
55 | { | |
e4b8154a GRG |
56 | case wxGIF_INVFORMAT: wxLogError(_("wxGIFHandler: error in GIF image format")); break; |
57 | case wxGIF_MEMERR: wxLogError(_("wxGIFHandler: couldn't allocate enough memory")); break; | |
58 | default: wxLogError(_("wxGIFHandler: unknown error !!!")); | |
e08e239b GRG |
59 | } |
60 | } | |
b59bf2db JS |
61 | delete decod; |
62 | return FALSE; | |
63 | } | |
b59bf2db | 64 | |
464122b6 JS |
65 | image->Destroy(); |
66 | ok = decod->ConvertToImage(image); | |
b59bf2db | 67 | |
464122b6 JS |
68 | delete decod; |
69 | return ok; | |
b59bf2db JS |
70 | } |
71 | ||
74e3313b | 72 | bool wxGIFHandler::SaveFile( wxImage * WXUNUSED(image), |
deb2fec0 | 73 | wxOutputStream& WXUNUSED(stream), bool verbose ) |
b59bf2db | 74 | { |
8a68d8b6 | 75 | if (verbose) |
223d09f6 | 76 | wxLogDebug(wxT("wxGIFHandler is read-only!!")); |
8a68d8b6 | 77 | |
b59bf2db JS |
78 | return FALSE; |
79 | } | |
80 | ||
995612e2 | 81 | bool wxGIFHandler::DoCanRead( wxInputStream& stream ) |
0828c087 | 82 | { |
bd2fdefe GRG |
83 | wxGIFDecoder *decod; |
84 | bool ok; | |
85 | ||
86 | decod = new wxGIFDecoder(&stream); | |
87 | ok = decod->CanRead(); | |
88 | ||
89 | delete decod; | |
90 | return ok; | |
0828c087 VS |
91 | } |
92 | ||
9ab6ee85 GRG |
93 | #endif // wxUSE_STREAMS |
94 | ||
95 | #endif // wxUSE_GIF |