]>
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 | ||
33 | #if !USE_SHARED_LIBRARIES | |
34 | IMPLEMENT_DYNAMIC_CLASS(wxGIFHandler,wxImageHandler) | |
35 | #endif | |
36 | ||
37 | //----------------------------------------------------------------------------- | |
38 | // wxGIFHandler | |
39 | //----------------------------------------------------------------------------- | |
40 | ||
41 | #if wxUSE_STREAMS | |
42 | ||
43 | bool wxGIFHandler::LoadFile( wxImage *image, wxInputStream& stream, bool verbose ) | |
44 | { | |
45 | wxGIFDecoder *decod; | |
46 | int error; | |
47 | bool ok; | |
48 | ||
49 | decod = new wxGIFDecoder(&stream, TRUE); | |
50 | ||
51 | if ((error = decod->ReadGIF()) != E_OK) | |
52 | { | |
53 | if (verbose) | |
54 | { | |
55 | switch (error) | |
56 | { | |
57 | case E_FORMATO: wxLogError(wxT("wxGIFHandler: error in image format")); break; | |
58 | case E_MEMORIA: wxLogError(wxT("wxGIFHandler: couldn't allocate memory")); break; | |
59 | default: wxLogError(wxT("wxGIFHandler: unknown error !!!")); | |
60 | } | |
61 | } | |
62 | delete decod; | |
63 | return FALSE; | |
64 | } | |
65 | ||
66 | image->Destroy(); | |
67 | ok = decod->ConvertToImage(image); | |
68 | ||
69 | delete decod; | |
70 | return ok; | |
71 | } | |
72 | ||
73 | bool wxGIFHandler::SaveFile( wxImage * WXUNUSED(image), | |
74 | wxOutputStream& WXUNUSED(stream), bool verbose ) | |
75 | { | |
76 | if (verbose) | |
77 | wxLogDebug(wxT("wxGIFHandler is read-only!!")); | |
78 | ||
79 | return FALSE; | |
80 | } | |
81 | ||
82 | bool wxGIFHandler::DoCanRead( wxInputStream& stream ) | |
83 | { | |
84 | wxGIFDecoder *decod; | |
85 | bool ok; | |
86 | ||
87 | decod = new wxGIFDecoder(&stream); | |
88 | ok = decod->CanRead(); | |
89 | ||
90 | delete decod; | |
91 | return ok; | |
92 | } | |
93 | ||
94 | #endif // wxUSE_STREAMS | |
95 | ||
96 | #endif // wxUSE_GIF |