Chnages to mono-bitmap code.

Added ConvertToMonoBitmap() to wxImage.
  Minor changes to forty.


git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@5359 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Robert Roebling
2000-01-12 17:57:18 +00:00
parent 9260520f90
commit 82ea63e6e0
11 changed files with 321 additions and 138 deletions

View File

@@ -289,6 +289,7 @@ void Game::Redraw(wxDC& dc)
// Initialise the card bitmap to the background colour // Initialise the card bitmap to the background colour
wxMemoryDC memoryDC; wxMemoryDC memoryDC;
memoryDC.SelectObject(*m_bmapCard); memoryDC.SelectObject(*m_bmapCard);
memoryDC.SetPen( *wxTRANSPARENT_PEN );
memoryDC.SetBrush(FortyApp::BackgroundBrush()); memoryDC.SetBrush(FortyApp::BackgroundBrush());
memoryDC.DrawRectangle(0, 0, CardWidth, CardHeight); memoryDC.DrawRectangle(0, 0, CardWidth, CardHeight);
memoryDC.SelectObject(*m_bmap); memoryDC.SelectObject(*m_bmap);
@@ -746,6 +747,7 @@ void Pack::Redraw(wxDC& dc)
char str[10]; char str[10];
sprintf(str, "%d ", m_topCard + 1); sprintf(str, "%d ", m_topCard + 1);
dc.SetBackgroundMode( wxSOLID );
dc.SetTextBackground(FortyApp::BackgroundColour()); dc.SetTextBackground(FortyApp::BackgroundColour());
dc.SetTextForeground(FortyApp::TextColour()); dc.SetTextForeground(FortyApp::TextColour());
dc.DrawText(str, m_x + CardWidth + 5, m_y + CardHeight / 2); dc.DrawText(str, m_x + CardWidth + 5, m_y + CardHeight / 2);

View File

@@ -123,6 +123,8 @@ PlayerSelectionDialog::PlayerSelectionDialog(
} }
Layout(); Layout();
CentreOnParent();
} }
PlayerSelectionDialog::~PlayerSelectionDialog() PlayerSelectionDialog::~PlayerSelectionDialog()

View File

@@ -97,6 +97,7 @@ public:
void SetWidth( int width ); void SetWidth( int width );
void SetDepth( int depth ); void SetDepth( int depth );
void SetPixmap( GdkPixmap *pixmap ); void SetPixmap( GdkPixmap *pixmap );
void SetBitmap( GdkBitmap *bitmap );
GdkPixmap *GetPixmap() const; GdkPixmap *GetPixmap() const;
GdkBitmap *GetBitmap() const; GdkBitmap *GetBitmap() const;

View File

@@ -97,6 +97,7 @@ public:
void SetWidth( int width ); void SetWidth( int width );
void SetDepth( int depth ); void SetDepth( int depth );
void SetPixmap( GdkPixmap *pixmap ); void SetPixmap( GdkPixmap *pixmap );
void SetBitmap( GdkBitmap *bitmap );
GdkPixmap *GetPixmap() const; GdkPixmap *GetPixmap() const;
GdkBitmap *GetBitmap() const; GdkBitmap *GetBitmap() const;

View File

@@ -101,6 +101,9 @@ public:
wxImage( const wxBitmap &bitmap ); wxImage( const wxBitmap &bitmap );
operator wxBitmap() const { return ConvertToBitmap(); } operator wxBitmap() const { return ConvertToBitmap(); }
wxBitmap ConvertToBitmap() const; wxBitmap ConvertToBitmap() const;
#ifdef __WXGTK__
wxBitmap ConvertToMonoBitmap( unsigned char red, unsigned char green, unsigned char blue );
#endif
void Create( int width, int height ); void Create( int width, int height );
void Destroy(); void Destroy();

View File

