]> git.saurik.com Git - wxWidgets.git/blobdiff - src/msw/bitmap.cpp
rebaked everything, fixes problems with OpenGL samples makefiles
[wxWidgets.git] / src / msw / bitmap.cpp
index b942d9d61f0cf31f15ea648037fdd786168ee62d..d06251a59966fc50963c7ef6b284b5614de65df2 100644 (file)
@@ -374,6 +374,8 @@ bool wxBitmap::CopyFromIconOrCursor(const wxGDIImage& icon,
     return true;
 #else // __WXMICROWIN__ || __WXWINCE__
     wxUnusedVar(icon);
+    wxUnusedVar(transp);
+
     return false;
 #endif // !__WXWINCE__/__WXWINCE__
 }
@@ -533,9 +535,14 @@ bool wxBitmap::Create(int width, int height, int depth)
 
 bool wxBitmap::Create(int width, int height, const wxDC& dc)
 {
-    wxCHECK_MSG( dc.Ok(), false, _T("invalid HDC in wxBitmap::Create()") );
+    wxCHECK_MSG( dc.IsOk(), false, _T("invalid HDC in wxBitmap::Create()") );
 
-    return DoCreate(width, height, -1, dc.GetHDC());
+    const wxMSWDCImpl *impl = wxDynamicCast( dc.GetImpl(), wxMSWDCImpl );
+    
+    if (impl)
+        return DoCreate(width, height, -1, impl->GetHDC());
+    else
+        return false;
 }
 
 bool wxBitmap::DoCreate(int w, int h, int d, WXHDC hdc)
@@ -803,10 +810,15 @@ bool wxBitmap::CreateFromImage(const wxImage& image, int depth)
 
 bool wxBitmap::CreateFromImage(const wxImage& image, const wxDC& dc)
 {
-    wxCHECK_MSG( dc.Ok(), false,
+    wxCHECK_MSG( dc.IsOk(), false,
                     _T("invalid HDC in wxBitmap::CreateFromImage()") );
 
-    return CreateFromImage(image, -1, dc.GetHDC());
+    const wxMSWDCImpl *impl = wxDynamicCast( dc.GetImpl(), wxMSWDCImpl );
+    
+    if (impl)
+        return CreateFromImage(image, -1, impl->GetHDC());
+    else
+        return false;
 }
 
 #if wxUSE_WXDIB
@@ -1087,8 +1099,14 @@ bool wxBitmap::SaveFile(const wxString& filename,
 // ----------------------------------------------------------------------------
 // sub bitmap extraction
 // ----------------------------------------------------------------------------
+wxBitmap wxBitmap::GetSubBitmap( const wxRect& rect ) const
+{
+        MemoryHDC dcSrc;
+        SelectInHDC selectSrc(dcSrc, GetHbitmap());
+        return GetSubBitmapOfHDC( rect, (WXHDC)dcSrc );
+}
 
-wxBitmap wxBitmap::GetSubBitmap( const wxRect& rect) const
+wxBitmap wxBitmap::GetSubBitmapOfHDC( const wxRect& rect, WXHDC hdc ) const
 {
     wxCHECK_MSG( Ok() &&
                  (rect.x >= 0) && (rect.y >= 0) &&
@@ -1109,16 +1127,15 @@ wxBitmap wxBitmap::GetSubBitmap( const wxRect& rect) const
               dcDst;
 
     {
-        SelectInHDC selectSrc(dcSrc, GetHbitmap()),
-                    selectDst(dcDst, GetHbitmapOf(ret));
-
-        if ( !selectSrc || !selectDst )
+        SelectInHDC selectDst(dcDst, GetHbitmapOf(ret));
+               
+        if ( !selectDst )
         {
-            wxLogLastError(_T("SelectObjct(hBitmap)"));
+            wxLogLastError(_T("SelectObject(destBitmap)"));
         }
 
         if ( !::BitBlt(dcDst, 0, 0, rect.width, rect.height,
-                       dcSrc, rect.x, rect.y, SRCCOPY) )
+                       (HDC)hdc, rect.x, rect.y, SRCCOPY) )
         {
             wxLogLastError(_T("BitBlt"));
         }