some ifdef's - now it might compile without wxUSE_IMAGE although not tested
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@9862 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -90,9 +90,12 @@ public:
|
|||||||
|
|
||||||
// If depth is omitted, will create a bitmap compatible with the display
|
// If depth is omitted, will create a bitmap compatible with the display
|
||||||
wxBitmap(int width, int height, int depth = -1);
|
wxBitmap(int width, int height, int depth = -1);
|
||||||
|
|
||||||
|
#if wxUSE_IMAGE
|
||||||
// Convert from wxImage:
|
// Convert from wxImage:
|
||||||
wxBitmap(const wxImage& image, int depth = -1) { (void)CreateFromImage(image, depth); }
|
wxBitmap(const wxImage& image, int depth = -1)
|
||||||
|
{ (void)CreateFromImage(image, depth); }
|
||||||
|
#endif // wxUSE_IMAGE
|
||||||
|
|
||||||
// we must have this, otherwise icons are silently copied into bitmaps using
|
// we must have this, otherwise icons are silently copied into bitmaps using
|
||||||
// the copy ctor but the resulting bitmap is invalid!
|
// the copy ctor but the resulting bitmap is invalid!
|
||||||
@@ -121,11 +124,13 @@ public:
|
|||||||
|
|
||||||
virtual ~wxBitmap();
|
virtual ~wxBitmap();
|
||||||
|
|
||||||
|
#if wxUSE_IMAGE
|
||||||
wxImage ConvertToImage() const;
|
wxImage ConvertToImage() const;
|
||||||
|
#endif // wxUSE_IMAGE
|
||||||
|
|
||||||
// get the given part of bitmap
|
// get the given part of bitmap
|
||||||
wxBitmap GetSubBitmap( const wxRect& rect ) const;
|
wxBitmap GetSubBitmap( const wxRect& rect ) const;
|
||||||
|
|
||||||
// copies the contents and mask of the given (colour) icon to the bitmap
|
// copies the contents and mask of the given (colour) icon to the bitmap
|
||||||
bool CopyFromIcon(const wxIcon& icon);
|
bool CopyFromIcon(const wxIcon& icon);
|
||||||
|
|
||||||
@@ -191,9 +196,11 @@ protected:
|
|||||||
|
|
||||||
// creates the bitmap from XPM data, supposed to be called from ctor
|
// creates the bitmap from XPM data, supposed to be called from ctor
|
||||||
bool CreateFromXpm(const char **bits);
|
bool CreateFromXpm(const char **bits);
|
||||||
|
|
||||||
|
#if wxUSE_IMAGE
|
||||||
// creates the bitmap from wxImage, supposed to be called from ctor
|
// creates the bitmap from wxImage, supposed to be called from ctor
|
||||||
bool CreateFromImage(const wxImage& image, int depth);
|
bool CreateFromImage(const wxImage& image, int depth);
|
||||||
|
#endif // wxUSE_IMAGE
|
||||||
|
|
||||||
private:
|
private:
|
||||||
#ifdef __WIN32__
|
#ifdef __WIN32__
|
||||||
|
@@ -350,6 +350,12 @@ bool wxBitmap::Create(int w, int h, int d)
|
|||||||
return Ok();
|
return Ok();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
// wxImage to/from conversions
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
#if wxUSE_IMAGE
|
||||||
|
|
||||||
bool wxBitmap::CreateFromImage( const wxImage& image, int depth )
|
bool wxBitmap::CreateFromImage( const wxImage& image, int depth )
|
||||||
{
|
{
|
||||||
wxCHECK_MSG( image.Ok(), FALSE, wxT("invalid image") )
|
wxCHECK_MSG( image.Ok(), FALSE, wxT("invalid image") )
|
||||||
@@ -570,7 +576,7 @@ bool wxBitmap::CreateFromImage( const wxImage& image, int depth )
|
|||||||
// check the wxBitmap object
|
// check the wxBitmap object
|
||||||
GetBitmapData()->SetOk();
|
GetBitmapData()->SetOk();
|
||||||
#endif // WXWIN_COMPATIBILITY_2
|
#endif // WXWIN_COMPATIBILITY_2
|
||||||
|
|
||||||
if (wxTheBitmapList) wxTheBitmapList->AddBitmap(this);
|
if (wxTheBitmapList) wxTheBitmapList->AddBitmap(this);
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
@@ -579,7 +585,7 @@ bool wxBitmap::CreateFromImage( const wxImage& image, int depth )
|
|||||||
wxImage wxBitmap::ConvertToImage() const
|
wxImage wxBitmap::ConvertToImage() const
|
||||||
{
|
{
|
||||||
wxImage image;
|
wxImage image;
|
||||||
|
|
||||||
wxCHECK_MSG( Ok(), wxNullImage, wxT("invalid bitmap") );
|
wxCHECK_MSG( Ok(), wxNullImage, wxT("invalid bitmap") );
|
||||||
|
|
||||||
// create an wxImage object
|
// create an wxImage object
|
||||||
@@ -704,6 +710,8 @@ wxImage wxBitmap::ConvertToImage() const
|
|||||||
return image;
|
return image;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endif // wxUSE_IMAGE
|
||||||
|
|
||||||
bool wxBitmap::LoadFile(const wxString& filename, long type)
|
bool wxBitmap::LoadFile(const wxString& filename, long type)
|
||||||
{
|
{
|
||||||
UnRef();
|
UnRef();
|
||||||
@@ -716,16 +724,20 @@ bool wxBitmap::LoadFile(const wxString& filename, long type)
|
|||||||
|
|
||||||
return handler->LoadFile(this, filename, type, -1, -1);
|
return handler->LoadFile(this, filename, type, -1, -1);
|
||||||
}
|
}
|
||||||
|
#if wxUSE_IMAGE
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
wxImage image;
|
wxImage image;
|
||||||
if ( !image.LoadFile( filename, type ) || !image.Ok() )
|
if ( image.LoadFile( filename, type ) && image.Ok() )
|
||||||
return FALSE;
|
{
|
||||||
|
*this = image.ConvertToBitmap();
|
||||||
|
|
||||||
*this = image.ConvertToBitmap();
|
return TRUE;
|
||||||
|
}
|
||||||
return TRUE;
|
|
||||||
}
|
}
|
||||||
|
#endif // wxUSE_IMAGE
|
||||||
|
|
||||||
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool wxBitmap::Create(void *data, long type, int width, int height, int depth)
|
bool wxBitmap::Create(void *data, long type, int width, int height, int depth)
|
||||||
@@ -754,15 +766,19 @@ bool wxBitmap::SaveFile(const wxString& filename, int type, const wxPalette *pal
|
|||||||
{
|
{
|
||||||
return handler->SaveFile(this, filename, type, palette);
|
return handler->SaveFile(this, filename, type, palette);
|
||||||
}
|
}
|
||||||
|
#if wxUSE_IMAGE
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// FIXME what about palette? shouldn't we use it?
|
// FIXME what about palette? shouldn't we use it?
|
||||||
wxImage image( *this );
|
wxImage image( *this );
|
||||||
if (!image.Ok())
|
if ( image.Ok() )
|
||||||
return FALSE;
|
{
|
||||||
|
return image.SaveFile(filename, type);
|
||||||
return image.SaveFile( filename, type );
|
}
|
||||||
}
|
}
|
||||||
|
#endif // wxUSE_IMAGE
|
||||||
|
|
||||||
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
|
Reference in New Issue
Block a user