'why wxScreenDC get black screen
Does anyone know why wxScreenDC only get black screen when Blit to a wxMemoryDC.
I'm using Debian system with wxWidgets v3.1.5(or v3.1.6)
Same code, replace wxScreenDC with wxWindowDC everything go fine.
This is my code:
void MyFrame::OnCapture(wxCommandEvent &event)
{
wxFileDialog dlg(this, _("Save PNG file"), "", "",
"PNG files (*.png)|*.png", wxFD_SAVE|wxFD_OVERWRITE_PROMPT);
if (dlg.ShowModal() == wxID_CANCEL)return;
wxScreenDC dc;
// wxWindowDC dc(this);
wxSize sz = dc.GetSize();
wxBitmap bmp(sz.x, sz.y);
wxMemoryDC memDC;
memDC.SelectObject(bmp);
memDC.Blit(0, 0, sz.x, sz.y, &dc, 0, 0);
memDC.SelectObject(wxNullBitmap);
bmp.SaveFile(dlg.GetPath(), wxBITMAP_TYPE_PNG);
}
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|