+// ----------------------------------------------------------------------------
+// raw bitmap access support
+// ----------------------------------------------------------------------------
+
+bool wxBitmap::GetRawData(wxRawBitmapData *data)
+{
+ wxCHECK_MSG( data, FALSE, _T("NULL pointer in wxBitmap::GetRawData") );
+
+ if ( !Ok() )
+ {
+ // no bitmap, no data (raw or otherwise)
+ return FALSE;
+ }
+
+ // we only support raw access to the DIBs, so check if we have one
+ DIBSECTION ds;
+ if ( !::GetObject(GetHbitmap(), sizeof(ds), &ds) )
+ {
+ return FALSE;
+ }
+
+ // ok, store the relevant info in wxRawBitmapData
+ const LONG h = ds.dsBm.bmHeight;
+
+ data->m_width = ds.dsBm.bmWidth;
+ data->m_height = h;
+ data->m_bypp = ds.dsBm.bmBitsPixel / 8;
+
+ // remember that DIBs are stored in top to bottom order!
+ const LONG bytesPerRow = ds.dsBm.bmWidthBytes;
+ data->m_stride = -bytesPerRow;
+ data->m_pixels = (unsigned char *)ds.dsBm.bmBits;
+ if ( h > 1 )
+ {
+ data->m_pixels += (h - 1)*bytesPerRow;
+ }
+
+ return TRUE;
+}
+