*maskdest++ = 0xFF - *masksource++ ;
                         masksource++ ;
                         masksource++ ;
+                        masksource++ ;
                     }
                     else if ( hasAlpha )
                         *maskdest++ = a ;
             for ( int y = 0 ; y < h ; ++y , sourcemaskstart += maskrowbytes)
             {
                 unsigned char *sourcemask = sourcemaskstart ;
-                for ( int x = 0 ; x < w ; ++x , sourcemask+=3 , destalpha += 4 )
+                for ( int x = 0 ; x < w ; ++x , sourcemask += 4 , destalpha += 4 )
                 {
                     *destalpha = 0xFF - *sourcemask ;
                 }
     if ( M_BITMAPDATA->m_bitmapMask )
     {
         wxMemoryBuffer maskbuf ;
-        int rowBytes = ( destwidth + 3 ) & 0xFFFFFFC ;
+        int rowBytes = ( destwidth * 4 + 3 ) & 0xFFFFFFC ;
         size_t maskbufsize = rowBytes * destheight ;
 
         int sourcelinesize = M_BITMAPDATA->m_bitmapMask->GetBytesPerRow() ;
         unsigned char *destdata = (unsigned char * ) maskbuf.GetWriteBuf( maskbufsize ) ;
         wxASSERT( (source != NULL) && (destdata != NULL) ) ;
 
-        source += rect.x * 3 + rect.y * sourcelinesize ;
+        source += rect.x * 4 + rect.y * sourcelinesize ;
         unsigned char *dest = destdata ;
 
         for (int yy = 0; yy < destheight; ++yy, source += sourcelinesize , dest += destlinesize)
         {
-            for (int xx = 0; xx < destlinesize; xx++ )
-                *(dest+xx) = 0xFF - *(source+xx*3) ;
+            memcpy( dest , source , destlinesize ) ;
         }
 
         maskbuf.UngetWriteBuf( maskbufsize ) ;
 
                 maskp++ ;
                 maskp++ ;
+                maskp++ ;
             }
             else if ( hasAlpha )
                 *alpha++ = a ;
 }
 
 // Construct a mask from a mono bitmap (copies the bitmap).
+
 wxMask::wxMask( const wxMemoryBuffer& data, int width , int height , int bytesPerRow )
 {
     Init() ;
     Rect rect = { 0 , 0 , m_height , m_width } ;
 
     OSStatus err = NewGWorldFromPtr(
-        (GWorldPtr*) &m_maskBitmap , k24RGBPixelFormat , &rect , NULL , NULL , 0 ,
+        (GWorldPtr*) &m_maskBitmap , k32ARGBPixelFormat , &rect , NULL , NULL , 0 ,
         (char*) m_memBuf.GetData() , m_bytesPerRow ) ;
     verify_noerr( err ) ;
 }
 
 // Create a mask from a mono bitmap (copies the bitmap).
+
 bool wxMask::Create(const wxMemoryBuffer& data,int width , int height , int bytesPerRow)
 {
     m_memBuf = data ;
 {
     m_width = bitmap.GetWidth() ;
     m_height = bitmap.GetHeight() ;
-    m_bytesPerRow = ( m_width * 3 + 3 ) & 0xFFFFFFC ;
+    m_bytesPerRow = ( m_width * 4 + 3 ) & 0xFFFFFFC ;
 
     size_t size = m_bytesPerRow * m_height ;
     unsigned char * destdatabase = (unsigned char*) m_memBuf.GetWriteBuf( size ) ;
                 *destdata++ = 0xFF ;
                 *destdata++ = 0xFF ;
                 *destdata++ = 0xFF ;
+                *destdata++ = 0xFF ;
             }
             else
             {
                 *destdata++ = 0x00 ;
                 *destdata++ = 0x00 ;
                 *destdata++ = 0x00 ;
+                *destdata++ = 0x00 ;
             }
         }
     }
 {
     m_width = bitmap.GetWidth() ;
     m_height = bitmap.GetHeight() ;
-    m_bytesPerRow = ( m_width * 3 + 3 ) & 0xFFFFFFC ;
+    m_bytesPerRow = ( m_width * 4 + 3 ) & 0xFFFFFFC ;
 
     size_t size = m_bytesPerRow * m_height ;
     unsigned char * destdatabase = (unsigned char*) m_memBuf.GetWriteBuf( size ) ;
                 *destdata++ = 0xFF ;
                 *destdata++ = 0xFF ;
                 *destdata++ = 0xFF ;
+                *destdata++ = 0xFF ;
             }
             else
             {
                 *destdata++ = 0x00 ;
                 *destdata++ = 0x00 ;
                 *destdata++ = 0x00 ;
+                *destdata++ = 0x00 ;
             }
         }
     }