@@ -252,7 +252,8 @@ void MyCanvas::OnPaint( wxPaintEvent &WXUNUSED(event) )
if (my_smile_xbm && my_smile_xbm->Ok()) if (my_smile_xbm && my_smile_xbm->Ok())
{ {
dc.DrawText( "XBM bitmap", 30, 1745 ); dc.DrawText( "XBM bitmap", 30, 1745 );
dc.SetPen( *wxRED_PEN ); dc.SetTextForeground( "RED" );
dc.SetTextBackground( "GREEN" );
dc.DrawBitmap( *my_smile_xbm, 30, 1760 ); dc.DrawBitmap( *my_smile_xbm, 30, 1760 );
dc.DrawText( "After wxImage conversion", 150, 1745 ); dc.DrawText( "After wxImage conversion", 150, 1745 );
@@ -264,6 +265,33 @@ void MyCanvas::OnPaint( wxPaintEvent &WXUNUSED(event) )
wxRED_PEN->GetColour().Blue() ); wxRED_PEN->GetColour().Blue() );
dc.DrawBitmap( i.ConvertToBitmap(), 150, 1760, TRUE ); dc.DrawBitmap( i.ConvertToBitmap(), 150, 1760, TRUE );
} }
dc.SetTextForeground( "BLACK" );
wxBitmap mono( 30,30,1 );
wxMemoryDC memdc;
memdc.SelectObject( mono );
memdc.SetPen( *wxTRANSPARENT_PEN );
memdc.SetBrush( *wxBLACK_BRUSH );
memdc.DrawRectangle( 0,0,30,30 );
memdc.SetBrush( *wxWHITE_BRUSH );
memdc.DrawRectangle( 5,5,20,20 );
memdc.SelectObject( wxNullBitmap );
if (mono.Ok())
{
dc.DrawText( "Mono bitmap", 30, 1845 );
dc.SetTextForeground( "RED" );
dc.SetTextBackground( "GREEN" );
dc.DrawBitmap( mono, 30, 1860 );
dc.DrawText( "After wxImage conversion", 150, 1845 );
wxImage i( mono );
i.SetMaskColour( 0,0,0 );
i.Replace( 255,255,255,
wxRED_PEN->GetColour().Red(),
wxRED_PEN->GetColour().Green(),
wxRED_PEN->GetColour().Blue() );
dc.DrawBitmap( i.ConvertToBitmap(), 150, 1860, TRUE );
}
} }
void MyCanvas::CreateAntiAliasedBitmap() void MyCanvas::CreateAntiAliasedBitmap()
@@ -347,7 +375,7 @@ MyFrame::MyFrame()
m_canvas = new MyCanvas( this, -1, wxPoint(0,0), wxSize(10,10) ); m_canvas = new MyCanvas( this, -1, wxPoint(0,0), wxSize(10,10) );
// 500 width * 1900 height // 500 width * 1900 height
m_canvas->SetScrollbars( 10, 10, 50, 190 ); m_canvas->SetScrollbars( 10, 10, 50, 200 );
} }
void MyFrame::OnQuit( wxCommandEvent &WXUNUSED(event) ) void MyFrame::OnQuit( wxCommandEvent &WXUNUSED(event) )

View File

