X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/319fe1034c0bdecf2b3a34669f3a15782c60d0b2..795b0f144495454aac0dc23e865f7a8f87f6dfa3:/src/cocoa/bitmap.mm?ds=inline diff --git a/src/cocoa/bitmap.mm b/src/cocoa/bitmap.mm index b16ba01087..cddc8c192f 100644 --- a/src/cocoa/bitmap.mm +++ b/src/cocoa/bitmap.mm @@ -125,6 +125,16 @@ wxBitmap::wxBitmap(int w, int h, int d) (void)Create(w, h, d); } +wxBitmap::wxBitmap(NSImage* cocoaNSImage) +{ + (void) Create(cocoaNSImage); +} + +wxBitmap::wxBitmap(NSBitmapImageRep* cocoaNSBitmapImageRep) +{ + (void) Create(cocoaNSBitmapImageRep); +} + wxBitmap::wxBitmap(const void* data, wxBitmapType type, int width, int height, int depth) { (void) Create(data, type, width, height, depth); @@ -348,6 +358,33 @@ bool wxBitmap::LoadFile(const wxString& filename, wxBitmapType type) return true; } +bool wxBitmap::Create(NSImage* cocoaNSImage) +{ + wxAutoNSAutoreleasePool pool; + NSBitmapImageRep *bitmapImageRep = [NSBitmapImageRep imageRepWithData:[cocoaNSImage TIFFRepresentation]]; + return Create(bitmapImageRep); +} + +bool wxBitmap::Create(NSBitmapImageRep *imageRep) +{ + UnRef(); + m_refData = new wxBitmapRefData; + if(imageRep != nil) + { + M_BITMAPDATA->m_width = [imageRep pixelsWide]; + M_BITMAPDATA->m_height = [imageRep pixelsHigh]; + M_BITMAPDATA->m_depth = [imageRep bitsPerPixel]; + M_BITMAPDATA->m_ok = true; + M_BITMAPDATA->m_numColors = 0; + M_BITMAPDATA->m_quality = 0; + M_BITMAPDATA->m_cocoaNSBitmapImageRep = [imageRep retain]; + M_BITMAPDATA->m_bitmapMask = NULL; + return true; + } + else + return false; +} + bool wxBitmap::Create(const void* data, wxBitmapType type, int width, int height, int depth) { UnRef(); @@ -364,6 +401,9 @@ bool wxBitmap::SaveFile(const wxString& filename, wxBitmapType type, const wxPal bool wxBitmap::CopyFromIcon(const wxIcon& icon) { + // Pool here due to lack of one during wx init phase + wxAutoNSAutoreleasePool pool; + UnRef(); if(!icon.GetNSImage()); [icon.GetNSImage() lockFocus]; @@ -535,7 +575,7 @@ wxMask::~wxMask() bool wxMask::Create(const wxBitmap& bitmap) { // TODO - wxLogDebug("Cannot yet create a mask from a mono bitmap"); + wxLogDebug(wxT("Cannot yet create a mask from a mono bitmap")); return FALSE; } @@ -544,7 +584,7 @@ bool wxMask::Create(const wxBitmap& bitmap) bool wxMask::Create(const wxBitmap& bitmap, int paletteIndex) { // TODO - wxLogDebug("Cannot yet create a mask from a palette bitmap"); + wxLogDebug(wxT("Cannot yet create a mask from a palette bitmap")); return FALSE; }