+bool wxBitmapRefData::Create(CGContextRef context)
+{
+ if ( context != NULL && CGBitmapContextGetData(context) )
+ {
+ m_hBitmap = context;
+ m_bytesPerRow = CGBitmapContextGetBytesPerRow(context);
+ m_width = CGBitmapContextGetWidth(context);
+ m_height = CGBitmapContextGetHeight(context);
+ m_depth = CGBitmapContextGetBitsPerPixel(context) ;
+
+ // our own contexts conform to this, always.
+ wxASSERT( m_depth == 32 );
+
+ // determine content scale
+ CGRect userrect = CGRectMake(0, 0, 10, 10);
+ CGRect devicerect;
+ devicerect = CGContextConvertRectToDeviceSpace(context, userrect);
+ m_scaleFactor = devicerect.size.height / userrect.size.height;
+
+ CGImageAlphaInfo alpha = CGBitmapContextGetAlphaInfo(context);
+
+ if ( alpha == kCGImageAlphaNone || alpha == kCGImageAlphaNoneSkipFirst || alpha == kCGImageAlphaNoneSkipLast )
+ {
+ // no alpha
+ }
+ else
+ {
+ m_hasAlpha = true;
+ }
+ }
+ m_ok = ( m_hBitmap != NULL ) ;
+
+ return m_ok ;
+}
+