]>
Commit | Line | Data |
---|---|---|
1 | ///////////////////////////////////////////////////////////////////////////// | |
2 | // Name: imaggif.cpp | |
3 | // Purpose: wxGIFHandler | |
4 | // Author: Vaclav Slavik & Guillermo Rodriguez Garcia | |
5 | // RCS-ID: $Id$ | |
6 | // Copyright: (c) 1999 Vaclav Slavik & Guillermo Rodriguez Garcia | |
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 | #if wxUSE_GIF | |
27 | ||
28 | #include "wx/image.h" | |
29 | #include "wx/gifdecod.h" | |
30 | #include "wx/wfstream.h" | |
31 | #include "wx/log.h" | |
32 | #include "wx/intl.h" | |
33 | ||
34 | #if !USE_SHARED_LIBRARIES | |
35 | IMPLEMENT_DYNAMIC_CLASS(wxGIFHandler,wxImageHandler) | |
36 | #endif | |
37 | ||
38 | //----------------------------------------------------------------------------- | |
39 | // wxGIFHandler | |
40 | //----------------------------------------------------------------------------- | |
41 | ||
42 | #if wxUSE_STREAMS | |
43 | ||
44 | bool wxGIFHandler::LoadFile( wxImage *image, wxInputStream& stream, bool verbose, int WXUNUSED(index) ) | |
45 | { | |
46 | wxGIFDecoder *decod; | |
47 | int error; | |
48 | bool ok; | |
49 | ||
50 | decod = new wxGIFDecoder(&stream, TRUE); | |
51 | ||
52 | if ((error = decod->ReadGIF()) != wxGIF_OK) | |
53 | { | |
54 | if (verbose) | |
55 | { | |
56 | switch (error) | |
57 | { | |
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 !!!")); | |
61 | } | |
62 | } | |
63 | delete decod; | |
64 | return FALSE; | |
65 | } | |
66 | ||
67 | image->Destroy(); | |
68 | ok = decod->ConvertToImage(image); | |
69 | ||
70 | delete decod; | |
71 | return ok; | |
72 | } | |
73 | ||
74 | bool wxGIFHandler::SaveFile( wxImage * WXUNUSED(image), | |
75 | wxOutputStream& WXUNUSED(stream), bool verbose ) | |
76 | { | |
77 | if (verbose) | |
78 | wxLogDebug(wxT("wxGIFHandler is read-only!!")); | |
79 | ||
80 | return FALSE; | |
81 | } | |
82 | ||
83 | bool wxGIFHandler::DoCanRead( wxInputStream& stream ) | |
84 | { | |
85 | wxGIFDecoder *decod; | |
86 | bool ok; | |
87 | ||
88 | decod = new wxGIFDecoder(&stream); | |
89 | ok = decod->CanRead(); | |
90 | ||
91 | delete decod; | |
92 | return ok; | |
93 | } | |
94 | ||
95 | #endif // wxUSE_STREAMS | |
96 | ||
97 | #endif // wxUSE_GIF |