为什么WXSCREENDC获得黑屏
有谁知道为什么 wxscreendc 只会在打击WXMemoryDC时才能获得黑屏。
我正在使用 wxwidgets v3.1.5(或v3.1.6)
相同的代码,用 wxscreendc wxwindowdc 一切都很好。
这是我的代码:
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);
}
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);
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论