[osg-users] WriteImageFile black
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 osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] WriteImageFile black
Thanks for your answers! As you supposed, I can't upgrade to the SVN version. I will have a look at your code, and try to reproduce it. Actually, I've been a bit stupid because I also thought about modifying the ScreenCaptureHandler class, but directly in the osg build instead of deriving it :O [Arrow] IMHO, the only thing I need to do is to add a bool allowing me to bypass the key pressing, which was what I tried to do on the osg version of ScreenCaptureHandler (and couldn't, because I couldn't modify the header). So I will try this, hoping that this is the good solution because I'm running out of time :/ > I think this sounds like an FAQ problem -- something about JPEG not > supporting the pixel > format you're trying to save. Try saving as a PNG -- it might be something to > do with an > alpha channel or something that JPEG can't handle. Might be, but I don't think so: I also tried others formats not supported, and these were simply empty files, whereas mine is not empty, has the good size but is black. > Well, OpenGL and OSG are complex indeed, but apart from that one problem, I always found a way to accomplish my will ;) -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=26495#26495 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] WriteImageFile black
sumit wrote: > 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 > Unfortunately, I tried today with others formats (png, tga, bmp), and either I got some plugin problems (plugin not found whereas it actually IS at the right place), or I ended with the same black rectangle. Thanks anyways. I just want to thank again [Arrow] Skylark, because I actually managed to derive the ScreenCaptureHandler (not even needed to look at your code) to make it behave how I want. Mine is now taking sequential screenshots during a given time whenever I press the corresponding key. -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=26515#26515 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] WriteImageFile black
Chris 'Xenon' Hanson wrote: > > Do you KNOW the pixel format of your display for sure? It could be something > odd that > most plugins can't handle without conversion. > I'm pretty sure it's good, using GL_RGB; even if that was not the case, I also tried some GL_RGBA, GL_BGRA,... Anyways, after tracing a bit (very hard, I only have release build because of osgART ), I found out that when I was trying to write to file, I actually had the good dimensions but the graphic context I was trying to write was NULL, so no plugin in the world (let's say universe :D ) can managed to fix that ;) -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=26519#26519 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org