]>
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 | |
8a68d8b6 | 34 | #if !USE_SHARED_LIBRARIES |
ce4169a4 | 35 | IMPLEMENT_DYNAMIC_CLASS(wxGIFHandler,wxImageHandler) |
8a68d8b6 | 36 | #endif |
ce4169a4 | 37 | |
b59bf2db JS |
38 | //----------------------------------------------------------------------------- |
39 | // wxGIFHandler | |
40 | //----------------------------------------------------------------------------- | |
41 | ||
9ab6ee85 GRG |
42 | #if wxUSE_STREAMS |
43 | ||
700ec454 | 44 | bool wxGIFHandler::LoadFile( wxImage *image, wxInputStream& stream, bool verbose, int WXUNUSED(index) ) |
b59bf2db | 45 | { |
464122b6 | 46 | wxGIFDecoder *decod; |
e08e239b | 47 | int error; |
464122b6 | 48 | bool ok; |
b59bf2db | 49 | |
464122b6 | 50 | decod = new wxGIFDecoder(&stream, TRUE); |
8a68d8b6 | 51 | |
e4b8154a | 52 | if ((error = decod->ReadGIF()) != wxGIF_OK) |
995612e2 | 53 | { |
e08e239b GRG |
54 | if (verbose) |
55 | { | |
56 | switch (error) | |
57 | { | |
e4b8154a GRG |
58 | case wxGIF_INVFORMAT: wxLogError(_("wxGIFHandler: error in GIF image format")); break; |
59 | case wxGIF_MEMERR: wxLogError(_("wxGIFHandler: couldn't allocate enough memory")); break; | |
60 | default: wxLogError(_("wxGIFHandler: unknown error !!!")); | |
e08e239b GRG |
61 | } |
62 | } | |
b59bf2db JS |
63 | delete decod; |
64 | return FALSE; | |
65 | } | |
b59bf2db | 66 | |
464122b6 JS |
67 | image->Destroy(); |
68 | ok = decod->ConvertToImage(image); | |
b59bf2db | 69 | |
464122b6 JS |
70 | delete decod; |
71 | return ok; | |
b59bf2db JS |
72 | } |
73 | ||
74e3313b | 74 | bool wxGIFHandler::SaveFile( wxImage * WXUNUSED(image), |
deb2fec0 | 75 | wxOutputStream& WXUNUSED(stream), bool verbose ) |
b59bf2db | 76 | { |
8a68d8b6 | 77 | if (verbose) |
223d09f6 | 78 | wxLogDebug(wxT("wxGIFHandler is read-only!!")); |
8a68d8b6 | 79 | |
b59bf2db JS |
80 | return FALSE; |
81 | } | |
82 | ||
995612e2 | 83 | bool wxGIFHandler::DoCanRead( wxInputStream& stream ) |
0828c087 | 84 | { |
bd2fdefe GRG |
85 | wxGIFDecoder *decod; |
86 | bool ok; | |
87 | ||
88 | decod = new wxGIFDecoder(&stream); | |
89 | ok = decod->CanRead(); | |
90 | ||
91 | delete decod; | |
92 | return ok; | |
0828c087 VS |
93 | } |
94 | ||
9ab6ee85 GRG |
95 | #endif // wxUSE_STREAMS |
96 | ||
97 | #endif // wxUSE_GIF |