Added conversion of dataType to GL_UNSIGNED in raw data reading path.
This commit is contained in:
parent
a927d924e1
commit
1cc89ba4fe
@ -977,6 +977,9 @@ osg::Image* readRaw(int sizeX, int sizeY, int sizeZ, int numberBytesPerComponent
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// normalise texture
|
||||
{
|
||||
// compute range of values
|
||||
FindRangeOperator rangeOp;
|
||||
for(int r=0;r<sizeR;++r)
|
||||
@ -995,12 +998,43 @@ osg::Image* readRaw(int sizeX, int sizeY, int sizeZ, int numberBytesPerComponent
|
||||
modifyRow(sizeS, pixelFormat, dataType, image->data(0,t,r), ScaleOperator(1.0f/rangeOp._rmax));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
fin.close();
|
||||
|
||||
if (dataType!=GL_UNSIGNED_BYTE)
|
||||
{
|
||||
// need to convert to ubyte
|
||||
|
||||
osg::ref_ptr<osg::Image> new_image = new osg::Image;
|
||||
new_image->allocateImage(sizeS, sizeT, sizeR, pixelFormat, GL_UNSIGNED_BYTE);
|
||||
|
||||
RecordRowOperator readOp(sizeS);
|
||||
WriteRowOperator writeOp;
|
||||
|
||||
for(int r=0;r<sizeR;++r)
|
||||
{
|
||||
for(int t=0;t<sizeT;++t)
|
||||
{
|
||||
// reset the indices to begining
|
||||
readOp._pos = 0;
|
||||
writeOp._pos = 0;
|
||||
|
||||
// read the pixels into readOp's _colour array
|
||||
readRow(sizeS, pixelFormat, dataType, image->data(0,t,r), readOp);
|
||||
|
||||
// pass readOp's _colour array contents over to writeOp (note this is just a pointer swap).
|
||||
writeOp._colours.swap(readOp._colours);
|
||||
|
||||
modifyRow(sizeS, pixelFormat, GL_UNSIGNED_BYTE, new_image->data(0,t,r), writeOp);
|
||||
|
||||
// return readOp's _colour array contents back to its rightful owner.
|
||||
writeOp._colours.swap(readOp._colours);
|
||||
}
|
||||
}
|
||||
|
||||
image = new_image;
|
||||
}
|
||||
|
||||
return image.release();
|
||||
|
Loading…
Reference in New Issue
Block a user