Hi Daniel,

On 10/06/11 15:56 , Daniel Cámpora wrote:
> I'd like to use the image loaders OSG implements. I've succesfully fetched 
> images from
> web links and my own HD. However, now I'm trying to do the same with an image 
> stored in
> a string, in main memory.
> 
> My OSG version is 2.9.9. The extension for the file is png, and considering s 
> is the
> string containing the image, I've tried the following portion of code:
> 
> Code: osg::ref_ptr<osg::Image> image;
> osgDB::ReaderWriter* rw = 
> osgDB::Registry::instance()->getReaderWriterForExtension("png");
> if (rw) { 
>     osgDB::ReaderWriter::ReadResult rr = rw->readImage(s);
>     if ( rr.success() )
>         image = rr.takeImage();
> }

None of the plugins support reading from a string (a string is always 
interpreted as a
file name), but some support reading from a stream, which can be a stringstream.

Try (from memory):
std::stringstream ss(s);
rw->readImage(ss);

Cheers,
/ulrich
_______________________________________________
osg-users mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

Reply via email to