In order to use a limit of 255, I needed to use GL_UNSIGNED_BYTE (char)

Code:

        int height=100;
        int width=100;
        int length=100;
        const long size = width*height*length*3;

        unsigned char* data = (unsigned char*)calloc(size,sizeof(unsigned 
char));

        for(long i=0; i < size ; i+= 3)
        {
                data[i] = 255;    //red
                data[i+1] = 0;    //green
                data[i+2] = 0;    //blue
        }

        osg::ref_ptr<osg::Image> image = new osg::Image;
        image->allocateImage(width, height, length, GL_RGB, GL_UNSIGNED_BYTE);
        image->setOrigin(osg::Image::BOTTOM_LEFT);//start countingpixels on the 
Bottom left of the picture
        image->setImage(width, height, length , GL_RGB, GL_RGB, 
GL_UNSIGNED_BYTE,data, osg::Image::NO_DELETE);

        osgDB::writeImageFile(*image, "test.jpg");




------------------
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=21589#21589





_______________________________________________
osg-users mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

Reply via email to