Index: /trunk/src/gui/image/qpixmap.h
===================================================================
--- /trunk/src/gui/image/qpixmap.h	(revision 620)
+++ /trunk/src/gui/image/qpixmap.h	(revision 621)
@@ -163,8 +163,10 @@
 #if defined(Q_WS_PM)
     HBITMAP toPmHBITMAP(HBITMAP *mask = 0, bool embedRealAlpha = false) const;
-    static QPixmap fromPmHBITMAP(HBITMAP hbm);
+    static QPixmap fromPmHBITMAP(HBITMAP hbm, HBITMAP hbmMask = NULLHANDLE);
     static HPOINTER toPmHPOINTER(const QIcon &icon, bool isPointer = false,
                                  int hotX = 0, int hotY = 0,
                                  bool embedRealAlpha = false, bool isMini = true);
+    static QIcon fromPmHPOINTER(HPOINTER hpointer, QPixmap *pixmap = 0,
+                                QPixmap *pixmapMini = 0);
 #endif
 
Index: /trunk/src/gui/image/qpixmap_pm.cpp
===================================================================
--- /trunk/src/gui/image/qpixmap_pm.cpp	(revision 620)
+++ /trunk/src/gui/image/qpixmap_pm.cpp	(revision 621)
@@ -93,5 +93,5 @@
     handle.
 
-    If \a mask is not NULL, the mask mode is turned. In this mode, the bitmap
+    If \a mask is not NULL, the mask mode is turned on. In this mode, the bitmap
     mask is also created from the QPixmap's mask and returned in the given
     variable. This bitmap mask will contain two vertically adjacent sections,
@@ -233,5 +233,13 @@
 
 /*!
-    Returns a QPixmap that is equivalent to the given \a bitmap.
+    Returns a QPixmap that is equivalent to the given \a bitmap. If \a hbmMask
+    is not NULLHANDLE, it should contain vertically adjacent AND and XOR masks
+    for the given bitmap which will be used to create a mask for the returned
+    QPixmap.
+
+    Note that this method will attempt to auto-detect the presence of the real
+    alpha chennel in the high 8 bits of the 32-bit pixel value for each pixel if
+    the \a bitmap has 1 plane and the 32-bit depth. This alpha channel will be
+    used to create an alpha channel for the returned QPixmap.
 
     \warning This function is only available on OS/2.
@@ -241,5 +249,5 @@
 */
 // static
-QPixmap QPixmap::fromPmHBITMAP(HBITMAP hbm)
+QPixmap QPixmap::fromPmHBITMAP(HBITMAP hbm, HBITMAP hbmMask)
 {
     QPixmap res;
@@ -258,5 +266,5 @@
         return res;
 
-    HPS hps = qt_alloc_mem_ps(bmh->cx, bmh->cy);
+    HPS hps = qt_alloc_mem_ps(bmh->cx, bmh->cy * 2);
     if (hps == NULLHANDLE)
         return res;
@@ -270,5 +278,5 @@
         // monochrome bitmap
         img = QImage(bmh->cx, bmh->cy, QImage::Format_Mono);
-        if (GpiQueryBitmapBits(hps, 0, bmh->cy, (PBYTE)img.bits(),
+        if (GpiQueryBitmapBits(hps, 0, img.height(), (PBYTE)img.bits(),
                                (PBITMAPINFO2)&bmi) != GPI_ALTERROR) {
             succeeded = true;
@@ -277,4 +285,5 @@
             colors[0] = QRgb(pal[0]);
             colors[1] = QRgb(pal[1]);
+            img.setColorTable(colors);
         }
     } else {
@@ -283,5 +292,5 @@
         bmh->cPlanes = 1;
         bmh->cBitCount = 32;
-        if (GpiQueryBitmapBits(hps, 0, bmh->cy, (PBYTE)img.bits(),
+        if (GpiQueryBitmapBits(hps, 0, img.height(), (PBYTE)img.bits(),
                                (PBITMAPINFO2)&bmi) != GPI_ALTERROR) {
             succeeded = true;
@@ -300,13 +309,39 @@
                 img = alphaImg;
             }
+            // flip the bitmap top to bottom to cancel PM inversion
+            img = img.mirrored();
         }
     }
 
+    QImage mask;
+
+    if (hbmMask != NULLHANDLE) {
+        // get the AND+XOR mask
+        GpiSetBitmap(hps, hbmMask);
+        mask = QImage(bmh->cx, bmh->cy * 2, QImage::Format_Mono);
+        bmh->cPlanes = 1;
+        bmh->cBitCount = 1;
+        if (GpiQueryBitmapBits(hps, 0, mask.height(), (PBYTE)mask.bits(),
+                               (PBITMAPINFO2)&bmi) != GPI_ALTERROR) {
+            // take the palette
+            QVector<QRgb> colors(2);
+            colors[0] = QRgb(pal[0]);
+            colors[1] = QRgb(pal[1]);
+            mask.setColorTable(colors);
+            // flip the bitmap top to bottom to cancel PM inversion
+            mask = mask.mirrored(false, true);
+            // drop the XOR mask
+            mask = mask.copy(0, 0, mask.width(), mask.height() / 2);
+            // create a normal mask from the AND mask
+            mask.invertPixels();
+        }
+    }
+
     qt_free_mem_ps(hps);
 
     if (succeeded) {
-        // flip the bitmap top to bottom to cancel PM inversion
-        img = img.mirrored();
         res = QPixmap::fromImage(img);
+        if (!mask.isNull())
+            res.setMask(QBitmap::fromImage(mask));
     }
 
@@ -399,4 +434,48 @@
 }
 
+/*!
+    Returns a QIcon that is equivalent to the given \a pointer. Optionally
+    returns pixmaps used to comprise the icon in the respective arguments.
+
+    Note that this method will attempt to auto-detect the presence of the real
+    alpha chennel in the high 8 bits of the 32-bit pixel value for each pixel if
+    the bitmaps in \a hpointer have 1 plane and the 32-bit depth. This alpha
+    channel will be used to create an alpha channel for the pixmaps comprising
+    the icon.
+
+    \warning This function is only available on OS/2.
+
+    \sa toPmHPOINTER(), {QPixmap#Pixmap Conversion}{Pixmap Conversion}
+
+*/
+// static
+QIcon QPixmap::fromPmHPOINTER(HPOINTER hpointer, QPixmap *pixmap,
+                              QPixmap *pixmapMini)
+{
+    QIcon res;
+
+    if (hpointer == NULLHANDLE)
+        return res;
+
+    POINTERINFO info = { 0 };
+    if (!WinQueryPointerInfo(hpointer, &info))
+        return res;
+
+    QPixmap pm = fromPmHBITMAP(info.hbmColor, info.hbmPointer);
+    if (!pm.isNull())
+        res.addPixmap(pm);
+
+    QPixmap pmMini = fromPmHBITMAP(info.hbmMiniColor, info.hbmMiniPointer);
+    if (!pmMini.isNull())
+        res.addPixmap(pmMini);
+
+    if (pixmap)
+        *pixmap = pm;
+    if (pixmapMini)
+        *pixmapMini = pmMini;
+
+    return res;
+}
+
 QPixmap QPixmap::grabWindow(WId winId, int x, int y, int w, int h)
 {
