/*! out-of-place conversion (inPlace == false) will always detach() */ void QGLPixmapData::createPixmapForImage(QImage &image, Qt::ImageConversionFlags flags, bool inPlace) { if (image.size() == QSize(w, h)) setSerialNumber(++qt_gl_pixmap_serial); resize(image.width(), image.height()); if (pixelType() == BitmapType) { m_source = image.convertToFormat(QImage::Format_MonoLSB); } else { QImage::Format format = QImage::Format_RGB32; if (qApp->desktop()->depth() == 16) format = QImage::Format_RGB16; if (image.hasAlphaChannel() && ((flags & Qt::NoOpaqueDetection) || const_cast<QImage &>(image).data_ptr()->checkForAlphaPixels())) format = QImage::Format_ARGB32_Premultiplied;; if (inPlace && image.data_ptr()->convertInPlace(format, flags)) { m_source = image; } else { m_source = image.convertToFormat(format); // convertToFormat won't detach the image if format stays the same. if (image.format() == format) m_source.detach(); } } m_dirty = true; m_hasFillColor = false; m_hasAlpha = m_source.hasAlphaChannel(); w = image.width(); h = image.height(); is_null = (w <= 0 || h <= 0); d = m_source.depth(); if (m_texture.id) { QGLShareContextScope ctx(qt_gl_share_context()); glDeleteTextures(1, &m_texture.id); m_texture.id = 0; } }
void QVGPixmapData::createPixmapForImage(QImage &image, Qt::ImageConversionFlags flags, bool inPlace) { resize(image.width(), image.height()); QImage::Format format = idealFormat(&image, flags); if (inPlace && image.data_ptr()->convertInPlace(format, flags)) { source = QVolatileImage(image); } else { QImage convertedImage = image.convertToFormat(format); // convertToFormat won't detach the image if format stays the // same. Detaching is needed to prevent issues with painting // onto this QPixmap later on. convertedImage.detach(); source = QVolatileImage(convertedImage); } recreate = true; }
void QGLPixmapData::createPixmapForImage(QImage &image, Qt::ImageConversionFlags flags, bool inPlace) { if (image.size() == QSize(w, h)) setSerialNumber(++qt_gl_pixmap_serial); resize(image.width(), image.height()); if (pixelType() == BitmapType) { QImage convertedImage = image.convertToFormat(QImage::Format_MonoLSB); if (image.format() == QImage::Format_MonoLSB) convertedImage.detach(); m_source = QVolatileImage(convertedImage); } else { QImage::Format format = idealFormat(image, flags); if (inPlace && image.data_ptr()->convertInPlace(format, flags)) { m_source = QVolatileImage(image); } else { QImage convertedImage = image.convertToFormat(format); // convertToFormat won't detach the image if format stays the same. if (image.format() == format) convertedImage.detach(); m_source = QVolatileImage(convertedImage); } } m_dirty = true; m_hasFillColor = false; m_hasAlpha = m_source.hasAlphaChannel(); w = image.width(); h = image.height(); is_null = (w <= 0 || h <= 0); d = m_source.depth(); destroyTexture(); }