[osg-users] how to convert a QPixmap to a osg::Image ?

Jason MacDonald jason.macdonald at ditchwitch.com
Mon May 4 13:15:02 PDT 2015

This is what I do to convert a QImage to osg::Image:

QImage img
    QImage glimg(QGLWidget::convertToGLFormat(img));
    osg::Image* osgImg = new osg::Image;
    unsigned char* bits = new unsigned char[glimg.byteCount()];
    memcpy(bits, glimg.bits(),glimg.byteCount());
    osgImg->setImage(img.width(), img.height(), 1, GL_RGBA, GL_RGBA, GL_UNSIGNED_BYTE, bits, osg::Image::USE_NEW_DELETE);


-----Original Message-----
From: osg-users [mailto:osg-users-bounces at lists.openscenegraph.org] On Behalf Of Lv Qing
Sent: Sunday, May 03, 2015 11:26 AM
To: osg-users at lists.openscenegraph.org
Subject: [osg-users] how to convert a QPixmap to a osg::Image ?


Our picture has storge as a QPixmap(a image format used by QT4.8) in database,when I got a QPixmap object,how to convert to a osg::Image ?

Thank you!


Read this topic online here:

osg-users mailing list
osg-users at lists.openscenegraph.org
This email and any files transmitted with it from The Charles Machine Works, Inc. are confidential and intended solely for the use of the individual or entity to which they are addressed. If you have received this email in error please notify the sender. Our company accepts no liability for the contents of this email, or for the consequences of any actions taken on the basis of the information provided, unless that information is subsequently confirmed in writing. Please note that any views or opinions presented in this email are solely those of the author and do not necessarily represent those of the company. Finally, the recipient should check this email and any attachments for the presence of viruses. The company accepts no liability for any damage caused by any virus transmitted by this email.

More information about the osg-users mailing list