Re: [osg-users] get a Texel from an osg::Image
On Fri, 2008-07-11 at 11:17 +, ka Ming wrote: > Hi, > is there any possibility to get, for example the rgb value, out of an > osg::Image. > data() returns only an unsigned char* > I need or I want an vec3 or with alpha value a vec4 as retrun value. > Is there any solution. > ming osgWidget has a method: osgWidget::Widget::getImageColorAtXY() ...that does something like this if you want to see how I did it. > > __ > Gesendet von Yahoo! Mail. > Dem pfiffigeren Posteingang. > ___ > 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
Re: [osg-users] get a Texel from an osg::Image
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
[osg-users] get a Texel from an osg::Image
Hi, is there any possibility to get, for example the rgb value, out of an osg::Image. data() returns only an unsigned char* I need or I want an vec3 or with alpha value a vec4 as retrun value. Is there any solution. ming __ Gesendet von Yahoo! Mail. Dem pfiffigeren Posteingang. http://de.overview.mail.yahoo.com___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org