source: Swollen/swollen/saveImage.cpp @ 2197

Last change on this file since 2197 was 1965, checked in by darran, 19 years ago
  • fixed flipped y coordinate georeferencing in cylinders.tif test image
  • fixed resultant problem in assigned texture coords
  • hopeful that this solves karratha texture issue ...
File size: 747 bytes
Line 
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
15bool 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
28
29
30   if ( osgDB::writeImageFile(*image, "image.jpg") )
31   {
32      std::cout << "Saved image " << playback_index << std::endl;
33      return true;
34   }
35
36   return false;
37
38}
Note: See TracBrowser for help on using the repository browser.