2006年12月25日星期一

Use Blit in wxWindows

wxDC::Blit is used to copy from a source DC to this DC, and it can be used to erase a shape but no affect the backgroud. This is very useful in case you need to erase a shape but not want to invoke Refresh or Invalidate since such methods may bring flickering. Below is an example:

wxMemoryDC memDC;

// Draw an ellipse as background
dc.SetBrush(wxBrush(wxColour(255, 0, 0)));
dc.DrawEllipse(10, 10, 100, 100);

// Draw a line
wxBitmap bmp(150, 1);
memDC.SelectObject(bmp);
dc.Blit(5, 60, 150, 1, &memDC, 0, 0, wxEQUIV);

// Erase the line
dc.Blit(5, 60, 150, 1, &memDC, 0, 0, wxINVERT);

没有评论: