Tomáš Zato
Tomáš Zato

Reputation: 53257

Save wxWidgets window screenshot

I have a wxWidgets application. I wan't to get the window screen as image and save it into a file.

I know that the wxImage can be saved easily:

wxImage im;
im.Create(window_width, window_height)
/**assign some data**/
im.SaveFile("path/screen.png", wxBITMAP_TYPE_PNG);

However, how do I gather the window (and I want only the window!) pixel data?

Upvotes: 1

Views: 2655

Answers (2)

VZ.
VZ.

Reputation: 22688

You can use wxClientDC to access the window data. Then just Blit() them to a wxMemoryDC with a wxBitmap selected into it and finally convert the bitmap to wxImage.

Upvotes: 3

ravenspoint
ravenspoint

Reputation: 20586

Here is some detailed code showing how to do this - it is the second article down.

http://forums.wxwidgets.org/viewtopic.php?p=32313

Upvotes: 2

Related Questions