Hi,

I updated the code as follows.


Code:

wxImageHandler * tgaLoader = new wxJPEGHandler();
wxImage::AddHandler(tgaLoader);
wxImage wximage;
wximage.LoadFile(_T("/home/lahiru/Pictures/IMG_6064.JPG"), wxBITMAP_TYPE_JPEG);

wxMemoryOutputStream img_data(NULL,0);
wximage.SaveFile(img_data,wxBITMAP_TYPE_JPEG);
wxStreamBuffer* output_buffer = img_data.GetOutputStreamBuffer();
int length = output_buffer->GetDataLeft();
char buffer[length];
output_buffer->Read(buffer,length);

std::stringstream ss;
ss.write(buffer,length);

osgDB::ReaderWriter* plugin = 
osgDB::Registry::instance()->getReaderWriterForExtension("JPEG");
osgDB::ReaderWriter::ReadResult result = plugin->readImage(ss);

osg::Image* klnFace = result.getImage();




However, for some reason, output_buffer->GetDataLeft(); returns 0.

In the actual use case, I have to convert a wxBitmap into an osg::Image to 
apply it as a texture. I will try to save the wxImage as a file and load it 
into an osg::image for the time being.

I really appreciate some help on this.

Thank you!

Best Regards,
Lahiru

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





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

Reply via email to