Use gil in ColourButton rather than wxMemoryDC

Basic drawing with wxMemoryDC is relatively slow.
This commit is contained in:
Thomas Goyne 2013-07-01 21:34:37 -07:00
parent 991569463a
commit e2022449d9
2 changed files with 5 additions and 6 deletions

View file

@ -21,7 +21,7 @@
#include "compat.h" #include "compat.h"
#include "dialog_colorpicker.h" #include "dialog_colorpicker.h"
#include <wx/dcmemory.h> #include <boost/gil/gil_all.hpp>
wxDEFINE_EVENT(EVT_COLOR, wxThreadEvent); wxDEFINE_EVENT(EVT_COLOR, wxThreadEvent);
@ -45,9 +45,8 @@ ColourButton::ColourButton(wxWindow *parent, wxSize const& size, bool alpha, agi
} }
void ColourButton::UpdateBitmap() { void ColourButton::UpdateBitmap() {
wxMemoryDC dc; using namespace boost::gil;
dc.SelectObject(bmp); fill_pixels(interleaved_view(bmp.GetWidth(), bmp.GetHeight(), (bgr8_pixel_t*)bmp.GetData(), 3 * bmp.GetWidth()),
dc.SetBrush(wxBrush(to_wx(colour))); bgr8_pixel_t(colour.r, colour.g, colour.b));
dc.DrawRectangle(0, 0, bmp.GetWidth(), bmp.GetHeight());
SetBitmapLabel(bmp); SetBitmapLabel(bmp);
} }

View file

@ -25,7 +25,7 @@ wxDECLARE_EVENT(EVT_COLOR, wxThreadEvent);
/// A button which displays a currently-selected color and lets the user pick /// A button which displays a currently-selected color and lets the user pick
/// a new color when clicked /// a new color when clicked
class ColourButton: public wxButton { class ColourButton: public wxButton {
wxBitmap bmp; ///< The button's bitmap label wxImage bmp; ///< The button's bitmap label
agi::Color colour; ///< The current colour agi::Color colour; ///< The current colour
/// Update the bitmap label after the color is changed /// Update the bitmap label after the color is changed