HI
 
RGB can be saved to Jpegs straight forwardly using  the jpeg library, never
used the OSG write though always done this myself
you have to make sure you set the right format etc and the image if coming
from OGL may have to be sent bottom to top instead 
of top to bottom
 
Don't have access to code I can post write now
 
G.

  _____  

From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of
Jean-Baptiste Authesserre
Sent: Thursday, April 10, 2008 8:08 AM
To: OpenSceneGraph Users
Subject: Re: [osg-users] osg Image data


Hi,

Have you tried to store your mage in an other format than jpg?
I have also difficulties to store in jpg format. I personally store
screenshots of a 3D scene, and it works well when I use png format, or bmp
format, but not with the jpg format. 

Maybe the libjpeg used by osg don't work with RGB image?

Jean-Baptiste.




2008/4/10, Vincent Bourdier <[EMAIL PROTECTED]>: 

Hi All,

I have a problem concerning writing image data.

My code is simple : 



    const 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] = 0;    //red
        data[i+1] = 0;    //green
        data[i+2] =    0;    //blue
    }

    osg::ref_ptr<osg::Image> image = new osg::Image;
    image->allocateImage(_x, _y, 1, GL_RGB, GL_UNSIGNED_SHORT);
    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_SHORT, data,
osg::Image::NO_DELETE);

    osgDB::writeImageFile(*image, "Z:/autres/Gradient.jpg");




the result must be a black picture... but I've a totally different result
(see attached file)

Does anyone see a mistake ?

Thanks.

Regards,
   Vincent.

_______________________________________________
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org





_______________________________________________
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

Reply via email to