]> git.saurik.com Git - wxWidgets.git/blame - src/common/imaggif.cpp
Several changes and updates
[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
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".
16#include <wx/wxprec.h>
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"
b59bf2db 32
8a68d8b6 33#if !USE_SHARED_LIBRARIES
ce4169a4 34IMPLEMENT_DYNAMIC_CLASS(wxGIFHandler,wxImageHandler)
8a68d8b6 35#endif
ce4169a4 36
b59bf2db
JS
37//-----------------------------------------------------------------------------
38// wxGIFHandler
39//-----------------------------------------------------------------------------
40
9ab6ee85
GRG
41#if wxUSE_STREAMS
42
8a68d8b6 43bool wxGIFHandler::LoadFile( wxImage *image, wxInputStream& stream, bool verbose )
b59bf2db 44{
464122b6 45 wxGIFDecoder *decod;
e08e239b 46 int error;
464122b6 47 bool ok;
b59bf2db 48
464122b6 49 decod = new wxGIFDecoder(&stream, TRUE);
8a68d8b6 50
e08e239b
GRG
51 if ((error = decod->ReadGIF()) != E_OK)
52 {
53 if (verbose)
54 {
55 switch (error)
56 {
57 case E_FORMATO: wxLogError(_T("wxGIFHandler: error in image format")); break;
58 case E_MEMORIA: wxLogError(_T("wxGIFHandler: couldn't allocate memory")); break;
59 default: wxLogError(_T("wxGIFHandler: unknown error !!!"));
60 }
61 }
b59bf2db
JS
62 delete decod;
63 return FALSE;
64 }
b59bf2db 65
464122b6
JS
66 image->Destroy();
67 ok = decod->ConvertToImage(image);
b59bf2db 68
464122b6
JS
69 delete decod;
70 return ok;
b59bf2db
JS
71}
72
74e3313b 73bool wxGIFHandler::SaveFile( wxImage * WXUNUSED(image),
deb2fec0 74 wxOutputStream& WXUNUSED(stream), bool verbose )
b59bf2db 75{
8a68d8b6
GRG
76 if (verbose)
77 wxLogDebug(_T("wxGIFHandler is read-only!!"));
78
b59bf2db
JS
79 return FALSE;
80}
81
0828c087
VS
82bool wxGIFHandler::CanRead( wxInputStream& stream )
83{
bd2fdefe
GRG
84 wxGIFDecoder *decod;
85 bool ok;
86
87 decod = new wxGIFDecoder(&stream);
88 ok = decod->CanRead();
89
90 delete decod;
91 return ok;
0828c087
VS
92}
93
9ab6ee85
GRG
94#endif // wxUSE_STREAMS
95
96#endif // wxUSE_GIF