From b60c6e9776cdadbc013b4bcc5a33c7e048ed554d Mon Sep 17 00:00:00 2001 From: David Elliott Date: Sat, 6 Dec 2003 23:27:08 +0000 Subject: [PATCH] Added simple implementation of (Get|Unget)RawData. Premultipied alpha is not handled at this point. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@24716 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- include/wx/cocoa/bitmap.h | 5 +++++ src/cocoa/bitmap.mm | 32 ++++++++++++++++++++++++++++++++ 2 files changed, 37 insertions(+) diff --git a/include/wx/cocoa/bitmap.h b/include/wx/cocoa/bitmap.h index 5715478e2a..6b3186d1b2 100644 --- a/include/wx/cocoa/bitmap.h +++ b/include/wx/cocoa/bitmap.h @@ -19,6 +19,7 @@ class WXDLLEXPORT wxBitmap; class WXDLLEXPORT wxIcon; class WXDLLEXPORT wxCursor; class WXDLLEXPORT wxImage; +class WXDLLEXPORT wxPixelDataBase; // ======================================================================== // wxMask @@ -123,6 +124,10 @@ public: void SetQuality(int q); void SetOk(bool isOk); + // raw bitmap access support functions + void *GetRawData(wxPixelDataBase& data, int bpp); + void UngetRawData(wxPixelDataBase& data); + wxPalette* GetPalette() const; void SetPalette(const wxPalette& palette); diff --git a/src/cocoa/bitmap.mm b/src/cocoa/bitmap.mm index c57e24e4f9..20eb68c03a 100644 --- a/src/cocoa/bitmap.mm +++ b/src/cocoa/bitmap.mm @@ -19,6 +19,7 @@ #include "wx/bitmap.h" #include "wx/image.h" #include "wx/xpmdecod.h" +#include "wx/rawbmp.h" #include "wx/cocoa/autorelease.h" #include "wx/cocoa/string.h" @@ -396,6 +397,37 @@ bool wxBitmap::CreateFromImage(const wxImage& image, int depth) return true; } +void *wxBitmap::GetRawData(wxPixelDataBase& data, int bpp) +{ + if(!Ok()) + return NULL; + + NSBitmapImageRep *bitmapRep = M_BITMAPDATA->m_cocoaNSBitmapImageRep; + if(!bitmapRep) + return NULL; + + if([bitmapRep bitsPerPixel]!=bpp) + { + wxFAIL_MSG( _T("incorrect bitmap type in wxBitmap::GetRawData()") ); + return NULL; + } + data.m_width = [bitmapRep pixelsWide]; + data.m_height = [bitmapRep pixelsHigh]; + data.m_stride = [bitmapRep bytesPerRow]; + return [bitmapRep bitmapData]; + + // NOTE: It is up to the user to make sure they used the proper + // pixel format class that details what is actually inside the pixels + // We can only check to make sure that the total number of bits per + // pixel are being iterated over properly + // NSBitmapImageRep can contain grayscale or CMYK data and + // wxPixelDataBase doesn't really define the color format +} + +void wxBitmap::UngetRawData(wxPixelDataBase& data) +{ // TODO +} + // ======================================================================== // wxMask // ======================================================================== -- 2.45.2