Index: /trunk/src/gui/image/qpixmap.h
===================================================================
--- /trunk/src/gui/image/qpixmap.h	(revision 341)
+++ /trunk/src/gui/image/qpixmap.h	(revision 342)
@@ -151,4 +151,5 @@
 #if defined(Q_WS_PM)
     HBITMAP toPmHBITMAP(HBITMAP *mask = 0, bool embedRealAlpha = false) const;
+    static QPixmap fromPmHBITMAP(HBITMAP hbm);
     static HPOINTER toPmHPOINTER(const QIcon &icon, bool isPointer = false,
                                  int hotX = 0, int hotY = 0,
Index: /trunk/src/gui/image/qpixmap_pm.cpp
===================================================================
--- /trunk/src/gui/image/qpixmap_pm.cpp	(revision 341)
+++ /trunk/src/gui/image/qpixmap_pm.cpp	(revision 342)
@@ -115,4 +115,6 @@
 
     \warning This function is only available on OS/2.
+
+    \sa fromPmHBITMAP(), toPmHPOINTER()
 */
 HBITMAP QPixmap::toPmHBITMAP(HBITMAP *mask, bool embedRealAlpha) const
@@ -120,7 +122,8 @@
     if (data->classId() != QPixmapData::RasterClass) {
         QPixmapData *data = new QRasterPixmapData(depth() == 1 ?
-                                                  QPixmapData::BitmapType : QPixmapData::PixmapType);
+                                                  QPixmapData::BitmapType :
+                                                  QPixmapData::PixmapType);
         data->fromImage(toImage(), Qt::AutoColor);
-        return QPixmap(data).toPmHBITMAP(mask);
+        return QPixmap(data).toPmHBITMAP(mask, embedRealAlpha);
     }
 
@@ -230,4 +233,86 @@
 
 /*!
+    Returns a QPixmap that is equivalent to the given \a bitmap.
+
+    \warning This function is only available on OS/2.
+
+    \sa toPmHBITMAP(), {QPixmap#Pixmap Conversion}{Pixmap Conversion}
+
+*/
+// static
+QPixmap QPixmap::fromPmHBITMAP(HBITMAP hbm)
+{
+    QPixmap res;
+
+    if (hbm == NULLHANDLE)
+        return res;
+
+    // bitmap header + 2 palette entries (for the monochrome bitmap)
+    char bmi[sizeof(BITMAPINFOHEADER2) + 4 * 2];
+    memset(bmi, 0, sizeof(bmi));
+    BITMAPINFOHEADER2 &bmh = *(PBITMAPINFOHEADER2)bmi;
+    bmh.cbFix = sizeof(BITMAPINFOHEADER2);
+    PULONG pal = (PULONG)(bmi + sizeof(BITMAPINFOHEADER2));
+
+    if (!GpiQueryBitmapInfoHeader(hbm, &bmh))
+        return res;
+
+    HPS hps = qt_alloc_mem_ps(bmh.cx, bmh.cy);
+    if (hps == NULLHANDLE)
+        return res;
+
+    GpiSetBitmap(hps, hbm);
+
+    QImage img;
+    bool succeeded = false;
+
+    if (bmh.cPlanes == 1 && bmh.cBitCount == 1) {
+        // monochrome bitmap
+        img = QImage(bmh.cx, bmh.cy, QImage::Format_Mono);
+        if (GpiQueryBitmapBits(hps, 0, bmh.cy, (PBYTE)img.bits(),
+                               (PBITMAPINFO2)&bmi) != GPI_ALTERROR) {
+            succeeded = true;
+            // take the palette
+            QVector<QRgb> colors(2);
+            colors[0] = QRgb(pal[0]);
+            colors[1] = QRgb(pal[1]);
+        }
+    } else {
+        // always convert to 32-bit otherwise
+        img = QImage(bmh.cx, bmh.cy, QImage::Format_RGB32);
+        bmh.cPlanes = 1;
+        bmh.cBitCount = 32;
+        if (GpiQueryBitmapBits(hps, 0, bmh.cy, (PBYTE)img.bits(),
+                               (PBITMAPINFO2)&bmi) != GPI_ALTERROR) {
+            succeeded = true;
+            // try to auto-detect if there is a real alpha channel
+            bool allZero = true;
+            for (int i = 0; i < img.numBytes(); ++i) {
+                if (img.bits()[i] & 0xFF000000) {
+                    allZero = false;
+                    break;
+                }
+            }
+            if (!allZero) {
+                // assume we've got the alpha channel
+                QImage alphaImg = QImage(bmh.cx, bmh.cy, QImage::Format_ARGB32);
+                memcpy(alphaImg.bits(), img.bits(), img.numBytes());
+                img = alphaImg;
+            }
+        }
+    }
+
+    qt_free_mem_ps(hps);
+
+    if (succeeded) {
+        // flip the bitmap top to bottom to cancel PM inversion
+        img = img.mirrored();
+        res = QPixmap::fromImage(img);
+    }
+
+    return res;
+}
+
+/*!
     Creates a \c HPOINTER from the given QIcon. Returns the \c HPOINTER handle.
 
@@ -252,4 +337,6 @@
 
     \warning This function is only available on OS/2.
+
+    \sa toPmHBITMAP()
 */
 // static
