Screenshot of Panel and a custom inside of it
I set a wxButton and it loads bitmap,png formats to Panel at right. But image is overfitting. I want to stretc image to Panel when it's loaded by button.
Here is button's function, just in case:
void rrFrame::testClick(wxCommandEvent& event)
{
wxBitmap bmp;
wxString strPath = wxT("img\\img1.png");
bmp.LoadFile(strPath, wxBITMAP_TYPE_ANY);
camFrame_wx->DrawBitmap(bmp, wxPoint(0, 0), false);
//camFrame_wx is the variable name of 'Custom'
}
I suppose i need a stretch or fit function in constructor. How to do this?
I think the easiest way to do this would be to load the image file into a wxImage first, then rescale the wxImage, and finally convert the wxImage to a wxBitmap. Like so:
void rrFrame::testClick(wxCommandEvent& event)
{
wxString strPath = "img\\img1.png";
wxImage im(strPath,wxBITMAP_TYPE_ANY );
wxSize sz = camFrame_wx->GetSize();
im.Rescale(sz.GetWidth(),sz.GetHeight(),wxIMAGE_QUALITY_HIGH );
wxBitmap bmp(im);
camFrame_wx->DrawBitmap(bmp, wxPoint(0, 0), false);
//camFrame_wx is the variable name of 'Custom'
}
Two additional comments: