]> git.saurik.com Git - wxWidgets.git/blame - src/common/imaggif.cpp
search progress bar has smooth gauge under win95 now
[wxWidgets.git] / src / common / imaggif.cpp
CommitLineData
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
8f493002
VS
10#ifdef __GNUG__
11#pragma implementation "imaggif.h"
12#endif
b59bf2db
JS
13
14// For compilers that support precompilation, includes "wx.h".
3096bd2f 15#include "wx/wxprec.h"
b59bf2db
JS
16
17#ifdef __BORLANDC__
464122b6 18# pragma hdrstop
b59bf2db
JS
19#endif
20
ce4169a4 21#ifndef WX_PRECOMP
464122b6 22# include "wx/defs.h"
ce4169a4 23#endif
b59bf2db 24
9ab6ee85 25#if wxUSE_GIF
8a68d8b6 26
8f493002 27#include "wx/imaggif.h"
464122b6 28#include "wx/gifdecod.h"
ce4169a4 29#include "wx/wfstream.h"
ce4169a4 30#include "wx/log.h"
f6b77239 31#include "wx/intl.h"
b59bf2db 32
ce4169a4
RR
33IMPLEMENT_DYNAMIC_CLASS(wxGIFHandler,wxImageHandler)
34
b59bf2db
JS
35//-----------------------------------------------------------------------------
36// wxGIFHandler
37//-----------------------------------------------------------------------------
38
9ab6ee85
GRG
39#if wxUSE_STREAMS
40
700ec454 41bool wxGIFHandler::LoadFile( wxImage *image, wxInputStream& stream, bool verbose, int WXUNUSED(index) )
b59bf2db 42{
464122b6 43 wxGIFDecoder *decod;
e08e239b 44 int error;
464122b6 45 bool ok;
b59bf2db 46
464122b6 47 decod = new wxGIFDecoder(&stream, TRUE);
8a68d8b6 48
e4b8154a 49 if ((error = decod->ReadGIF()) != wxGIF_OK)
995612e2 50 {
e08e239b
GRG
51 if (verbose)
52 {
53 switch (error)
54 {
e4b8154a
GRG
55 case wxGIF_INVFORMAT: wxLogError(_("wxGIFHandler: error in GIF image format")); break;
56 case wxGIF_MEMERR: wxLogError(_("wxGIFHandler: couldn't allocate enough memory")); break;
57 default: wxLogError(_("wxGIFHandler: unknown error !!!"));
e08e239b
GRG
58 }
59 }
b59bf2db
JS
60 delete decod;
61 return FALSE;
62 }
b59bf2db 63
464122b6
JS
64 image->Destroy();
65 ok = decod->ConvertToImage(image);
b59bf2db 66
464122b6
JS
67 delete decod;
68 return ok;
b59bf2db
JS
69}
70
74e3313b 71bool wxGIFHandler::SaveFile( wxImage * WXUNUSED(image),
deb2fec0 72 wxOutputStream& WXUNUSED(stream), bool verbose )
b59bf2db 73{
8a68d8b6 74 if (verbose)
223d09f6 75 wxLogDebug(wxT("wxGIFHandler is read-only!!"));
8a68d8b6 76
b59bf2db
JS
77 return FALSE;
78}
79
995612e2 80bool wxGIFHandler::DoCanRead( wxInputStream& stream )
0828c087 81{
bd2fdefe
GRG
82 wxGIFDecoder *decod;
83 bool ok;
84
85 decod = new wxGIFDecoder(&stream);
86 ok = decod->CanRead();
87
88 delete decod;
89 return ok;
0828c087
VS
90}
91
9ab6ee85
GRG
92#endif // wxUSE_STREAMS
93
94#endif // wxUSE_GIF