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
This commit is contained in:
David Elliott 2003-12-06 23:27:08 +00:00
parent a28fe6d54e
commit b60c6e9776
2 changed files with 37 additions and 0 deletions

View File

@ -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);

View File

@ -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
// ========================================================================