HI Vincent
On Fri, Apr 11, 2008 at 9:04 AM, Vincent Bourdier
<[EMAIL PROTECTED]> wrote:
> I have a VS bug :
>
> Windows a déclenché un point d'arrêt dans 3DEM.exe.
> Cela peut être dû à une défaillance du tas et indique un bogue dans 3DEM.exe
> ou l'une des DLL chargées.
> La fenêtre Sortie peut contenir des informations de diagnostic
> supplémentaires
This indicates that your application has corrupted the heap, most
probably by writing out the bounds of a buffer. It is not a "VS bug",
it is just Visual Studio (actually, the debug CRT) telling you that
you did something wrong.
> But If I put in comment the previous lines of my code, no bug appears...
> Is there any important bug which have been resolved from the last realease
> (OSG 2.2) in osg::Image ?
The osg::Image class is robust and does not have bug AFAIK, so your
code is certainly guilty.
> Any ideas ?
I'd bet on a difference between the buffer size osg::Image::setImage()
expects and the buffer you actually give it.
There is no guarantee that the actual size of the data for an RGB
image is 3*width*height, because the memory layout might be different
- there can be padding zero bytes at the end of each line if your
dimensions are not powers of two.
You should compute the actual line length (which is >= width) and
multiply it by the height to get the actual buffer size needed. For
instance, somewhere in my code I have a function that extracts a
sub-image from an osg::Image that goes like this:
osg::Image* createSubImage(const osg::Image* source, int src_s, int
src_t, int width, int height)
{
assert(source);
int padding = source->getPixelSizeInBits()/8;
int rowSize = width * padding;
Buffer<unsigned char> dest_data(rowSize * height); // This is a
wrapper around unsigned char* that allocates the desired size and
frees the pointer when it goes out of scope
for (int i=0;i<height;i++)
{
memcpy(&dest_data[rowSize*i], source->data(src_s, src_t+i),
rowSize);
}
osg::Image* dest = new osg::Image;
dest->setImage(width, height, 1,
source->getInternalTextureFormat(),
source->getPixelFormat(),
source->getDataType(),
dest_data.detach(), // Steal the data pointer from the Buffer<>
so
that it is now owned by the new osg::Image
osg::Image::USE_NEW_DELETE);
return dest;
}
Hope this helps
Regards
Thibault
_______________________________________________
osg-users mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org