X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/148af7c534dcd3cf129c10db13fc37828d0f3cc1..657309a52bd20b14d5a431a6d4d107fd76f9569a:/src/cocoa/bitmap.mm?ds=sidebyside diff --git a/src/cocoa/bitmap.mm b/src/cocoa/bitmap.mm index d075f0a56d..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();