diff --git a/src/gui/image/qimage_conversions.cpp b/src/gui/image/qimage_conversions.cpp
index 28e3a48689ca5b1be68f9e133067a369952adde4..e1be0322155631c20fdc58a44720d36f3913f83d 100644
--- a/src/gui/image/qimage_conversions.cpp
+++ b/src/gui/image/qimage_conversions.cpp
@@ -557,7 +557,7 @@ static inline uint qUnpremultiplyRgb30(uint rgb30)
     }
     case 2: {
         uint rgb = rgb30 & 0x3fffffff;
-        rgb += rgb >> 1;
+        rgb += (rgb >> 1) & 0x5ff7fdff;
         return (a << 30) | rgb;
     }
     case 3:
@@ -2348,10 +2348,10 @@ Image_Converter qimage_converter_map[QImage::NImageFormats][QImage::NImageFormat
         0,
         0,
         0,
+        0,
         convert_BGR30_to_RGB30,
         convert_BGR30_to_RGB30,
         0,
-        0,
         convert_passthrough,
         0, 0
     }, // Format_RGB30
diff --git a/tests/auto/gui/image/qimage/tst_qimage.cpp b/tests/auto/gui/image/qimage/tst_qimage.cpp
index 51e4c6233eedb5e1f0829518afaa387e137255d3..266230de387f101672655354350052381fbd6f80 100644
--- a/tests/auto/gui/image/qimage/tst_qimage.cpp
+++ b/tests/auto/gui/image/qimage/tst_qimage.cpp
@@ -183,6 +183,7 @@ private slots:
     void cleanupFunctions();
 
     void devicePixelRatio();
+    void rgb30Unpremul();
 
     void metadataPassthrough();
 
@@ -2829,6 +2830,20 @@ void tst_QImage::devicePixelRatio()
     QCOMPARE(b.devicePixelRatio(), qreal(1.0));
 }
 
+void tst_QImage::rgb30Unpremul()
+{
+    QImage a(3, 1, QImage::Format_A2RGB30_Premultiplied);
+    ((uint*)a.bits())[0] = (3U << 30) | (128 << 20) | (256 << 10) | 512;
+    ((uint*)a.bits())[1] = (2U << 30) | (131 << 20) | (259 << 10) | 515;
+    ((uint*)a.bits())[2] = (1U << 30) | ( 67 << 20) | (131 << 10) | 259;
+
+    QImage b = a.convertToFormat(QImage::Format_RGB30);
+    const uint* bbits = (const uint*)b.bits();
+    QCOMPARE(bbits[0], (3U << 30) | (128 << 20) | (256 << 10) | 512);
+    QCOMPARE(bbits[1], (3U << 30) | (196 << 20) | (388 << 10) | 772);
+    QCOMPARE(bbits[2], (3U << 30) | (201 << 20) | (393 << 10) | 777);
+}
+
 void tst_QImage::metadataPassthrough()
 {
     QImage a(64, 64, QImage::Format_ARGB32);