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.

Vincent.

2008/4/11, Stephan Huber <[EMAIL PROTECTED]>:
>
> Vincent Bourdier schrieb:
>
> > If x*y*3 is not the good solution, how can I compute the right size for
> a
> > RGB image ?
>
>
> please show us the complete code. The chance is high that you write out
> of the bounds of your created picture. Creating osg::Images from scratch
> is possible, I do this a lot in my own code.
>
> cheers,
>
> Stephan
>
> _______________________________________________
> 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