Hi Clement, On 1/09/11 10:34 , [email protected] wrote: > Hi Ulrich, > > The code for reading file is my testing data and I copied the data from one > format to > unsigned char format, so the file won't contain more data than I expected.
So you are reading exactly nx*ny*nz bytes? > 1. when i changed to malloc(nx * ny * nz * 8 * (sizeof(unsigned char))), it > works, but it doesn't work if I changed 8 to 4. What happens when you specify *8? That might indicate that you're reading more data than you expect. > 2. why I need to assign the memory with data's size * 8. is it for RBGA > each 2 bit extra data? If the data you're reading is indeed RGBA data then the buffer size should be (nx*ny*nz*4). I don't know enough about your application or your data to help you there. > 3. why osg will excess the data I assigned into Image? I guess osg is just > reading from the data I assigned only. Yes, but if you tell it the the data in the buffer is (nx*ny*nz, RGBA, UNSIGNED BYTE) it's expecting to find (nx*ny*nz*4) bytes in that buffer (4 channels [RGBA], one unsigned byte per channel). > 4. what is the different between osg::Image::NO_DELETE, > osg::Image::USE_NEW_DELETE and osg::Image::USE_MALLOC_FREE? NO_DELETE means OSG won't touch the data and you are responsibile to release the buffer when it's no longer needed. USE_NEW_DELETE means OSG will use new[] and delete[] to release the buffer. USE_MALLOC_FREE means OSG will use malloc() and free() to release the buffer. Since you're using malloc() you might want to use USE_MALLOC_FREE but again, that depends on your application. Cheers, /ulrich _______________________________________________ osg-users mailing list [email protected] http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

