Hi Thomas, Your way capturing screenshot is working on my system at least. Probably there is problem with the plug-in. Set OSG_NOTIFY_LEVEL=DEBUG, and see whether you are getting any errors or warnings, also try to play with different formats. This particular format may not be supported by your plug-in.
Cheers, Sumit Date: Mon, 05 Apr 2010 15:02:09 +0000 From: "Thomas PATTOU" <[email protected]> To: [email protected] Subject: [osg-users] WriteImageFile black Message-ID: <[email protected]> Content-Type: text/plain; charset=UTF-8 Hi everybody, First, I want to state that I am aware there is already quite a few posts about this. I read most of them, trying to understand what is wrong with my application; now that this is said, I can also state that I did not find out the solution. Basically, I am trying to achieve the same thing as a lot of people, taking a screenshot of my current view and writing it to file. I really tried a lot of ways to get this working, in vain. : - I tried to use the ScreenCaptureHandler, but this doesn't allow me to achieve what I want (I want to record several frames during a given period) because of the fact that it only takes screenshots when you press a key. - I tried to have a look at osgscreencapture, which is unfortunately too complex for me to get it clearly. - I tried the basic Code: osg::Image* temp = new osg::Image(); temp->readPixels(0, 0, viewer->getCamera()->getGraphicsContext()->getTraits()->width, viewer->getCamera()->getGraphicsContext()->getTraits()->height, GL_RGB, GL_UNSIGNED_BYTE); osgDB::writeImageFile(*temp, toto.jpg); which gives me the result I have now (a black jpg file). - I also tried to put that code in a handler derived from GUIEventHandler Code: bool ScreenshotHandler::handle(const osgGA::GUIEventAdapter& ea,osgGA::GUIActionAdapter& aa) { osg::View* viewTest = aa.asView(); osg::Image* temp = new osg::Image(); temp->readPixels(0, 0, viewTest->getCamera()->getGraphicsContext()->getTraits()->width, viewTest->getCamera()->getGraphicsContext()->getTraits()->height, GL_RGB, GL_UNSIGNED_BYTE); osgDB::writeImageFile(*temp, "toto2.jpg"); return true; } that I add to the viewer, but I still get the same problem. I really am starting to be in a rush for this project, and getting depressed by the complexity of getting a simple shot of the view. Please help! Thank you! Cheers, Thomas[/code] ------------------ Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=26457#26457 _______________________________________________ osg-users mailing list [email protected] http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

