Hi all,

After trying for few hours, I was able to convert the wxImage into an 
osg:Image, and apply it as a texture.

I am posting the code below as it might help someone else as well.


Code:

wxBitmap bmp(wximage);
wxNativePixelData data(bmp);

wxNativePixelData::Iterator p(data);

osg::Image* klnFace = new osg::Image();
int tex_width = data.GetWidth();
int tex_height = data.GetHeight();
klnFace->allocateImage(tex_width, tex_height, 1, GL_RGBA, GL_FLOAT);

float* img_data = (float*)klnFace->data();
for (unsigned i = 0; (i < tex_height); i++) {
        for (unsigned j = 0; (j < tex_width); j++) {
            int ind = i*tex_width + j;
            img_data[ind*4]   = p.Red()/255.0;
            img_data[ind*4+1] = p.Green()/255.0;
            img_data[ind*4+2] = p.Blue()/255.0;
            img_data[ind*4+3] = 1.0;

            p.MoveTo(data, j, tex_height-1-i);
        }
}




I used wxNativePixelData to access the raw image data.

Thank you!

Cheers,
Lahiru

------------------
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=32330#32330





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

Reply via email to