osg Image 保存图片测试

// test for read image
osg::ref_ptr texture2d = new osg::Texture2D;
osg::ref_ptr img = new osg::Image;
img=osgDB::readImageFile("C:\\Users\\Public\\Pictures\\Sample Pictures\\Tulips.jpg");
osg::ref_ptr img2 = new osg::Image;
img2->setImage(img->s(),img->t(),img->r(),img->getInternalTextureFormat(),img->getPixelFormat(),img->getDataType(),img->data(),img->getAllocationMode());
osgDB::writeImageFile(*img2,"img2.jpg");
osgDB::writeImageFile(*img,"abc.jpg");
texture2d->setImage(img);

你可能感兴趣的:(OSG)