diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/opengl/qpixmapdata_gl.cpp | 21 |
1 files changed, 15 insertions, 6 deletions
diff --git a/src/opengl/qpixmapdata_gl.cpp b/src/opengl/qpixmapdata_gl.cpp index 2331c6d..dc7aa81 100644 --- a/src/opengl/qpixmapdata_gl.cpp +++ b/src/opengl/qpixmapdata_gl.cpp @@ -48,9 +48,12 @@ #include <private/qgl_p.h> #include <private/qdrawhelper_p.h> +#include <private/qimage_p.h> #include <private/qpaintengineex_opengl2_p.h> +#include <qdesktopwidget.h> + QT_BEGIN_NAMESPACE extern QGLWidget* qt_gl_share_widget(); @@ -315,7 +318,7 @@ void QGLPixmapData::ensureCreated() const } void QGLPixmapData::fromImage(const QImage &image, - Qt::ImageConversionFlags) + Qt::ImageConversionFlags flags) { if (image.size() == QSize(w, h)) setSerialNumber(++qt_gl_pixmap_serial); @@ -323,20 +326,26 @@ void QGLPixmapData::fromImage(const QImage &image, if (pixelType() == BitmapType) { m_source = image.convertToFormat(QImage::Format_MonoLSB); + } else { - m_source = image.hasAlphaChannel() - ? image.convertToFormat(QImage::Format_ARGB32_Premultiplied) - : image.convertToFormat(QImage::Format_RGB32); + QImage::Format format = QImage::Format_RGB32; + if (qApp->desktop()->depth() == 16) + format = QImage::Format_RGB16; + + if (image.hasAlphaChannel() && const_cast<QImage &>(image).data_ptr()->checkForAlphaPixels()) + format = QImage::Format_ARGB32_Premultiplied;; + + m_source = image.convertToFormat(format); } m_dirty = true; m_hasFillColor = false; - m_hasAlpha = image.hasAlphaChannel(); + m_hasAlpha = m_source.hasAlphaChannel(); w = image.width(); h = image.height(); is_null = (w <= 0 || h <= 0); - d = pixelType() == QPixmapData::PixmapType ? 32 : 1; + d = m_source.depth(); if (m_texture.id) { QGLShareContextScope ctx(qt_gl_share_widget()->context()); |