Added futher use of readSize/writeSize.

This commit is contained in:
Robert Osfield 2010-02-11 09:13:33 +00:00
parent 725258ea54
commit eac767d494
2 changed files with 6 additions and 6 deletions

View File

@ -524,7 +524,7 @@ osg::Image* InputStream::readImage()
} }
// _mipmapData // _mipmapData
unsigned int levelSize = 0; *this >> levelSize; unsigned int levelSize = readSize();
osg::Image::MipmapDataType levels(levelSize); osg::Image::MipmapDataType levels(levelSize);
for ( unsigned int i=0; i<levelSize; ++i ) for ( unsigned int i=0; i<levelSize; ++i )
{ {
@ -538,7 +538,7 @@ osg::Image* InputStream::readImage()
case IMAGE_INLINE_FILE: case IMAGE_INLINE_FILE:
if ( isBinary() ) if ( isBinary() )
{ {
unsigned int size = 0; *this >> size; unsigned int size = readSize();
if ( size>0 ) if ( size>0 )
{ {
char* data = new char[size]; char* data = new char[size];

View File

@ -355,11 +355,11 @@ void OutputStream::writeImage( const osg::Image* img )
*this << img->getDataType(); // _dataType *this << img->getDataType(); // _dataType
*this << img->getPacking(); // _packing *this << img->getPacking(); // _packing
*this << img->getAllocationMode(); // _allocationMode *this << img->getAllocationMode(); // _allocationMode
// _data // _data
unsigned int size = img->getTotalSizeInBytesIncludingMipmaps(); unsigned int size = img->getTotalSizeInBytesIncludingMipmaps();
*this << size; writeCharArray( (char*)img->data(), size ); writeSize(size); writeCharArray( (char*)img->data(), size );
// _mipmapData // _mipmapData
const osg::Image::MipmapDataType& levels = img->getMipmapLevels(); const osg::Image::MipmapDataType& levels = img->getMipmapLevels();
writeSize(levels.size()); writeSize(levels.size());
@ -379,7 +379,7 @@ void OutputStream::writeImage( const osg::Image* img )
{ {
infile.seekg( 0, std::ios::end ); infile.seekg( 0, std::ios::end );
unsigned int size = infile.tellg(); unsigned int size = infile.tellg();
*this << size; writeSize(size);
if ( size>0 ) if ( size>0 )
{ {