@@ -1311,6 +1311,104 @@ wxImage::wxImage( const wxBitmap &bitmap )
#include <gdk/gdkrgb.h> #include <gdk/gdkrgb.h>
#endif #endif
wxBitmap wxImage::ConvertToMonoBitmap( unsigned char red, unsigned char green, unsigned char blue )
{
wxBitmap bitmap;
wxCHECK_MSG( Ok(), bitmap, wxT("invalid image") );
int width = GetWidth();
int height = GetHeight();
bitmap.SetHeight( height );
bitmap.SetWidth( width );
bitmap.SetBitmap( gdk_pixmap_new( (GdkWindow*)&gdk_root_parent, width, height, 1 ) );
bitmap.SetDepth( 1 );
// Create picture image
unsigned char *data_data = (unsigned char*)malloc( ((width >> 3)+8) * height );
GdkImage *data_image =
gdk_image_new_bitmap( gdk_visual_get_system(), data_data, width, height );
// Create mask image
GdkImage *mask_image = (GdkImage*) NULL;
if (HasMask())
{
unsigned char *mask_data = (unsigned char*)malloc( ((width >> 3)+8) * height );
mask_image = gdk_image_new_bitmap( gdk_visual_get_system(), mask_data, width, height );
wxMask *mask = new wxMask();
mask->m_bitmap = gdk_pixmap_new( (GdkWindow*)&gdk_root_parent, width, height, 1 );
bitmap.SetMask( mask );
}
int r_mask = GetMaskRed();
int g_mask = GetMaskGreen();
int b_mask = GetMaskBlue();
unsigned char* data = GetData();
int index = 0;
for (int y = 0; y < height; y++)
{
for (int x = 0; x < width; x++)
{
int r = data[index];
index++;
int g = data[index];
index++;
int b = data[index];
index++;
if (HasMask())
{
if ((r == r_mask) && (b == b_mask) && (g == g_mask))
gdk_image_put_pixel( mask_image, x, y, 1 );
else
gdk_image_put_pixel( mask_image, x, y, 0 );
}
if ((r == red) && (b == blue) && (g == green))
gdk_image_put_pixel( data_image, x, y, 1 );
else
gdk_image_put_pixel( data_image, x, y, 0 );
} // for
} // for
// Blit picture
GdkGC *data_gc = gdk_gc_new( bitmap.GetBitmap() );
gdk_draw_image( bitmap.GetBitmap(), data_gc, data_image, 0, 0, 0, 0, width, height );
gdk_image_destroy( data_image );
gdk_gc_unref( data_gc );
// Blit mask
if (HasMask())
{
GdkGC *mask_gc = gdk_gc_new( bitmap.GetMask()->GetBitmap() );
gdk_draw_image( bitmap.GetMask()->GetBitmap(), mask_gc, mask_image, 0, 0, 0, 0, width, height );
gdk_image_destroy( mask_image );
gdk_gc_unref( mask_gc );
}
return bitmap;
}
wxBitmap wxImage::ConvertToBitmap() const wxBitmap wxImage::ConvertToBitmap() const
{ {
wxBitmap bitmap; wxBitmap bitmap;
@@ -1428,14 +1526,6 @@ wxBitmap wxImage::ConvertToBitmap() const
gdk_image_put_pixel( mask_image, x, y, 0 ); gdk_image_put_pixel( mask_image, x, y, 0 );
} }
if (HasMask())
{
if ((r == r_mask) && (b == b_mask) && (g == g_mask))
gdk_image_put_pixel( mask_image, x, y, 1 );
else
gdk_image_put_pixel( mask_image, x, y, 0 );
}
switch (bpp) switch (bpp)
{ {
case 8: case 8:

View File

@@ -513,6 +513,13 @@ void wxBitmap::SetPixmap( GdkPixmap *pixmap )
M_BMPDATA->m_pixmap = pixmap; M_BMPDATA->m_pixmap = pixmap;
} }
void wxBitmap::SetBitmap( GdkPixmap *bitmap )
{
if (!m_refData) m_refData = new wxBitmapRefData();
M_BMPDATA->m_bitmap = bitmap;
}
GdkPixmap *wxBitmap::GetPixmap() const GdkPixmap *wxBitmap::GetPixmap() const
{ {
wxCHECK_MSG( Ok(), (GdkPixmap *) NULL, wxT("invalid bitmap") ); wxCHECK_MSG( Ok(), (GdkPixmap *) NULL, wxT("invalid bitmap") );

View File

@@ -500,6 +500,8 @@ void wxWindowDC::DoDrawBitmap( const wxBitmap &bitmap,
wxCHECK_RET( bitmap.Ok(), wxT("invalid bitmap") ); wxCHECK_RET( bitmap.Ok(), wxT("invalid bitmap") );
bool is_mono = (bitmap.GetBitmap());
/* scale/translate size and position */ /* scale/translate size and position */
int xx = XLOG2DEV(x); int xx = XLOG2DEV(x);
@@ -523,8 +525,10 @@ void wxWindowDC::DoDrawBitmap( const wxBitmap &bitmap,
if ((w != ww) || (h != hh)) if ((w != ww) || (h != hh))
{ {
wxImage image( bitmap ); wxImage image( bitmap );
image = image.Scale( ww, hh ); image.Rescale( ww, hh );
if (is_mono)
use_bitmap = image.ConvertToMonoBitmap(255,255,255);
else
use_bitmap = image.ConvertToBitmap(); use_bitmap = image.ConvertToBitmap();
} }
else else
@@ -539,34 +543,41 @@ void wxWindowDC::DoDrawBitmap( const wxBitmap &bitmap,
if (useMask && mask) if (useMask && mask)
{ {
gdk_gc_set_clip_mask( m_penGC, mask ); if (is_mono)
gdk_gc_set_clip_origin( m_penGC, xx, yy );
}
/* draw XPixmap or XBitmap, depending on what the wxBitmap contains */
GdkPixmap *pm = use_bitmap.GetPixmap();
if (pm)
{ {
gdk_draw_pixmap( m_window, m_penGC, pm, 0, 0, xx, yy, -1, -1 ); gdk_gc_set_clip_mask( m_textGC, mask );
gdk_gc_set_clip_origin( m_textGC, xx, yy );
} }
else else
{ {
GdkBitmap *bm = use_bitmap.GetBitmap(); gdk_gc_set_clip_mask( m_penGC, mask );
if (bm) gdk_gc_set_clip_origin( m_penGC, xx, yy );
{
gdk_draw_bitmap( m_window, m_penGC, bm, 0, 0, xx, yy, -1, -1 );
} }
} }
/* Draw XPixmap or XBitmap, depending on what the wxBitmap contains. For
drawing a mono-bitmap (XBitmap) we use the current text GC */
if (is_mono)
gdk_draw_bitmap( m_window, m_textGC, use_bitmap.GetBitmap(), 0, 0, xx, yy, -1, -1 );
else
gdk_draw_pixmap( m_window, m_penGC, use_bitmap.GetPixmap(), 0, 0, xx, yy, -1, -1 );
/* remove mask again if any */ /* remove mask again if any */
if (useMask && mask) if (useMask && mask)
{
if (is_mono)
{
gdk_gc_set_clip_mask( m_textGC, (GdkBitmap *) NULL );
gdk_gc_set_clip_origin( m_textGC, 0, 0 );
}
else
{ {
gdk_gc_set_clip_mask( m_penGC, (GdkBitmap *) NULL ); gdk_gc_set_clip_mask( m_penGC, (GdkBitmap *) NULL );
gdk_gc_set_clip_origin( m_penGC, 0, 0 ); gdk_gc_set_clip_origin( m_penGC, 0, 0 );
} }
} }
}
bool wxWindowDC::DoBlit( wxCoord xdest, wxCoord ydest, wxCoord width, wxCoord height, bool wxWindowDC::DoBlit( wxCoord xdest, wxCoord ydest, wxCoord width, wxCoord height,
wxDC *source, wxCoord xsrc, wxCoord ysrc, wxDC *source, wxCoord xsrc, wxCoord ysrc,
@@ -587,6 +598,7 @@ bool wxWindowDC::DoBlit( wxCoord xdest, wxCoord ydest, wxCoord width, wxCoord he
wxMemoryDC *memDC = (wxMemoryDC*)source; wxMemoryDC *memDC = (wxMemoryDC*)source;
bool use_bitmap_method = FALSE; bool use_bitmap_method = FALSE;
bool is_mono = FALSE;
if (srcDC->m_isMemDC) if (srcDC->m_isMemDC)
{ {
@@ -610,6 +622,7 @@ bool wxWindowDC::DoBlit( wxCoord xdest, wxCoord ydest, wxCoord width, wxCoord he
/* we HAVE TO use the direct way for memory dcs /* we HAVE TO use the direct way for memory dcs
that are bitmaps because XCopyArea doesn't cope that are bitmaps because XCopyArea doesn't cope
with different bit depths */ with different bit depths */
is_mono = TRUE;
use_bitmap_method = TRUE; use_bitmap_method = TRUE;
} }
else if ((xsrc == 0) && (ysrc == 0) && else if ((xsrc == 0) && (ysrc == 0) &&
@@ -653,6 +666,9 @@ bool wxWindowDC::DoBlit( wxCoord xdest, wxCoord ydest, wxCoord width, wxCoord he
wxImage image( memDC->m_selected ); wxImage image( memDC->m_selected );
image = image.Scale( bm_ww, bm_hh ); image = image.Scale( bm_ww, bm_hh );
if (is_mono)
use_bitmap = image.ConvertToMonoBitmap(255,255,255);
else
use_bitmap = image.ConvertToBitmap(); use_bitmap = image.ConvertToBitmap();
} }
else else
@@ -675,36 +691,41 @@ bool wxWindowDC::DoBlit( wxCoord xdest, wxCoord ydest, wxCoord width, wxCoord he
if (useMask && mask) if (useMask && mask)
{ {
gdk_gc_set_clip_mask( m_penGC, mask ); if (is_mono)
gdk_gc_set_clip_origin( m_penGC, xx, yy );
}
/* draw XPixmap or XBitmap, depending on what the wxBitmap contains */
GdkPixmap *pm = use_bitmap.GetPixmap();
if (pm)
{ {
gdk_draw_pixmap( m_window, m_penGC, pm, xsrc, ysrc, xx, yy, ww, hh ); gdk_gc_set_clip_mask( m_textGC, mask );
gdk_gc_set_clip_origin( m_textGC, xx, yy );
} }
else else
{ {
GdkBitmap *bm = use_bitmap.GetBitmap(); gdk_gc_set_clip_mask( m_penGC, mask );
if (bm) gdk_gc_set_clip_origin( m_penGC, xx, yy );
{
/* we use the textGC here because blitting a bitmap is done
using the current text colour */
gdk_draw_bitmap( m_window, m_textGC, bm, xsrc, ysrc, xx, yy, ww, hh );
} }
} }
/* Draw XPixmap or XBitmap, depending on what the wxBitmap contains. For
drawing a mono-bitmap (XBitmap) we use the current text GC */
if (is_mono)
gdk_draw_bitmap( m_window, m_textGC, use_bitmap.GetBitmap(), xsrc, ysrc, xx, yy, ww, hh );
else
gdk_draw_pixmap( m_window, m_penGC, use_bitmap.GetPixmap(), xsrc, ysrc, xx, yy, ww, hh );
/* remove mask again if any */ /* remove mask again if any */
if (useMask && mask) if (useMask && mask)
{
if (is_mono)
{
gdk_gc_set_clip_mask( m_textGC, (GdkBitmap *) NULL );
gdk_gc_set_clip_origin( m_textGC, 0, 0 );
}
else
{ {
gdk_gc_set_clip_mask( m_penGC, (GdkBitmap *) NULL ); gdk_gc_set_clip_mask( m_penGC, (GdkBitmap *) NULL );
gdk_gc_set_clip_origin( m_penGC, 0, 0 ); gdk_gc_set_clip_origin( m_penGC, 0, 0 );
} }
} }
}
else /* use_bitmap_method */ else /* use_bitmap_method */
{ {
/* scale/translate size and position */ /* scale/translate size and position */

View File

@@ -513,6 +513,13 @@ void wxBitmap::SetPixmap( GdkPixmap *pixmap )
M_BMPDATA->m_pixmap = pixmap; M_BMPDATA->m_pixmap = pixmap;
} }
void wxBitmap::SetBitmap( GdkPixmap *bitmap )
{
if (!m_refData) m_refData = new wxBitmapRefData();
M_BMPDATA->m_bitmap = bitmap;
}
GdkPixmap *wxBitmap::GetPixmap() const GdkPixmap *wxBitmap::GetPixmap() const
{ {
wxCHECK_MSG( Ok(), (GdkPixmap *) NULL, wxT("invalid bitmap") ); wxCHECK_MSG( Ok(), (GdkPixmap *) NULL, wxT("invalid bitmap") );

View File

@@ -500,6 +500,8 @@ void wxWindowDC::DoDrawBitmap( const wxBitmap &bitmap,
wxCHECK_RET( bitmap.Ok(), wxT("invalid bitmap") ); wxCHECK_RET( bitmap.Ok(), wxT("invalid bitmap") );
bool is_mono = (bitmap.GetBitmap());
/* scale/translate size and position */ /* scale/translate size and position */
int xx = XLOG2DEV(x); int xx = XLOG2DEV(x);
@@ -523,8 +525,10 @@ void wxWindowDC::DoDrawBitmap( const wxBitmap &bitmap,
if ((w != ww) || (h != hh)) if ((w != ww) || (h != hh))
{ {
wxImage image( bitmap ); wxImage image( bitmap );
image = image.Scale( ww, hh ); image.Rescale( ww, hh );
if (is_mono)
use_bitmap = image.ConvertToMonoBitmap(255,255,255);
else
use_bitmap = image.ConvertToBitmap(); use_bitmap = image.ConvertToBitmap();
} }
else else
@@ -539,34 +543,41 @@ void wxWindowDC::DoDrawBitmap( const wxBitmap &bitmap,
if (useMask && mask) if (useMask && mask)
{ {
gdk_gc_set_clip_mask( m_penGC, mask ); if (is_mono)
gdk_gc_set_clip_origin( m_penGC, xx, yy );
}
/* draw XPixmap or XBitmap, depending on what the wxBitmap contains */
GdkPixmap *pm = use_bitmap.GetPixmap();
if (pm)
{ {
gdk_draw_pixmap( m_window, m_penGC, pm, 0, 0, xx, yy, -1, -1 ); gdk_gc_set_clip_mask( m_textGC, mask );
gdk_gc_set_clip_origin( m_textGC, xx, yy );
} }
else else
{ {
GdkBitmap *bm = use_bitmap.GetBitmap(); gdk_gc_set_clip_mask( m_penGC, mask );
if (bm) gdk_gc_set_clip_origin( m_penGC, xx, yy );
{
gdk_draw_bitmap( m_window, m_penGC, bm, 0, 0, xx, yy, -1, -1 );
} }
} }
/* Draw XPixmap or XBitmap, depending on what the wxBitmap contains. For
drawing a mono-bitmap (XBitmap) we use the current text GC */
if (is_mono)
gdk_draw_bitmap( m_window, m_textGC, use_bitmap.GetBitmap(), 0, 0, xx, yy, -1, -1 );
else
gdk_draw_pixmap( m_window, m_penGC, use_bitmap.GetPixmap(), 0, 0, xx, yy, -1, -1 );
/* remove mask again if any */ /* remove mask again if any */
if (useMask && mask) if (useMask && mask)
{
if (is_mono)
{
gdk_gc_set_clip_mask( m_textGC, (GdkBitmap *) NULL );
gdk_gc_set_clip_origin( m_textGC, 0, 0 );
}
else
{ {
gdk_gc_set_clip_mask( m_penGC, (GdkBitmap *) NULL ); gdk_gc_set_clip_mask( m_penGC, (GdkBitmap *) NULL );
gdk_gc_set_clip_origin( m_penGC, 0, 0 ); gdk_gc_set_clip_origin( m_penGC, 0, 0 );
} }
} }
}
bool wxWindowDC::DoBlit( wxCoord xdest, wxCoord ydest, wxCoord width, wxCoord height, bool wxWindowDC::DoBlit( wxCoord xdest, wxCoord ydest, wxCoord width, wxCoord height,
wxDC *source, wxCoord xsrc, wxCoord ysrc, wxDC *source, wxCoord xsrc, wxCoord ysrc,
@@ -587,6 +598,7 @@ bool wxWindowDC::DoBlit( wxCoord xdest, wxCoord ydest, wxCoord width, wxCoord he
wxMemoryDC *memDC = (wxMemoryDC*)source; wxMemoryDC *memDC = (wxMemoryDC*)source;
bool use_bitmap_method = FALSE; bool use_bitmap_method = FALSE;
bool is_mono = FALSE;
if (srcDC->m_isMemDC) if (srcDC->m_isMemDC)
{ {
@@ -610,6 +622,7 @@ bool wxWindowDC::DoBlit( wxCoord xdest, wxCoord ydest, wxCoord width, wxCoord he
/* we HAVE TO use the direct way for memory dcs /* we HAVE TO use the direct way for memory dcs
that are bitmaps because XCopyArea doesn't cope that are bitmaps because XCopyArea doesn't cope
with different bit depths */ with different bit depths */
is_mono = TRUE;
use_bitmap_method = TRUE; use_bitmap_method = TRUE;
} }
else if ((xsrc == 0) && (ysrc == 0) && else if ((xsrc == 0) && (ysrc == 0) &&
@@ -653,6 +666,9 @@ bool wxWindowDC::DoBlit( wxCoord xdest, wxCoord ydest, wxCoord width, wxCoord he
wxImage image( memDC->m_selected ); wxImage image( memDC->m_selected );
image = image.Scale( bm_ww, bm_hh ); image = image.Scale( bm_ww, bm_hh );
if (is_mono)
use_bitmap = image.ConvertToMonoBitmap(255,255,255);
else
use_bitmap = image.ConvertToBitmap(); use_bitmap = image.ConvertToBitmap();
} }
else else
@@ -675,36 +691,41 @@ bool wxWindowDC::DoBlit( wxCoord xdest, wxCoord ydest, wxCoord width, wxCoord he
if (useMask && mask) if (useMask && mask)
{ {
gdk_gc_set_clip_mask( m_penGC, mask ); if (is_mono)
gdk_gc_set_clip_origin( m_penGC, xx, yy );
}
/* draw XPixmap or XBitmap, depending on what the wxBitmap contains */
GdkPixmap *pm = use_bitmap.GetPixmap();
if (pm)
{ {
gdk_draw_pixmap( m_window, m_penGC, pm, xsrc, ysrc, xx, yy, ww, hh ); gdk_gc_set_clip_mask( m_textGC, mask );
gdk_gc_set_clip_origin( m_textGC, xx, yy );
} }
else else
{ {
GdkBitmap *bm = use_bitmap.GetBitmap(); gdk_gc_set_clip_mask( m_penGC, mask );
if (bm) gdk_gc_set_clip_origin( m_penGC, xx, yy );
{
/* we use the textGC here because blitting a bitmap is done
using the current text colour */
gdk_draw_bitmap( m_window, m_textGC, bm, xsrc, ysrc, xx, yy, ww, hh );
} }
} }
/* Draw XPixmap or XBitmap, depending on what the wxBitmap contains. For
drawing a mono-bitmap (XBitmap) we use the current text GC */
if (is_mono)
gdk_draw_bitmap( m_window, m_textGC, use_bitmap.GetBitmap(), xsrc, ysrc, xx, yy, ww, hh );
else
gdk_draw_pixmap( m_window, m_penGC, use_bitmap.GetPixmap(), xsrc, ysrc, xx, yy, ww, hh );
/* remove mask again if any */ /* remove mask again if any */
if (useMask && mask) if (useMask && mask)
{
if (is_mono)
{
gdk_gc_set_clip_mask( m_textGC, (GdkBitmap *) NULL );
gdk_gc_set_clip_origin( m_textGC, 0, 0 );
}
else
{ {
gdk_gc_set_clip_mask( m_penGC, (GdkBitmap *) NULL ); gdk_gc_set_clip_mask( m_penGC, (GdkBitmap *) NULL );
gdk_gc_set_clip_origin( m_penGC, 0, 0 ); gdk_gc_set_clip_origin( m_penGC, 0, 0 );
} }
} }
}
else /* use_bitmap_method */ else /* use_bitmap_method */
{ {
/* scale/translate size and position */ /* scale/translate size and position */