X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/29c310fe056f23acbbab37fc51faf58d5326bcf5..461fe6e2559a3096d4985a50ba106f26ed890a1d:/src/cocoa/bitmap.mm diff --git a/src/cocoa/bitmap.mm b/src/cocoa/bitmap.mm index ca82c1a4e4..c57e24e4f9 100644 --- a/src/cocoa/bitmap.mm +++ b/src/cocoa/bitmap.mm @@ -9,12 +9,14 @@ // Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// -#include "wx/setup.h" -#include "wx/utils.h" -#include "wx/palette.h" +#include "wx/wxprec.h" +#ifndef WX_PRECOMP + #include "wx/log.h" + #include "wx/utils.h" + #include "wx/palette.h" + #include "wx/icon.h" +#endif //WX_PRECOMP #include "wx/bitmap.h" -#include "wx/icon.h" -#include "wx/log.h" #include "wx/image.h" #include "wx/xpmdecod.h" @@ -70,8 +72,7 @@ wxBitmapRefData::wxBitmapRefData( const wxBitmapRefData& data) m_numColors = data.m_numColors; m_bitmapPalette = data.m_bitmapPalette; m_quality = data.m_quality; - m_cocoaNSBitmapImageRep = data.m_cocoaNSBitmapImageRep; - [m_cocoaNSBitmapImageRep retain]; + m_cocoaNSBitmapImageRep = [data.m_cocoaNSBitmapImageRep copyWithZone:nil]; m_bitmapMask = data.m_bitmapMask?new wxMask(*data.m_bitmapMask):NULL; } @@ -142,6 +143,16 @@ WX_NSBitmapImageRep wxBitmap::GetNSBitmapImageRep() return M_BITMAPDATA->m_cocoaNSBitmapImageRep; } +void wxBitmap::SetNSBitmapImageRep(WX_NSBitmapImageRep bitmapImageRep) +{ + if(!M_BITMAPDATA) + return; + // NOTE: No checking is done to make sure width/height agree + [bitmapImageRep retain]; + [M_BITMAPDATA->m_cocoaNSBitmapImageRep release]; + M_BITMAPDATA->m_cocoaNSBitmapImageRep = bitmapImageRep; +} + void wxBitmap::SetWidth(int w) { if (!M_BITMAPDATA) @@ -249,6 +260,23 @@ bool wxBitmap::Create(int w, int h, int d) M_BITMAPDATA->m_depth = d; /* TODO: create new bitmap */ + M_BITMAPDATA->m_cocoaNSBitmapImageRep = [[NSBitmapImageRep alloc] + initWithBitmapDataPlanes: NULL + pixelsWide: w + pixelsHigh: h + bitsPerSample: 8 + samplesPerPixel: 3 + hasAlpha: NO + isPlanar: NO + colorSpaceName: NSCalibratedRGBColorSpace + bytesPerRow: 0 + bitsPerPixel: 0]; + + wxLogDebug("M_BITMAPDATA=%p NSBitmapImageRep bitmapData=%p", M_BITMAPDATA, [M_BITMAPDATA->m_cocoaNSBitmapImageRep bitmapData]); + M_BITMAPDATA->m_ok = true; + M_BITMAPDATA->m_numColors = 0; + M_BITMAPDATA->m_quality = 0; + M_BITMAPDATA->m_bitmapMask = NULL; return M_BITMAPDATA->m_ok; }