+ UnRef();
+
+ wxCHECK_MSG(image.Ok(), false, wxT("invalid image"));
+ wxCHECK_MSG(depth == -1 || depth == 1, false, wxT("invalid bitmap depth"));
+
+ m_refData = new wxBitmapRefData();
+
+ M_BITMAPDATA->m_width = image.GetWidth();
+ M_BITMAPDATA->m_height = image.GetHeight();
+ NSBitmapImageRep *bitmapImage = [[NSBitmapImageRep alloc]
+ initWithBitmapDataPlanes: NULL
+ pixelsWide: image.GetWidth()
+ pixelsHigh: image.GetHeight()
+ bitsPerSample: 8
+ samplesPerPixel: 3
+ hasAlpha: NO
+ isPlanar: NO
+ colorSpaceName: NSCalibratedRGBColorSpace
+ bytesPerRow: 0
+ bitsPerPixel: 0];
+
+ const int numBytes = image.GetWidth()*image.GetHeight()*3;
+ memcpy([bitmapImage bitmapData], image.GetData(), numBytes);
+ // TODO: Alpha and convert to desired depth
+ M_BITMAPDATA->m_depth = 24;
+ M_BITMAPDATA->m_ok = true;
+ M_BITMAPDATA->m_numColors = 0;
+ M_BITMAPDATA->m_quality = 0;
+ M_BITMAPDATA->m_cocoaNSBitmapImageRep = bitmapImage;
+ M_BITMAPDATA->m_bitmapMask = NULL;
+ return true;