Rev | Line | |
---|
[125] | 1 | /* |
---|
| 2 | SWWViewer |
---|
| 3 | |
---|
| 4 | An OpenSceneGraph viewer for pyVolution SWW files. |
---|
| 5 | copyright (C) 2004-2005 Geoscience Australia |
---|
| 6 | */ |
---|
| 7 | |
---|
| 8 | #include <iostream> |
---|
| 9 | #include <osg/Image> |
---|
| 10 | #include <osgDB/WriteFile> |
---|
| 11 | #include <osgDB/FileNameUtils> |
---|
| 12 | #include <customviewer.h> |
---|
| 13 | |
---|
| 14 | |
---|
| 15 | bool saveImage(unsigned int playback_index, CustomViewer viewer, std::string moviedir) |
---|
| 16 | { |
---|
| 17 | |
---|
| 18 | int x, y; |
---|
| 19 | unsigned int width, height; |
---|
| 20 | |
---|
| 21 | viewer.getCamera(0)->getProjectionRectangle(x, y, width, height); |
---|
| 22 | |
---|
| 23 | osg::ref_ptr<osg::Image> image = new osg::Image; |
---|
| 24 | |
---|
| 25 | image->readPixels(x, y, width, height, GL_RGB, GL_UNSIGNED_BYTE); |
---|
| 26 | |
---|
| 27 | if ( osgDB::writeImageFile(*image, "image.jpg") ) |
---|
| 28 | { |
---|
| 29 | std::cout << "Saved image " << playback_index << std::endl; |
---|
| 30 | return true; |
---|
| 31 | } |
---|
| 32 | |
---|
| 33 | return false; |
---|
| 34 | |
---|
| 35 | } |
---|
Note: See
TracBrowser
for help on using the repository browser.