void QGLPixmapData::fromNativeType(void* pixmap, NativeType type) { if (type == QPixmapData::SgImage && pixmap) { #if defined(QT_SYMBIAN_SUPPORTS_SGIMAGE) && !defined(QT_NO_EGL) RSgImage *sgImage = reinterpret_cast<RSgImage*>(pixmap); m_sgImage = new RSgImage; m_sgImage->Open(sgImage->Id()); TSgImageInfo info; sgImage->GetInfo(info); w = info.iSizeInPixels.iWidth; h = info.iSizeInPixels.iHeight; d = symbianPixeFormatBitsPerPixel((TUidPixelFormat)info.iPixelFormat); m_source = QVolatileImage(); m_hasAlpha = true; m_hasFillColor = false; m_dirty = true; is_null = (w <= 0 || h <= 0); #endif } else if (type == QPixmapData::FbsBitmap && pixmap) { CFbsBitmap *bitmap = reinterpret_cast<CFbsBitmap *>(pixmap); QSize size(bitmap->SizeInPixels().iWidth, bitmap->SizeInPixels().iHeight); if (size.width() == w && size.height() == h) setSerialNumber(++qt_gl_pixmap_serial); resize(size.width(), size.height()); m_source = QVolatileImage(bitmap); if (pixelType() == BitmapType) { m_source.ensureFormat(QImage::Format_MonoLSB); } else if (!knownGoodFormat(m_source.format())) { m_source.beginDataAccess(); QImage::Format format = idealFormat(m_source.imageRef(), Qt::AutoColor); m_source.endDataAccess(true); m_source.ensureFormat(format); } m_hasAlpha = m_source.hasAlphaChannel(); m_hasFillColor = false; m_dirty = true; d = m_source.depth(); } else if (type == QPixmapData::VolatileImage && pixmap) { // Support QS60Style in more efficient skin graphics retrieval. QVolatileImage *img = static_cast<QVolatileImage *>(pixmap); if (img->width() == w && img->height() == h) setSerialNumber(++qt_gl_pixmap_serial); resize(img->width(), img->height()); m_source = *img; m_hasAlpha = m_source.hasAlphaChannel(); m_hasFillColor = false; m_dirty = true; d = m_source.depth(); } else if (type == QPixmapData::NativeImageHandleProvider && pixmap) { destroyTexture(); nativeImageHandleProvider = static_cast<QNativeImageHandleProvider *>(pixmap); // Cannot defer the retrieval, we need at least the size right away. createFromNativeImageHandleProvider(); } }
void QVGPixmapData::fromNativeType(void* pixmap, NativeType type) { if (type == QPixmapData::SgImage && pixmap) { #if defined(QT_SYMBIAN_SUPPORTS_SGIMAGE) && !defined(QT_NO_EGL) RSgImage *sgImage = reinterpret_cast<RSgImage*>(pixmap); destroyImages(); prevSize = QSize(); vgImage = sgImageToVGImage(context, *sgImage); if (vgImage != VG_INVALID_HANDLE) { w = vgGetParameteri(vgImage, VG_IMAGE_WIDTH); h = vgGetParameteri(vgImage, VG_IMAGE_HEIGHT); d = 32; // We always use ARGB_Premultiplied for VG pixmaps. } is_null = (w <= 0 || h <= 0); source = QVolatileImage(); // readback will be done later, only when needed recreate = false; prevSize = QSize(w, h); updateSerial(); #endif } else if (type == QPixmapData::FbsBitmap && pixmap) { CFbsBitmap *bitmap = reinterpret_cast<CFbsBitmap *>(pixmap); QSize size(bitmap->SizeInPixels().iWidth, bitmap->SizeInPixels().iHeight); resize(size.width(), size.height()); source = QVolatileImage(bitmap); // duplicates only, if possible if (source.isNull()) return; if (!conversionLessFormat(source.format())) { // Here we may need to copy if the formats do not match. // (e.g. for display modes other than EColor16MAP and EColor16MU) source.beginDataAccess(); QImage::Format format = idealFormat(&source.imageRef(), Qt::AutoColor); source.endDataAccess(true); source.ensureFormat(format); } recreate = true; } else if (type == QPixmapData::VolatileImage && pixmap) { QVolatileImage *img = static_cast<QVolatileImage *>(pixmap); resize(img->width(), img->height()); source = *img; recreate = true; } else if (type == QPixmapData::NativeImageHandleProvider && pixmap) { destroyImages(); nativeImageHandleProvider = static_cast<QNativeImageHandleProvider *>(pixmap); // Cannot defer the retrieval, we need at least the size right away. createFromNativeImageHandleProvider(); } }
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(); }