added InitAlpha() (replaces patch 991168)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@32213 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -53,6 +53,7 @@ All:
|
|||||||
- "Alt" key (VK_MENU) now results in WXK_ALT keyboard event, not WXK_MENU
|
- "Alt" key (VK_MENU) now results in WXK_ALT keyboard event, not WXK_MENU
|
||||||
- wxFFile::ReadAll() now takes an optional wxMBConv parameter
|
- wxFFile::ReadAll() now takes an optional wxMBConv parameter
|
||||||
- wxCommandProcessor::MarkAsSaved() and IsDirty() added (Angela Wrobel)
|
- wxCommandProcessor::MarkAsSaved() and IsDirty() added (Angela Wrobel)
|
||||||
|
- added wxStackWalker and related classes (Win32 and some Unix versions only)
|
||||||
|
|
||||||
|
|
||||||
All (GUI):
|
All (GUI):
|
||||||
@@ -74,6 +75,7 @@ All (GUI):
|
|||||||
of the progress (with new "Skip" button in dialog)
|
of the progress (with new "Skip" button in dialog)
|
||||||
- wxGenericListCtrl::SetItemState(-1) now changes the state of all items as
|
- wxGenericListCtrl::SetItemState(-1) now changes the state of all items as
|
||||||
in wxMSW version (Gunnar Roth)
|
in wxMSW version (Gunnar Roth)
|
||||||
|
- added wxImage::InitAlpha()
|
||||||
|
|
||||||
Unix:
|
Unix:
|
||||||
|
|
||||||
|
@@ -639,6 +639,16 @@ Returns true if the given option is present. The function is case-insensitive to
|
|||||||
\helpref{wxImage::GetOptionInt}{wximagegetoptionint}
|
\helpref{wxImage::GetOptionInt}{wximagegetoptionint}
|
||||||
|
|
||||||
|
|
||||||
|
\membersection{wxImage::InitAlpha}\label{wximageinitalpha}
|
||||||
|
|
||||||
|
\func{void}{InitAlpha}{\void}
|
||||||
|
|
||||||
|
Initializes the image alpha channel data. It is an error to call it
|
||||||
|
if the image already has alpha data. If it doesn't, alpha data will be
|
||||||
|
by default initialized to all pixels being fully opaque. But if the image has a
|
||||||
|
a mask colour, all mask pixels will be completely transparent.
|
||||||
|
|
||||||
|
|
||||||
\membersection{wxImage::InitStandardHandlers}\label{wximageinitstandardhandlers}
|
\membersection{wxImage::InitStandardHandlers}\label{wximageinitstandardhandlers}
|
||||||
|
|
||||||
\func{static void}{InitStandardHandlers}{\void}
|
\func{static void}{InitStandardHandlers}{\void}
|
||||||
|
@@ -272,6 +272,7 @@ public:
|
|||||||
unsigned char *GetAlpha() const; // may return NULL!
|
unsigned char *GetAlpha() const; // may return NULL!
|
||||||
bool HasAlpha() const { return GetAlpha() != NULL; }
|
bool HasAlpha() const { return GetAlpha() != NULL; }
|
||||||
void SetAlpha(unsigned char *alpha = NULL);
|
void SetAlpha(unsigned char *alpha = NULL);
|
||||||
|
void InitAlpha();
|
||||||
|
|
||||||
// Mask functions
|
// Mask functions
|
||||||
void SetMaskColour( unsigned char r, unsigned char g, unsigned char b );
|
void SetMaskColour( unsigned char r, unsigned char g, unsigned char b );
|
||||||
|
@@ -912,6 +912,44 @@ unsigned char *wxImage::GetAlpha() const
|
|||||||
return M_IMGDATA->m_alpha;
|
return M_IMGDATA->m_alpha;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void wxImage::InitAlpha()
|
||||||
|
{
|
||||||
|
wxCHECK_RET( !HasAlpha(), wxT("image already has an alpha channel") );
|
||||||
|
|
||||||
|
// initialize memory for alpha channel
|
||||||
|
SetAlpha();
|
||||||
|
|
||||||
|
unsigned char *alpha = M_IMGDATA->m_alpha;
|
||||||
|
const size_t lenAlpha = M_IMGDATA->m_width * M_IMGDATA->m_height;
|
||||||
|
|
||||||
|
static const unsigned char ALPHA_TRANSPARENT = 0;
|
||||||
|
static const unsigned char ALPHA_OPAQUE = 0xff;
|
||||||
|
if ( HasMask() )
|
||||||
|
{
|
||||||
|
// use the mask to initialize the alpha channel.
|
||||||
|
const unsigned char * const alphaEnd = alpha + lenAlpha;
|
||||||
|
|
||||||
|
const unsigned char mr = M_IMGDATA->m_maskRed;
|
||||||
|
const unsigned char mg = M_IMGDATA->m_maskGreen;
|
||||||
|
const unsigned char mb = M_IMGDATA->m_maskBlue;
|
||||||
|
for ( unsigned char *src = M_IMGDATA->m_data;
|
||||||
|
alpha < alphaEnd;
|
||||||
|
src += 3, alpha++ )
|
||||||
|
{
|
||||||
|
*alpha = (src[0] == mr && src[1] == mg && src[2] == mb)
|
||||||
|
? ALPHA_TRANSPARENT
|
||||||
|
: ALPHA_OPAQUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
M_IMGDATA->m_hasMask = false;
|
||||||
|
}
|
||||||
|
else // no mask
|
||||||
|
{
|
||||||
|
// make the image fully opaque
|
||||||
|
memset(alpha, ALPHA_OPAQUE, lenAlpha);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
// mask support
|
// mask support
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
|
Reference in New Issue
Block a user