Hi Paul,
On 23/06/10 11:53 , Paul Pocock wrote:
> I'm trying to write 3d texture data to file but when loading back into
> osg::Image I'm getting rubbish:
>
> Writing to file with 3d texture data:
>
> unsigned int size = image->getTotalSizeInBytesIncludingMipmaps();
> fout.write( (char*)image->data(), size );
>
>
> Reading from file:
>
> unsigned char* data = new unsigned char[texSize*texSize*texSize*4];
> std::ifstream fin("image3ddata2",std::ios::binary);
>
> fin.read((char*)&data ,(sizeof(unsigned char)* 4 * texSize * texSize *
> texSize));
>
> osg::ref_ptr<osg::Image> image = new osg::Image;
> image->setImage(texSize,texSize,texSize,4, GL_RGBA,
> GL_UNSIGNED_BYTE,data, osg::Image::USE_NEW_DELETE);
>
>
> Can anyone see anything I'm doing wrong? Either Writing or Reading?
I cannot spot anything obviously wrong with the code.
Can you check if the file on disk is okay, so that either part (writing or
reading) can be
ruled out?
I'd also try to set the memory to some pattern before reading, in case the file
isn't
fully read or something.
Cheers,
/ulrich
_______________________________________________
osg-users mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org