added wxXPMDecoder

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@9916 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Václav Slavík
2001-04-28 23:30:24 +00:00
parent 9d8bdf2dbc
commit 424f5e2700
3 changed files with 792 additions and 13 deletions
+48
View File
@@ -0,0 +1,48 @@
/////////////////////////////////////////////////////////////////////////////
// Name: xpmdecod.h
// Purpose: wxXPMDecoder, XPM reader for wxImage and wxBitmap
// Author: Vaclav Slavik
// CVS-ID: $Id$
// Copyright: (c) 2001 Vaclav Slavik
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifndef _WX_XPMDECOD_H_
#define _WX_XPMDECOD_H_
#ifdef __GNUG__
#pragma interface "xpmdecod.h"
#endif
#include "wx/setup.h"
#if wxUSE_IMAGE && wxUSE_XPM
class WXDLLEXPORT wxImage;
class WXDLLEXPORT wxInputStream;
// --------------------------------------------------------------------------
// wxXPMDecoder class
// --------------------------------------------------------------------------
class WXDLLEXPORT wxXPMDecoder
{
public:
// constructor, destructor, etc.
wxXPMDecoder() {}
~wxXPMDecoder() {}
#if wxUSE_STREAMS
// Is the stream XPM file?
bool CanRead(wxInputStream& stream);
// Read XPM file from the stream, parse it and create image from it
wxImage ReadFile(wxInputStream& stream);
#endif
// Read directly from XPM data (as passed to wxBitmap ctor):
wxImage ReadData(const char **xpm_data);
};
#endif // wxUSE_IMAGE && wxUSE_XPM
#endif // _WX_GIFDECOD_H_
+13 -13
View File
@@ -1,7 +1,7 @@
/////////////////////////////////////////////////////////////////////////////
// Name: imagxpm.cpp
// Purpose: wxXPMHandler
// Author: Vaclav Slavik
// Author: Vaclav Slavik, Robert Roebling
// RCS-ID: $Id$
// Copyright: (c) 2001 Vaclav Slavik
// Licence: wxWindows licence
@@ -84,7 +84,7 @@ license is as follows:
#include "wx/log.h"
#include "wx/intl.h"
#include "wx/utils.h"
#include "wx/xpmdecod.h"
IMPLEMENT_DYNAMIC_CLASS(wxXPMHandler,wxImageHandler)
@@ -94,13 +94,17 @@ IMPLEMENT_DYNAMIC_CLASS(wxXPMHandler,wxImageHandler)
#if wxUSE_STREAMS
bool wxXPMHandler::LoadFile(wxImage *WXUNUSED(image),
wxInputStream& WXUNUSED(stream),
bool wxXPMHandler::LoadFile(wxImage *image,
wxInputStream& stream,
bool verbose, int WXUNUSED(index))
{
if (verbose)
wxLogDebug(_("XPM: the handler is write-only!"));
return FALSE;
wxXPMDecoder decoder;
wxImage img = decoder.ReadFile(stream);
if ( !img.Ok() )
return FALSE;
*image = img;
return TRUE;
}
bool wxXPMHandler::SaveFile(wxImage * image,
@@ -208,12 +212,8 @@ bool wxXPMHandler::SaveFile(wxImage * image,
bool wxXPMHandler::DoCanRead(wxInputStream& stream)
{
unsigned char buf[9];
stream.Read(buf, 9);
stream.SeekI(-9, wxFromCurrent);
return (memcmp(buf, "/* XPM */", 9) == 0);
wxXPMDecoder decoder;
return decoder.CanRead(stream);
}
#endif // wxUSE_STREAMS
File diff suppressed because it is too large Load Diff