#endif
//-----------------------------------------------------------------------------
-// wxImage
+// global data
+//-----------------------------------------------------------------------------
+
+wxList wxImage::sm_handlers;
+wxImage wxNullImage;
+
+//-----------------------------------------------------------------------------
+// wxImageRefData
//-----------------------------------------------------------------------------
class wxImageRefData: public wxObjectRefData
free( m_alpha );
}
-wxList wxImage::sm_handlers;
-
-wxImage wxNullImage;
+//-----------------------------------------------------------------------------
+// wxImage
//-----------------------------------------------------------------------------
#define M_IMGDATA static_cast<wxImageRefData*>(m_refData)
IMPLEMENT_DYNAMIC_CLASS(wxImage, wxObject)
-wxImage::wxImage( int width, int height, bool clear )
-{
- Create( width, height, clear );
-}
-
-wxImage::wxImage( int width, int height, unsigned char* data, bool static_data )
-{
- Create( width, height, data, static_data );
-}
-
-wxImage::wxImage( int width, int height, unsigned char* data, unsigned char* alpha, bool static_data )
-{
- Create( width, height, data, alpha, static_data );
-}
-
-wxImage::wxImage( const wxString& name, wxBitmapType type, int index )
-{
- LoadFile( name, type, index );
-}
-
-wxImage::wxImage( const wxString& name, const wxString& mimetype, int index )
-{
- LoadFile( name, mimetype, index );
-}
-
-#if wxUSE_STREAMS
-wxImage::wxImage( wxInputStream& stream, wxBitmapType type, int index )
-{
- LoadFile( stream, type, index );
-}
-
-wxImage::wxImage( wxInputStream& stream, const wxString& mimetype, int index )
-{
- LoadFile( stream, mimetype, index );
-}
-#endif // wxUSE_STREAMS
-
-wxImage::wxImage(const char* const* xpmData)
-{
- Create(xpmData);
-}
-
bool wxImage::Create(const char* const* xpmData)
{
#if wxUSE_XPM
IMPLEMENT_ABSTRACT_CLASS(wxImageHandler,wxObject)
#if wxUSE_STREAMS
-bool wxImageHandler::LoadFile( wxImage *WXUNUSED(image), wxInputStream& WXUNUSED(stream), bool WXUNUSED(verbose), int WXUNUSED(index) )
+int wxImageHandler::GetImageCount( wxInputStream& stream )
{
- return false;
-}
+ // NOTE: this code is the same of wxAnimationDecoder::CanRead and
+ // wxImageHandler::CallDoCanRead
-bool wxImageHandler::SaveFile( wxImage *WXUNUSED(image), wxOutputStream& WXUNUSED(stream), bool WXUNUSED(verbose) )
-{
- return false;
-}
+ if ( !stream.IsSeekable() )
+ return false; // can't test unseekable stream
-int wxImageHandler::GetImageCount( wxInputStream& WXUNUSED(stream) )
-{
- return 1;
+ wxFileOffset posOld = stream.TellI();
+ int n = DoGetImageCount(stream);
+
+ // restore the old position to be able to test other formats and so on
+ if ( stream.SeekI(posOld) == wxInvalidOffset )
+ {
+ wxLogDebug(_T("Failed to rewind the stream in wxImageHandler!"));
+
+ // reading would fail anyhow as we're not at the right position
+ return false;
+ }
+
+ return n;
}
bool wxImageHandler::CanRead( const wxString& name )
bool wxImageHandler::CallDoCanRead(wxInputStream& stream)
{
- wxFileOffset posOld = stream.TellI();
- if ( posOld == wxInvalidOffset )
- {
- // can't test unseekable stream
- return false;
- }
+ // NOTE: this code is the same of wxAnimationDecoder::CanRead and
+ // wxImageHandler::GetImageCount
+
+ if ( !stream.IsSeekable() )
+ return false; // can't test unseekable stream
+ wxFileOffset posOld = stream.TellI();
bool ok = DoCanRead(stream);
// restore the old position to be able to test other formats and so on