X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/995612e2abc1131458863ed1d3e55206df7c33de..b068c4e8a1f4919360329c345eae36ff95ab5a10:/src/common/image.cpp diff --git a/src/common/image.cpp b/src/common/image.cpp index 5c304f0a9d..05344a678f 100644 --- a/src/common/image.cpp +++ b/src/common/image.cpp @@ -437,8 +437,32 @@ bool wxImage::SaveFile( const wxString& filename, const wxString& mimetype ) return FALSE; } +bool wxImage::CanRead( const wxString &name ) +{ +#if wxUSE_STREAMS + wxFileInputStream stream(name); + return CanRead(stream); +#else + return FALSE; +#endif +} + #if wxUSE_STREAMS +bool wxImage::CanRead( wxInputStream &stream ) +{ + wxList &list=GetHandlers(); + + for ( wxList::Node *node = list.GetFirst(); node; node = node->GetNext() ) + { + wxImageHandler *handler=(wxImageHandler*)node->GetData(); + if (handler->CanRead( stream )) + return TRUE; + } + + return FALSE; +} + bool wxImage::LoadFile( wxInputStream& stream, long type ) { UnRef(); @@ -628,7 +652,7 @@ void wxImage::CleanUpHandlers() //----------------------------------------------------------------------------- #if !USE_SHARED_LIBRARIES -IMPLEMENT_DYNAMIC_CLASS(wxImageHandler,wxObject) +IMPLEMENT_ABSTRACT_CLASS(wxImageHandler,wxObject) #endif #if wxUSE_STREAMS @@ -1238,9 +1262,22 @@ wxImage::wxImage( const wxBitmap &bitmap ) { wxCHECK_RET( bitmap.Ok(), wxT("invalid bitmap") ); - GdkImage *gdk_image = gdk_image_get( bitmap.GetPixmap(), - 0, 0, - bitmap.GetWidth(), bitmap.GetHeight() ); + GdkImage *gdk_image = (GdkImage*) NULL; + if (bitmap.GetPixmap()) + { + gdk_image = gdk_image_get( bitmap.GetPixmap(), + 0, 0, + bitmap.GetWidth(), bitmap.GetHeight() ); + } else + if (bitmap.GetBitmap()) + { + gdk_image = gdk_image_get( bitmap.GetBitmap(), + 0, 0, + bitmap.GetWidth(), bitmap.GetHeight() ); + } else + { + wxFAIL_MSG( wxT("Ill-formed bitmap") ); + } wxCHECK_RET( gdk_image, wxT("couldn't create image") ); @@ -1264,7 +1301,12 @@ wxImage::wxImage( const wxBitmap &bitmap ) SetMaskColour( 16, 16, 16 ); // anything unlikely and dividable } - GdkVisual *visual = gdk_window_get_visual( bitmap.GetPixmap() ); + GdkVisual *visual = (GdkVisual*) NULL; + if (bitmap.GetPixmap()) + visual = gdk_window_get_visual( bitmap.GetPixmap() ); + else + visual = gdk_window_get_visual( bitmap.GetBitmap() ); + if (visual == NULL) visual = gdk_window_get_visual( (GdkWindow*) &gdk_root_parent ); int bpp = visual->depth; if ((bpp == 16) && (visual->red_mask != 0xf800)) bpp = 15; @@ -1277,7 +1319,7 @@ wxImage::wxImage( const wxBitmap &bitmap ) for (int i = 0; i < bitmap.GetWidth(); i++) { wxInt32 pixel = gdk_image_get_pixel( gdk_image, i, j ); - pixel = wxINT32_SWAP_ON_BE( pixel ); + // pixel = wxINT32_SWAP_ON_BE( pixel ); if (bpp <= 8) { data[pos] = cmap->colors[pixel].red >> 8;