Hello,

I have make a new message, because I replied another message and it was not so good. I hope this is ok.

Ok, back to my problem.
Mourad thanks for your help. I try it and it seems that I lose the half image information. When I have a image 12 x 12 I get a image 6x6. I think the problem is that the unsigned char* can only handle 8 bits.

Cheers,

Martin


Am 29.07.2009 15:58, schrieb Mourad Boufarguine:
Rather I would do this :

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

for(long i=0; i < size ; i+= 3)
{
    data[i]     =  65535;    //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_SHORT);
image->setOrigin(osg::Image::BOTTOM_LEFT);
image->setImage(width, height, 1, GL_RGB, GL_RGB, GL_UNSIGNED_SHORT, (unsigned char*)data, osg::Image::NO_DELETE);

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


Mourad


2009/7/29 Martin Großer <grosser.mar...@gmx.de <mailto:grosser.mar...@gmx.de>>

    Hello Mourad,

    ok, I can change it to GL_UNSIGNED_SHORT and I can change the
    internal pixel format to GL_RGB16, but the data value is a pointer
    to a unsigned char.  Unsigned char is also 8 bit and not 16 bit?

    Here the changed version:


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

    for(long i=0; i < size ; i+= 3)
    {
        data[i]     =  65535;    //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_SHORT);
    image->setOrigin(osg::Image::BOTTOM_LEFT);
    image->setImage(width, height, 1, GL_RGB16, GL_RGB16,
    GL_UNSIGNED_SHORT, data, osg::Image::NO_DELETE);

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


    What type is possible for the data value? And what happens when I
    use GL_FLOAT? There are 32 bits?
    My main problem is, I don't understand the data value.


    Cheers,

    Martin


    Am 29.07.2009 13:25, schrieb Mourad Boufarguine:
    Martin,

    And for the second question, yes, you can use 16 bits per
    channel. GL_UNSIGNED_BYTE means 8 bits per channel, so
    GL_UNSIGNED_SHORT is for 16 bits.

    Mourad

    2009/7/29 Martin Großer <grosser.mar...@gmx.de
    <mailto:grosser.mar...@gmx.de>>

        Year! That is right. I feel awful about this mistake.

        First I try GL_FLOAT and I forget to change the value from 1
        to 255.
        Thanks for your help.

        Martin

        Am 29.07.2009 11:39, schrieb David Spilling:
        Martin,

        I think you want this:

               data[i]     = 255;    //red


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



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


    ------------------------------------------------------------------------

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


    _______________________________________________
    osg-users mailing list
    osg-users@lists.openscenegraph.org
    <mailto: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

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

Reply via email to