]> git.saurik.com Git - wxWidgets.git/blobdiff - src/osx/core/bitmap.cpp
Fix pulsing of bitmaps in focused buttons under Windows 7.
[wxWidgets.git] / src / osx / core / bitmap.cpp
index b503a3fcc1c6ef1cceaa6f6393d4b9a70a256c24..1161256016c7fb4698c8f448c51a1c53984d12aa 100644 (file)
@@ -890,9 +890,9 @@ wxBitmap::wxBitmap(const char bits[], int the_width, int the_height, int no_bits
     {
         if ( no_bits == 1 )
         {
     {
         if ( no_bits == 1 )
         {
-            int linesize = ( the_width / (sizeof(unsigned char) * 8)) ;
-            if ( the_width % (sizeof(unsigned char) * 8) )
-                linesize += sizeof(unsigned char);
+            int linesize = the_width / 8;
+            if ( the_width % 8 )
+                linesize++;
 
             unsigned char* linestart = (unsigned char*) bits ;
             unsigned char* destptr = (unsigned char*) BeginRawAccess() ;
 
             unsigned char* linestart = (unsigned char*) bits ;
             unsigned char* destptr = (unsigned char*) BeginRawAccess() ;
@@ -1649,6 +1649,28 @@ bool wxMask::Create(const wxBitmap& bitmap, const wxColour& colour)
     return true;
 }
 
     return true;
 }
 
+wxBitmap wxMask::GetBitmap() const
+{
+    wxBitmap bitmap(m_width, m_height, 1);
+    unsigned char* dst = static_cast<unsigned char*>(bitmap.BeginRawAccess());
+    const int dst_stride = bitmap.GetBitmapData()->GetBytesPerRow();
+    const unsigned char* src = static_cast<unsigned char*>(GetRawAccess());
+    for (int j = 0; j < m_height; j++, src += m_bytesPerRow, dst += dst_stride)
+    {
+        unsigned char* d = dst;
+        for (int i = 0; i < m_width; i++)
+        {
+            const unsigned char byte = src[i];
+            *d++ = 0xff;
+            *d++ = byte;
+            *d++ = byte;
+            *d++ = byte;
+        }
+    }
+    bitmap.EndRawAccess();
+    return bitmap;
+}
+
 WXHBITMAP wxMask::GetHBITMAP() const
 {
     return m_maskBitmap ;
 WXHBITMAP wxMask::GetHBITMAP() const
 {
     return m_maskBitmap ;
@@ -1693,7 +1715,7 @@ IMPLEMENT_DYNAMIC_CLASS(wxPNGResourceHandler, wxBundleResourceHandler)
 
 class WXDLLEXPORT wxJPEGResourceHandler: public wxBundleResourceHandler
 {
 
 class WXDLLEXPORT wxJPEGResourceHandler: public wxBundleResourceHandler
 {
-    DECLARE_DYNAMIC_CLASS(wxPNGResourceHandler)
+    DECLARE_DYNAMIC_CLASS(wxJPEGResourceHandler)
     
 public:
     inline wxJPEGResourceHandler()
     
 public:
     inline wxJPEGResourceHandler()