All, Thank you in advance. My application needs to capture an image (that part works), turn parts of it transparent (that part doesn’t), and redisplay the image. I have the capture working, and, with a workaround, I have the transparency working. The problem is that the workaround involves writing the image to a file, and reading it back. Surely there is a better way than that. I’m sure that I’m missing something, probably something simple…
Here’s the main snippet: Code: // I read in the bitmap, without transparency. ref_ptr<Image> image = osgDB::readImageFile( "Ball.bmp"); // As expected, we do not see transparency. { ref_ptr<osgViewer::Viewer> viewer = new osgViewer::Viewer(); viewer ->setSceneData( makeGeode( image).get()); viewer->run(); } // I convert the image to an RGBA format, if necessary, and set the alpha (black is transparent). My_OSG_Library::ConvertImageColorToAlphaValue( image); // But, the image is still opaque! { ref_ptr<osgViewer::Viewer> viewer = new osgViewer::Viewer(); viewer ->setSceneData( makeGeode( image).get()); viewer->run(); } // I check the image by writing it out to an .rgba file... osgDB::writeImageFile( * image, "Ball.rgba"); // Since it checks, I read it back in... image = osgDB::readImageFile( "Ball.rgba"); // And, voila! The transparency works! { ref_ptr<osgViewer::Viewer> viewer = new osgViewer::Viewer(); viewer ->setSceneData( makeGeode( image).get()); viewer->run(); } My function, ConvertImageColorToAlphaValue, is apparently setting the alpha values correctly. I’ve checked Ball.rgba, using gimp, and the black corners are transparent, as expected. But, image doesn’t render transparently until I read it back in. So, my first question is: What needs to change in the image to “activate” transparency? My second question… If you look at my “helper” class, OSG_PixelComponent, which I implemented to examine color values, and set the alpha values, does get the job done… I suspect that there is a better way to do this, though, and I’m wondering what that would be. Thanks again, Phil Philip A. Tessier ------------------ Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=32421#32421 Attachments: http://forum.openscenegraph.org//files/ball_142.bmp http://forum.openscenegraph.org//files/osg_transparency_demo_405.cpp _______________________________________________ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org