From b39ff3af6a784cae14f90d22fe83fa8ed78b231e Mon Sep 17 00:00:00 2001 From: Gunnar Sletta Date: Fri, 2 Oct 2009 09:35:56 +0200 Subject: Explicitely check for alpha pixels before creating an alpha GL pixnmap Reviewed-by: Samuel --- src/opengl/qpixmapdata_gl.cpp | 21 +++++++++++++++------ 1 file 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 #include +#include #include +#include + 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(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()); -- cgit v0.12