It looks better !

I didn't understood what the difference between the NO_DELETE,
USE_NEW_DELETE, ... but now I know how to use it.

I cannot make all my tests now, but for the moment It work better, without
error.

Thanks a lot for your help.  :-)

Regard.
   Vincent.

2008/4/11, Ralph Kern <[EMAIL PROTECTED]>:
>
> You mix up memory allocated with malloc/calloc/realloc and those with
> new / delete:
>
> the guilty lines are:
>
>
>   >         unsigned char* data = (unsigned char*)calloc(size,
>   >     sizeof(unsigned char));
>
>
> opposed to
>
>
>   >         image->setImage(_x, _y, 1, GL_RGB, GL_RGB, GL_UNSIGNED_BYTE,
>   >     data, osg::Image::USE_NEW_DELETE);
>
>
> Do you see USE_NEW_DELETE? it tells the image to do cleanup using
>         delete [] data;
>
> You should allocate your data using
>         unsigned char *data = new unsigned char[size];
>
> regards Ralph
>
> Vincent Bourdier schrieb:
>
> > Ok, this is the code, without all the pixel color computation :
> >
> >         long size = _x*_y*3;
> >
> >         unsigned char* data = (unsigned char*)calloc(size,
> >     sizeof(unsigned char));
> >
> >         for(long i=0; i < size ; i+= 3)
> >         {
> >
> >             [...]
> >
> >             data[i] = color;    //red
> >             data[i+1] = color;    //green
> >             data[i+2] =    color;    //blue
> >         }
> >
> >         osg::Image* image = new osg::Image;
> >         image->allocateImage(_x, _y, 1, GL_RGB, GL_UNSIGNED_BYTE);
> >         image->setOrigin(osg::Image::BOTTOM_LEFT);//start counting
> >     pixels on the Bottom left of the picture
> >         image->setImage(_x, _y, 1, GL_RGB, GL_RGB, GL_UNSIGNED_BYTE,
> >     data, osg::Image::USE_NEW_DELETE);
> >
> >         osgDB::writeImageFile(*image, "Z:/autres/Gradient.jpg");
> >
> >
> > Thanks for help.
> >
>
>
> _______________________________________________
> osg-users mailing list
> [email protected]
> http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
>
_______________________________________________
osg-users mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

Reply via email to