// wxBitmap creation
// ----------------------------------------------------------------------------
-// this function should be called from all wxBitmap ctors
-void wxBitmap::Init()
-{
- // m_refData = NULL; done in the base class ctor
-}
-
wxGDIImageRefData *wxBitmap::CreateData() const
{
return new wxBitmapRefData;
wxBitmap::wxBitmap(const char bits[], int width, int height, int depth)
{
- Init();
-
#ifndef __WXMICROWIN__
wxBitmapRefData *refData = new wxBitmapRefData;
m_refData = refData;
// Create from XPM data
bool wxBitmap::CreateFromXpm(const char **data)
{
-#if wxUSE_IMAGE && wxUSE_XPM
- Init();
-
+#if wxUSE_IMAGE && wxUSE_XPM && wxUSE_WXDIB
wxCHECK_MSG( data != NULL, false, wxT("invalid bitmap data") )
wxXPMDecoder decoder;
wxBitmap::wxBitmap(int w, int h, int d)
{
- Init();
-
(void)Create(w, h, d);
}
wxBitmap::wxBitmap(int w, int h, const wxDC& dc)
{
- Init();
-
(void)Create(w, h, dc);
}
wxBitmap::wxBitmap(void *data, long type, int width, int height, int depth)
{
- Init();
-
(void)Create(data, type, width, height, depth);
}
wxBitmap::wxBitmap(const wxString& filename, wxBitmapType type)
{
- Init();
-
LoadFile(filename, (int)type);
}
// wxImage to/from conversions
// ----------------------------------------------------------------------------
-#if wxUSE_WXDIB
-
bool wxBitmap::CreateFromImage(const wxImage& image, int depth)
{
return CreateFromImage(image, depth, 0);
return CreateFromImage(image, -1, dc.GetHDC());
}
+#if wxUSE_WXDIB
+
bool wxBitmap::CreateFromImage(const wxImage& image, int depth, WXHDC hdc)
{
wxCHECK_MSG( image.Ok(), false, wxT("invalid image") );
wxDIB dib(image);
if ( !dib.IsOk() )
return false;
- if (depth == -1)
- depth = dib.GetDepth(); // Get depth from image if none specified
+
+ if ( depth == -1 )
+ depth = dib.GetDepth(); // Get depth from image if none specified
// store the bitmap parameters
wxBitmapRefData *refData = new wxBitmapRefData;
return image;
}
-#endif // wxUSE_WXDIB
+#else // !wxUSE_WXDIB
+
+bool
+wxBitmap::CreateFromImage(const wxImage& WXUNUSED(image),
+ int WXUNUSED(depth),
+ WXHDC WXUNUSED(hdc))
+{
+ return false;
+}
+
+wxImage wxBitmap::ConvertToImage() const
+{
+ return wxImage();
+}
+
+#endif // wxUSE_WXDIB/!wxUSE_WXDIB
#endif // wxUSE_IMAGE
return handler->LoadFile(this, filename, type, -1, -1);
}
-#if wxUSE_IMAGE
+#if wxUSE_IMAGE && wxUSE_WXDIB
else // no bitmap handler found
{
wxImage image;
{
return handler->SaveFile(this, filename, type, palette);
}
-#if wxUSE_IMAGE
+#if wxUSE_IMAGE && wxUSE_WXDIB
else // no bitmap handler found
{
// FIXME what about palette? shouldn't we use it?