OSDN Git Service

replace QRasterPixmapData::createPixmapForImage() with its body
authorIvailo Monev <xakepa10@laimg.moc>
Sat, 4 Apr 2020 07:47:52 +0000 (07:47 +0000)
committerIvailo Monev <xakepa10@laimg.moc>
Sat, 4 Apr 2020 07:47:52 +0000 (07:47 +0000)
Signed-off-by: Ivailo Monev <xakepa10@laimg.moc>
src/gui/image/qpixmap_raster.cpp
src/gui/image/qpixmap_raster_p.h

index c459d00..1f7c4bb 100644 (file)
@@ -93,14 +93,56 @@ bool QRasterPixmapData::fromData(const uchar *buffer, uint len, const char *form
     if (image.isNull())
         return false;
 
-    createPixmapForImage(image, flags);
+    fromImage(image, flags);
     return !isNull();
 }
 
 void QRasterPixmapData::fromImage(const QImage &sourceImage,
                                   Qt::ImageConversionFlags flags)
 {
-    createPixmapForImage(sourceImage, flags);
+    QImage::Format format;
+    if (flags & Qt::NoFormatConversion) {
+        format = sourceImage.format();
+    } else if (pixelType() == BitmapType) {
+        format = QImage::Format_MonoLSB;
+    } else {
+        if (sourceImage.depth() == 1) {
+            format = sourceImage.hasAlphaChannel()
+                    ? QImage::Format_ARGB32_Premultiplied
+                    : QImage::Format_RGB32;
+        } else {
+            QImage::Format opaqueFormat = QImage::systemFormat();
+            QImage::Format alphaFormat = QImage::Format_ARGB32_Premultiplied;
+
+            // We don't care about the others...
+            if (opaqueFormat == QImage::Format_RGB16) {
+                alphaFormat = QImage::Format_ARGB8565_Premultiplied;
+            }
+
+            if (!sourceImage.hasAlphaChannel()) {
+                format = opaqueFormat;
+            } else if ((flags & Qt::NoOpaqueDetection) == 0
+                       && !sourceImage.data_ptr()->checkForAlphaPixels())
+            {
+                format = opaqueFormat;
+            } else {
+                format = alphaFormat;
+            }
+        }
+    }
+
+    image = sourceImage.convertToFormat(format);
+
+    if (image.d) {
+        w = image.d->width;
+        h = image.d->height;
+        d = image.d->depth;
+    } else {
+        w = h = d = 0;
+    }
+    is_null = (w <= 0 || h <= 0);
+
+    setSerialNumber(image.cacheKey()  >> 32);
 }
 
 void QRasterPixmapData::fromImageReader(QImageReader *imageReader,
@@ -110,7 +152,7 @@ void QRasterPixmapData::fromImageReader(QImageReader *imageReader,
     if (image.isNull())
         return;
 
-    createPixmapForImage(image, flags);
+    fromImage(image, flags);
 }
 
 // from qwindowsurface.cpp
@@ -261,53 +303,6 @@ int QRasterPixmapData::metric(QPaintDevice::PaintDeviceMetric metric) const
     return 0;
 }
 
-void QRasterPixmapData::createPixmapForImage(const QImage &sourceImage, Qt::ImageConversionFlags flags)
-{
-    QImage::Format format;
-    if (flags & Qt::NoFormatConversion) {
-        format = sourceImage.format();
-    } else if (pixelType() == BitmapType) {
-        format = QImage::Format_MonoLSB;
-    } else {
-        if (sourceImage.depth() == 1) {
-            format = sourceImage.hasAlphaChannel()
-                    ? QImage::Format_ARGB32_Premultiplied
-                    : QImage::Format_RGB32;
-        } else {
-            QImage::Format opaqueFormat = QImage::systemFormat();
-            QImage::Format alphaFormat = QImage::Format_ARGB32_Premultiplied;
-
-            // We don't care about the others...
-            if (opaqueFormat == QImage::Format_RGB16) {
-                alphaFormat = QImage::Format_ARGB8565_Premultiplied;
-            }
-
-            if (!sourceImage.hasAlphaChannel()) {
-                format = opaqueFormat;
-            } else if ((flags & Qt::NoOpaqueDetection) == 0
-                       && !sourceImage.data_ptr()->checkForAlphaPixels())
-            {
-                format = opaqueFormat;
-            } else {
-                format = alphaFormat;
-            }
-        }
-    }
-
-    image = sourceImage.convertToFormat(format);
-
-    if (image.d) {
-        w = image.d->width;
-        h = image.d->height;
-        d = image.d->depth;
-    } else {
-        w = h = d = 0;
-    }
-    is_null = (w <= 0 || h <= 0);
-
-    setSerialNumber(image.cacheKey()  >> 32);
-}
-
 QImage* QRasterPixmapData::buffer()
 {
     return &image;
index fbc4841..e6696cc 100644 (file)
@@ -75,7 +75,6 @@ public:
 
 protected:
     int metric(QPaintDevice::PaintDeviceMetric metric) const;
-    void createPixmapForImage(const QImage &sourceImage, Qt::ImageConversionFlags flags);
     void setImage(const QImage &image);
     QImage image;