#include "utils/ImageUtils.h" #include #include #include #include "common/SpdLogger.h" osg::Image* ImageUtils::readImage(const std::string& filePath) { QImage image(filePath.c_str()); if (image.isNull()) return NULL; image = QGLWidget::convertToGLFormat(image); int nByteCount = image.byteCount(); unsigned char* pData = new unsigned char[nByteCount]; for (int idx = 0; idx < nByteCount; ++idx) { pData[idx] = image.bits()[idx]; } osg::Image* pMarkerImage = new osg::Image(); pMarkerImage->setImage(image.width(), image.height(), 1, 4, GL_RGBA, GL_UNSIGNED_BYTE, pData, osg::Image::USE_NEW_DELETE, 1); return pMarkerImage; }