Problem You need to make a snapshot of a composite (e.a. layout manager)
Solution Based on Jeroen's previous snapshot code of a widget, this one snaps the child widgets of a composite.
void makeSnapshot(const FXDrawable* drawable){ // Construct and create an FXImage object FXPNGImage snapshot(getApp(), NULL, 0, drawable->getWidth(), drawable->getHeight()); snapshot.create();
// Create a window device context and lock it onto the image FXDCWindow dc(&snapshot);
dc.clipChildren(FALSE); dc.setFunction(BLT_SRC);
// Draw from the widget to this dc.drawArea(drawable, 0, 0, drawable->getWidth(), drawable->getHeight(), 0, 0);
// Release lock dc.end();
// Grab pixels from server side back to client side snapshot.restore();
// Save recovered pixels to a file FXFileStream stream; if (stream.open("snapshot.png", FXStreamSave)) { snapshot.savePixels(stream); stream.close(); }
}
Contributor(s)Sander Jansen
|