I need to save screenshot from my application ( this = wxFrame ). The code below does it but around the application icon (in the title bar) I see some artifacts. I suppose it is a result of wxImage::ClearAlpha() method and artifacts are the trace of icon's shadow or something like this. If I comment ClearAlpha than the image not recognized correctly by most of the picture viewers (only icon or title bar is shown, depends on OS). At the same time file contains all data (mspaint by winxp show the image). What would you recommend in this situation?
Code: Select all
wxImage::AddHandler(new wxPNGHandler); wxWindowDC wnd(this); //wxScreenDC wnd; wxSize wndsize = wnd.GetSize(); wxBitmap scr(wndsize.x, wndsize.y, -1); wxMemoryDC memdc(scr); memdc.Blit(0, 0, wndsize.x, wndsize.y, &wnd, 0, 0); memdc.SelectObject(wxNullBitmap); wxImage img = scr.ConvertToImage(); img.ClearAlpha(); img.SaveFile(wxT("c:\\baralgin\\my_screenshot.png"),wxBITMAP_TYPE_PNG);