+
+// ----------------------------------------------------------------------------
+// raw bitmap access support
+// ----------------------------------------------------------------------------
+
+void *wxBitmap::GetRawData(wxPixelDataBase& data, int bpp)
+{
+    if ( !Ok() )
+    {
+        // no bitmap, no data (raw or otherwise)
+        return NULL;
+    }
+
+   if ( M_BITMAPDATA->m_bitmapType != kMacBitmapTypeGrafWorld )
+   {
+       wxFAIL_MSG( _T("GetRawData() only supported for GWorlds") );
+
+       return NULL;
+   }
+
+   GWorldPtr gworld = MAC_WXHBITMAP(M_BITMAPDATA->m_hBitmap);
+   PixMapHandle hPixMap = GetGWorldPixMap(gworld);
+   wxCHECK_MSG( hPixMap && *hPixMap, NULL,
+                    _T("GetRawData(): failed to get PixMap from GWorld?") );
+
+   wxCHECK_MSG( (*hPixMap)->pixelSize == bpp, NULL,
+                    _T("GetRawData(): pixel format mismatch") );
+
+   if ( !LockPixels(hPixMap) )
+   {
+       wxFAIL_MSG( _T("failed to lock PixMap in GetRawData()") );
+
+       return NULL;
+   }
+
+   data.m_width = GetWidth();
+   data.m_height = GetHeight();
+   data.m_stride = (*hPixMap)->rowBytes & 0x7fff;
+
+   M_BITMAPDATA->m_hasAlpha = false;
+
+   return GetPixBaseAddr(hPixMap);
+}
+
+void wxBitmap::UngetRawData(wxPixelDataBase& dataBase)
+{
+    if ( !Ok() )
+        return;
+
+    if ( M_BITMAPDATA->m_hasAlpha )
+    {
+        wxAlphaPixelData& data = (wxAlphaPixelData&)dataBase;
+
+        int w = data.GetWidth(),
+            h = data.GetHeight();
+
+        wxBitmap bmpMask(GetWidth(), GetHeight(), 32);
+        wxAlphaPixelData dataMask(bmpMask, data.GetOrigin(), wxSize(w, h));
+        wxAlphaPixelData::Iterator pMask(dataMask),
+                                   p(data);
+        for ( int y = 0; y < h; y++ )
+        {
+            wxAlphaPixelData::Iterator rowStartMask = pMask,
+                                       rowStart = p;
+
+            for ( int x = 0; x < w; x++ )
+            {
+                const wxAlphaPixelData::Iterator::ChannelType
+                    alpha = p.Alpha();
+
+                pMask.Red() = alpha;
+                pMask.Green() = alpha;
+                pMask.Blue() = alpha;
+
+                ++p;
+                ++pMask;
+            }
+
+            p = rowStart;
+            p.OffsetY(data, 1);
+
+            pMask = rowStartMask;
+            pMask.OffsetY(dataMask, 1);
+        }
+
+        SetMask(new wxMask(bmpMask));
+    }
+
+    GWorldPtr gworld = MAC_WXHBITMAP(M_BITMAPDATA->m_hBitmap);
+    PixMapHandle hPixMap = GetGWorldPixMap(gworld);
+    if ( hPixMap )
+    {
+        UnlockPixels(hPixMap);
+    }
+}
+
+void wxBitmap::UseAlpha()
+{
+    // remember that we are using alpha channel, we'll need to create a proper
+    // mask in UngetRawData()
+    M_BITMAPDATA->m_hasAlpha = true;
+}
+