+ ::SelectObject(hMemDC, hOldBitmap);
+ ::DeleteDC(hMemDC);
+
+#if wxUSE_PALETTE
+ // Copy the palette from the source image
+ if (GetPalette())
+ image.SetPalette(* GetPalette());
+#endif // wxUSE_PALETTE
+
+ return image;
+}
+
+#endif // __WXMICROWIN__
+
+// ----------------------------------------------------------------------------
+// wxImage to/from conversions
+// ----------------------------------------------------------------------------
+
+bool wxBitmap::CreateFromImage(const wxImage& image, int depth)
+{
+ return CreateFromImage(image, depth, 0);
+}
+
+bool wxBitmap::CreateFromImage(const wxImage& image, const wxDC& dc)
+{
+ wxCHECK_MSG( dc.IsOk(), false,
+ wxT("invalid HDC in wxBitmap::CreateFromImage()") );
+
+ const wxMSWDCImpl *impl = wxDynamicCast( dc.GetImpl(), wxMSWDCImpl );
+
+ if (impl)
+ return CreateFromImage(image, -1, impl->GetHDC());
+ else
+ return false;
+}
+
+#if wxUSE_WXDIB
+
+bool wxBitmap::CreateFromImage(const wxImage& image, int depth, WXHDC hdc)
+{
+ wxCHECK_MSG( image.IsOk(), false, wxT("invalid image") );
+
+ UnRef();
+
+ // first convert the image to DIB
+ const int h = image.GetHeight();
+ const int w = image.GetWidth();
+
+ wxDIB dib(image);
+ if ( !dib.IsOk() )
+ return false;
+
+ const bool hasAlpha = image.HasAlpha();
+
+ if (depth == -1)
+ depth = dib.GetDepth();
+
+ // store the bitmap parameters
+ wxBitmapRefData * const refData = new wxBitmapRefData;
+ refData->m_width = w;
+ refData->m_height = h;
+ refData->m_hasAlpha = hasAlpha;
+ refData->m_depth = depth;
+
+ m_refData = refData;
+
+
+ // next either store DIB as is or create a DDB from it
+ HBITMAP hbitmap wxDUMMY_INITIALIZE(0);
+
+ // are we going to use DIB?
+ //
+ // NB: DDBs don't support alpha so if we have alpha channel we must use DIB
+ if ( hasAlpha || wxShouldCreateDIB(w, h, depth, hdc) )