no real changes, just move wxMask::GetBitmap() to wxMask section
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@73410 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -273,6 +273,46 @@ bool wxMask::InitFromMonoBitmap(const wxBitmap& bitmap)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
wxBitmap wxMask::GetBitmap() const
|
||||||
|
{
|
||||||
|
wxBitmap bitmap;
|
||||||
|
if (m_bitmap)
|
||||||
|
{
|
||||||
|
#ifdef __WXGTK3__
|
||||||
|
cairo_surface_t* mask = m_bitmap;
|
||||||
|
const int w = cairo_image_surface_get_width(mask);
|
||||||
|
const int h = cairo_image_surface_get_height(mask);
|
||||||
|
GdkPixbuf* pixbuf = gdk_pixbuf_new(GDK_COLORSPACE_RGB, false, 8, w, h);
|
||||||
|
const guchar* src = cairo_image_surface_get_data(mask);
|
||||||
|
guchar* dst = gdk_pixbuf_get_pixels(pixbuf);
|
||||||
|
const int stride_src = cairo_image_surface_get_stride(mask);
|
||||||
|
const int stride_dst = gdk_pixbuf_get_rowstride(pixbuf);
|
||||||
|
for (int j = 0; j < h; j++, src += stride_src, dst += stride_dst)
|
||||||
|
{
|
||||||
|
guchar* d = dst;
|
||||||
|
for (int i = 0; i < w; i++, d += 3)
|
||||||
|
{
|
||||||
|
d[0] = src[i];
|
||||||
|
d[1] = src[i];
|
||||||
|
d[2] = src[i];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
bitmap = wxBitmap(pixbuf, 1);
|
||||||
|
#else
|
||||||
|
GdkPixmap* mask = m_bitmap;
|
||||||
|
int w, h;
|
||||||
|
gdk_drawable_get_size(mask, &w, &h);
|
||||||
|
GdkPixmap* pixmap = gdk_pixmap_new(mask, w, h, -1);
|
||||||
|
GdkGC* gc = gdk_gc_new(pixmap);
|
||||||
|
gdk_gc_set_function(gc, GDK_COPY_INVERT);
|
||||||
|
gdk_draw_drawable(pixmap, gc, mask, 0, 0, 0, 0, w, h);
|
||||||
|
g_object_unref(gc);
|
||||||
|
bitmap = wxBitmap(pixmap);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
return bitmap;
|
||||||
|
}
|
||||||
|
|
||||||
#ifdef __WXGTK3__
|
#ifdef __WXGTK3__
|
||||||
wxMask::operator cairo_surface_t*() const
|
wxMask::operator cairo_surface_t*() const
|
||||||
#else
|
#else
|
||||||
@@ -909,46 +949,6 @@ void wxBitmap::SetMask( wxMask *mask )
|
|||||||
M_BMPDATA->m_mask = mask;
|
M_BMPDATA->m_mask = mask;
|
||||||
}
|
}
|
||||||
|
|
||||||
wxBitmap wxMask::GetBitmap() const
|
|
||||||
{
|
|
||||||
wxBitmap bitmap;
|
|
||||||
if (m_bitmap)
|
|
||||||
{
|
|
||||||
#ifdef __WXGTK3__
|
|
||||||
cairo_surface_t* mask = m_bitmap;
|
|
||||||
const int w = cairo_image_surface_get_width(mask);
|
|
||||||
const int h = cairo_image_surface_get_height(mask);
|
|
||||||
GdkPixbuf* pixbuf = gdk_pixbuf_new(GDK_COLORSPACE_RGB, false, 8, w, h);
|
|
||||||
const guchar* src = cairo_image_surface_get_data(mask);
|
|
||||||
guchar* dst = gdk_pixbuf_get_pixels(pixbuf);
|
|
||||||
const int stride_src = cairo_image_surface_get_stride(mask);
|
|
||||||
const int stride_dst = gdk_pixbuf_get_rowstride(pixbuf);
|
|
||||||
for (int j = 0; j < h; j++, src += stride_src, dst += stride_dst)
|
|
||||||
{
|
|
||||||
guchar* d = dst;
|
|
||||||
for (int i = 0; i < w; i++, d += 3)
|
|
||||||
{
|
|
||||||
d[0] = src[i];
|
|
||||||
d[1] = src[i];
|
|
||||||
d[2] = src[i];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
bitmap = wxBitmap(pixbuf, 1);
|
|
||||||
#else
|
|
||||||
GdkPixmap* mask = m_bitmap;
|
|
||||||
int w, h;
|
|
||||||
gdk_drawable_get_size(mask, &w, &h);
|
|
||||||
GdkPixmap* pixmap = gdk_pixmap_new(mask, w, h, -1);
|
|
||||||
GdkGC* gc = gdk_gc_new(pixmap);
|
|
||||||
gdk_gc_set_function(gc, GDK_COPY_INVERT);
|
|
||||||
gdk_draw_drawable(pixmap, gc, mask, 0, 0, 0, 0, w, h);
|
|
||||||
g_object_unref(gc);
|
|
||||||
bitmap = wxBitmap(pixmap);
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
return bitmap;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool wxBitmap::CopyFromIcon(const wxIcon& icon)
|
bool wxBitmap::CopyFromIcon(const wxIcon& icon)
|
||||||
{
|
{
|
||||||
*this = icon;
|
*this = icon;
|
||||||
|
@@ -1173,13 +1173,6 @@ wxMask *wxBitmap::GetMask() const
|
|||||||
return GetBitmapData() ? GetBitmapData()->GetMask() : NULL;
|
return GetBitmapData() ? GetBitmapData()->GetMask() : NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
wxBitmap wxMask::GetBitmap() const
|
|
||||||
{
|
|
||||||
wxBitmap bmp;
|
|
||||||
bmp.SetHBITMAP(m_maskBitmap);
|
|
||||||
return bmp;
|
|
||||||
}
|
|
||||||
|
|
||||||
wxDC *wxBitmap::GetSelectedInto() const
|
wxDC *wxBitmap::GetSelectedInto() const
|
||||||
{
|
{
|
||||||
#if wxDEBUG_LEVEL
|
#if wxDEBUG_LEVEL
|
||||||
@@ -1547,6 +1540,13 @@ bool wxMask::Create(const wxBitmap& bitmap, const wxColour& colour)
|
|||||||
#endif // __WXMICROWIN__/!__WXMICROWIN__
|
#endif // __WXMICROWIN__/!__WXMICROWIN__
|
||||||
}
|
}
|
||||||
|
|
||||||
|
wxBitmap wxMask::GetBitmap() const
|
||||||
|
{
|
||||||
|
wxBitmap bmp;
|
||||||
|
bmp.SetHBITMAP(m_maskBitmap);
|
||||||
|
return bmp;
|
||||||
|
}
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
// wxBitmapHandler
|
// wxBitmapHandler
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
|
Reference in New Issue
Block a user