Always create the pixmap with an alpha channel
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@40762 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -299,7 +299,7 @@ wxBitmap wxBitmap::Rescale( int clipx, int clipy, int clipwidth, int clipheight,
|
|||||||
{
|
{
|
||||||
bmp.SetDepth(GetDepth());
|
bmp.SetDepth(GetDepth());
|
||||||
bmp.SetPixbuf(gdk_pixbuf_new(GDK_COLORSPACE_RGB,
|
bmp.SetPixbuf(gdk_pixbuf_new(GDK_COLORSPACE_RGB,
|
||||||
gdk_pixbuf_get_has_alpha(GetPixbuf()),
|
true, //gdk_pixbuf_get_has_alpha(GetPixbuf()),
|
||||||
8, width, height));
|
8, width, height));
|
||||||
gdk_pixbuf_scale(GetPixbuf(), bmp.GetPixbuf(),
|
gdk_pixbuf_scale(GetPixbuf(), bmp.GetPixbuf(),
|
||||||
0, 0, width, height,
|
0, 0, width, height,
|
||||||
@@ -566,7 +566,7 @@ bool wxBitmap::CreateFromImageAsPixbuf(const wxImage& image)
|
|||||||
int height = image.GetHeight();
|
int height = image.GetHeight();
|
||||||
|
|
||||||
GdkPixbuf *pixbuf = gdk_pixbuf_new(GDK_COLORSPACE_RGB,
|
GdkPixbuf *pixbuf = gdk_pixbuf_new(GDK_COLORSPACE_RGB,
|
||||||
image.HasAlpha(),
|
true, //image.HasAlpha(),
|
||||||
8 /* bits per sample */,
|
8 /* bits per sample */,
|
||||||
width, height);
|
width, height);
|
||||||
if (!pixbuf)
|
if (!pixbuf)
|
||||||
@@ -789,7 +789,7 @@ wxBitmap wxBitmap::GetSubBitmap( const wxRect& rect) const
|
|||||||
if (HasPixbuf())
|
if (HasPixbuf())
|
||||||
{
|
{
|
||||||
GdkPixbuf *pixbuf = gdk_pixbuf_new(GDK_COLORSPACE_RGB,
|
GdkPixbuf *pixbuf = gdk_pixbuf_new(GDK_COLORSPACE_RGB,
|
||||||
gdk_pixbuf_get_has_alpha(GetPixbuf()),
|
true, //gdk_pixbuf_get_has_alpha(GetPixbuf()),
|
||||||
8, rect.width, rect.height);
|
8, rect.width, rect.height);
|
||||||
ret.SetPixbuf(pixbuf);
|
ret.SetPixbuf(pixbuf);
|
||||||
ret.SetDepth(M_BMPDATA->m_bpp);
|
ret.SetDepth(M_BMPDATA->m_bpp);
|
||||||
@@ -939,8 +939,10 @@ GdkPixbuf *wxBitmap::GetPixbuf() const
|
|||||||
int width = GetWidth();
|
int width = GetWidth();
|
||||||
int height = GetHeight();
|
int height = GetHeight();
|
||||||
|
|
||||||
|
// always create the alpha channel so raw bitmap access will work
|
||||||
|
// correctly
|
||||||
GdkPixbuf *pixbuf = gdk_pixbuf_new(GDK_COLORSPACE_RGB,
|
GdkPixbuf *pixbuf = gdk_pixbuf_new(GDK_COLORSPACE_RGB,
|
||||||
GetMask() != NULL,
|
true, // GetMask() != NULL,
|
||||||
8, width, height);
|
8, width, height);
|
||||||
M_BMPDATA->m_pixbuf =
|
M_BMPDATA->m_pixbuf =
|
||||||
gdk_pixbuf_get_from_drawable(pixbuf, M_BMPDATA->m_pixmap, NULL,
|
gdk_pixbuf_get_from_drawable(pixbuf, M_BMPDATA->m_pixmap, NULL,
|
||||||
@@ -1021,11 +1023,14 @@ void *wxBitmap::GetRawData(wxPixelDataBase& data, int bpp)
|
|||||||
if (!pixbuf)
|
if (!pixbuf)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
|
if (!gdk_pixbuf_get_has_alpha( pixbuf ))
|
||||||
|
return NULL;
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
if (gdk_pixbuf_get_has_alpha( pixbuf ))
|
if (gdk_pixbuf_get_has_alpha( pixbuf ))
|
||||||
wxPrintf( wxT("Has alpha\n") );
|
wxPrintf( wxT("Has alpha, %d channels\n"), gdk_pixbuf_get_n_channels(pixbuf) );
|
||||||
else
|
else
|
||||||
wxPrintf( wxT("No alpha.\n") );
|
wxPrintf( wxT("No alpha, %d channels.\n"), gdk_pixbuf_get_n_channels(pixbuf) );
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
data.m_height = gdk_pixbuf_get_height( pixbuf );
|
data.m_height = gdk_pixbuf_get_height( pixbuf );
|
||||||
|
Reference in New Issue
Block a user