24 #ifndef COM_DAFER45_TBTK_IMAGE_PANEL
25 #define COM_DAFER45_TBTK_IMAGE_PANEL
30 #include <opencv2/core/core.hpp>
34 class ImagePanel :
public wxPanel{
37 ImagePanel(wxWindow *parent);
43 void setImage(wxString file, wxBitmapType format);
46 void setImage(
const cv::Mat &image);
49 void onPaintEvent(wxPaintEvent &event);
52 void onSizeEvent(wxSizeEvent &event);
58 void render(wxDC &dc);
60 DECLARE_EVENT_TABLE();
66 wxBitmap resizedImage;
75 inline void ImagePanel::setImage(
const cv::Mat &image){
76 unsigned char *data =
new unsigned char[image.elemSize()*image.cols*image.rows];
77 for(
unsigned int n = 0; n < image.elemSize()*image.cols*image.rows; n++)
78 data[n] = image.data[n];
80 this->image = wxImage(image.cols, image.rows, data,
false);