Hello,

I would like create a Image. I read the mail "osg Image data" in the archive of the mailing list. And I try it:


const long size = width*height*3;
unsigned char* data = (unsigned char*)calloc(size, sizeof(unsigned char));

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

// image
osg::ref_ptr<osg::Image> image = new osg::Image;
image->allocateImage(width, height, 1, GL_RGB, GL_UNSIGNED_BYTE);
image->setOrigin(osg::Image::BOTTOM_LEFT);
image->setImage(width, height, 1, GL_RGB, GL_RGB, GL_UNSIGNED_BYTE, data, osg::Image::NO_DELETE);

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

But it doesn't work. I get a black image. What is my mistake?


And one more question. GL_UNSIGNED_BYTE means 8 bits per component (r,g,b). Right? I would like use 16 bits or more per component. Is it possible?

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

Reply via email to