Ming,

So long as you know that the image format is GL_RGBA8, and 2D, you can do
something like:

osg::Vec4 returnColour(int row, int col)
{
        unsigned char*  pSrc  = (unsigned char*)  image->data(row,col);
        float r = (float) *pSrc++/255.0f;
        float g = (float) *pSrc++/255.0f;
        float b = (float) *pSrc++/255.0f;
        float a = (float) *pSrc++/255.0f;
        return osg::Vec4(r,g,b,a);
}

If you are not in control of the image's format then you should check
whether it is RGB or RGBA before trying to get alpha, and also whether it is
RGBA8 and not (for example) RGBA16F, or RGBA32F, or something slighly more
esoteric.

Hope that helps,

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

Reply via email to