[osg-users] How to render the image without reducing its size.?

Uma Devi Selvaraj umaselvam1503 at gmail.com
Tue Nov 22 04:58:18 PST 2016


Hi,

   I have simple code that renders image using osgviewer. I am able to render the image successfully with the code. My problem now is the size of the image is reduced. for example the original size of the image is 4683 * 3035, the image is reduced to 4096 * 3035. Is this expected behaviour or is there anything I need to add in my code. I have added my code.


//required header files

int main(int argc,char**argv)
{

	osg::ref_ptr<osg::Image> image;
    image = osgDB::readImageFile("C:\\Users\\mcw\\Desktop\\DemModel.tif.gdal");
	std::cout << "Image info are " << image->s() << "\n" <<image->t() <<"\n" <<image->r() << std::endl;
	if (!(image.valid()))
	{
		std::cout << "Unable to read image file " << std::endl;
		getchar();
		return 0;
	}
	
	osg::ref_ptr<osg::Geode> geode =(osg::createGeodeForImage(image));
	
	osg::Texture2D *texture = new osg::Texture2D();
	texture->setFilter(osg::Texture::MIN_FILTER, osg::Texture::LINEAR);
	texture->setFilter(osg::Texture::MAG_FILTER, osg::Texture::LINEAR);
	texture->setWrap(osg::Texture::WRAP_R, osg::Texture::REPEAT);
	texture->setResizeNonPowerOfTwoHint(false);
	texture->setImage(image);
	texture->setBorderColor(osg::Vec4d(0.4f, 0.5f, 0.6f, 1.0f));
	osg::StateSet* stateset = new osg::StateSet;

	stateset->setTextureAttributeAndModes(0, texture, osg::StateAttribute::ON);
	
	geode->setStateSet(stateset);
	osgViewer::Viewer viewer;
	viewer.setSceneData(geode.get());
	getchar();
	return viewer.run();

}

... 

Thank you!

Cheers,
Uma

------------------
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=69470#69470








More information about the osg-users mailing list