]> git.saurik.com Git - wxWidgets.git/blobdiff - src/mac/dataobj.cpp
nativedlg and some interface changes.
[wxWidgets.git] / src / mac / dataobj.cpp
index ff91434d912be055a43d08a95467afe8551bbd59..c2f75326c02918ad7264778f7e9718e995c5611e 100644 (file)
@@ -33,6 +33,7 @@
 #include "wx/dataobj.h"
 #include "wx/mstream.h"
 #include "wx/image.h"
+#include "wx/mac/private.h"
 
 // ----------------------------------------------------------------------------
 // functions
@@ -280,7 +281,7 @@ bool wxBitmapDataObject::SetData(
         return FALSE;
     }
 
-    m_bitmap = vImage.ConvertToBitmap();
+    m_bitmap = wxBitmap( vImage ) ; 
     return m_bitmap.Ok();
 }
 
@@ -289,17 +290,18 @@ void wxBitmapDataObject::DoConvertToPng()
     if (!m_bitmap.Ok())
         return;
 
-    wxImage                         vImage(m_bitmap);
-    wxPNGHandler                    vHandler;
-    wxCountingOutputStream          vCount;
+    wxCHECK_RET( wxImage::FindHandler(wxBITMAP_TYPE_PNG) != NULL,
+                 wxT("You must call wxImage::AddHandler(new wxPNGHandler); to be able to use clipboard with bitmaps!") );
 
-    vHandler.SaveFile(&vImage, vCount);
+    wxImage image = m_bitmap.ConvertToImage();
 
-    m_pngSize = vCount.GetSize() + 100; // sometimes the size seems to vary ???
-    m_pngData = malloc(m_pngSize);
+    wxCountingOutputStream count;
+    image.SaveFile(count, wxBITMAP_TYPE_PNG);
 
-    wxMemoryOutputStream            vMstream((char*) m_pngData, m_pngSize);
+    m_pngSize = count.GetSize() + 100; // sometimes the size seems to vary ???
+    m_pngData = malloc(m_pngSize);
 
-    vHandler.SaveFile(&vImage, vMstream );
+    wxMemoryOutputStream mstream((char*) m_pngData, m_pngSize);
+    image.SaveFile(mstream, wxBITMAP_TYPE_PNG);
 }