This is really an OSG question more than a FlightGear question, and I asked about it already over on the OSG forums, but while I'm awaiting approval over there I thought I'd just see if anybody over here had anything to say about it.
I'm still working on my "FlightGear World Server", and the current mission is to replace my (achingly slow) skybox generator. My previous method was to rotate the camera via PropertyTree changes, and save screenshots at each cardinal direction. I finally got through the literature on CameraGroups and Cameras, however, and managed to hook up a set of five cameras which simultaneously record all five desired directions, with the correct field of view.
I'm using viewports to keep these all in the same window, which allows them all to save out in the same screenshot as well, but this is where I run into trouble based on my very limited OpenSceneGraph knowledge. I'd like to open up that saved image, chop it up into five pieces and save them separately. This should be simple enough, I'd just like to verify a couple of assumptions first and see if I'm even close to doing this right.
Question number one: without even getting to the actual task at hand, when I simply try to load the image, as follows:
- Code: Select all
osg::Image *image = osgDB::readImageFile(screenshotPath.c_str());
printf("loaded image! name %s file %s size %d width %d height %d\n",image->getName().c_str(),image->getFileName(),image->getImageSizeInBytes(),image->s(),image->t());
I get a valid filename, but garbage for getImageSizeInBytes as well as the width/height dimensions. Is there something wrong already with the way I'm using readImageFile? The image is present and valid, working fine in other applications. Not sure if my osg::Image is corrupt already or if there is just something wrong with the getImageSizeInBytes etc. functions.
Question number two: when I do get past this and have my image safely loaded, are there any OSG or SG/FG functions to help me copy subsections of this image into other images? Assuming not, does osg::Image::data() give me access to the raw bitmap data, with exactly width*height bytes present? (ie no compression or anything weird at this level?)
ie, could I safely loop through segments of data() on my source image and copy rows of bytes into a new, smaller destination image?
Thanks for any insights!
Cheers,
Chris