X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/a51e79e87db3512823258d487849bb7e7947b700..f86190702bb433f139dc2c335e2c551755def81f:/src/osx/core/bitmap.cpp diff --git a/src/osx/core/bitmap.cpp b/src/osx/core/bitmap.cpp index fcc3a24ac0..da236465dd 100644 --- a/src/osx/core/bitmap.cpp +++ b/src/osx/core/bitmap.cpp @@ -890,9 +890,9 @@ wxBitmap::wxBitmap(const char bits[], int the_width, int the_height, int no_bits { if ( no_bits == 1 ) { - int linesize = ( the_width / (sizeof(unsigned char) * 8)) ; - if ( the_width % (sizeof(unsigned char) * 8) ) - linesize += sizeof(unsigned char); + int linesize = the_width / 8; + if ( the_width % 8 ) + linesize++; unsigned char* linestart = (unsigned char*) bits ; unsigned char* destptr = (unsigned char*) BeginRawAccess() ; @@ -939,6 +939,11 @@ wxBitmap::wxBitmap(const void* data, wxBitmapType type, int width, int height, i (void) Create(data, type, width, height, depth); } +wxBitmap::wxBitmap(int width, int height, const wxDC& WXUNUSED(dc)) +{ + (void) Create(width, height); +} + wxBitmap::wxBitmap(const wxString& filename, wxBitmapType type) { LoadFile(filename, type); @@ -1005,6 +1010,17 @@ IconRef wxBitmap::CreateIconRef() const #if wxOSX_USE_COCOA +wxBitmap::wxBitmap(WX_NSImage image) +{ + (void)Create(image); +} + +bool wxBitmap::Create(WX_NSImage image) +{ + wxCFRef cgimage(wxOSXCreateCGImageFromNSImage(image)); + return Create(cgimage); +} + WX_NSImage wxBitmap::GetNSImage() const { wxCFRef< CGImageRef > cgimage(CreateCGImage()); @@ -1102,7 +1118,6 @@ bool wxBitmap::Create(int w, int h, int d) return M_BITMAPDATA->IsOk() ; } - bool wxBitmap::Create(CGImageRef image) { UnRef(); @@ -1649,6 +1664,28 @@ bool wxMask::Create(const wxBitmap& bitmap, const wxColour& colour) return true; } +wxBitmap wxMask::GetBitmap() const +{ + wxBitmap bitmap(m_width, m_height, 1); + unsigned char* dst = static_cast(bitmap.BeginRawAccess()); + const int dst_stride = bitmap.GetBitmapData()->GetBytesPerRow(); + const unsigned char* src = static_cast(GetRawAccess()); + for (int j = 0; j < m_height; j++, src += m_bytesPerRow, dst += dst_stride) + { + unsigned char* d = dst; + for (int i = 0; i < m_width; i++) + { + const unsigned char byte = src[i]; + *d++ = 0xff; + *d++ = byte; + *d++ = byte; + *d++ = byte; + } + } + bitmap.EndRawAccess(); + return bitmap; +} + WXHBITMAP wxMask::GetHBITMAP() const { return m_maskBitmap ;