- Timestamp:
- Mar 3, 2010, 3:04:01 AM (15 years ago)
- Location:
- trunk/src/gui/image
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/gui/image/qpixmap.h
r561 r621 163 163 #if defined(Q_WS_PM) 164 164 HBITMAP toPmHBITMAP(HBITMAP *mask = 0, bool embedRealAlpha = false) const; 165 static QPixmap fromPmHBITMAP(HBITMAP hbm );165 static QPixmap fromPmHBITMAP(HBITMAP hbm, HBITMAP hbmMask = NULLHANDLE); 166 166 static HPOINTER toPmHPOINTER(const QIcon &icon, bool isPointer = false, 167 167 int hotX = 0, int hotY = 0, 168 168 bool embedRealAlpha = false, bool isMini = true); 169 static QIcon fromPmHPOINTER(HPOINTER hpointer, QPixmap *pixmap = 0, 170 QPixmap *pixmapMini = 0); 169 171 #endif 170 172 -
trunk/src/gui/image/qpixmap_pm.cpp
r569 r621 93 93 handle. 94 94 95 If \a mask is not NULL, the mask mode is turned . In this mode, the bitmap95 If \a mask is not NULL, the mask mode is turned on. In this mode, the bitmap 96 96 mask is also created from the QPixmap's mask and returned in the given 97 97 variable. This bitmap mask will contain two vertically adjacent sections, … … 233 233 234 234 /*! 235 Returns a QPixmap that is equivalent to the given \a bitmap. 235 Returns a QPixmap that is equivalent to the given \a bitmap. If \a hbmMask 236 is not NULLHANDLE, it should contain vertically adjacent AND and XOR masks 237 for the given bitmap which will be used to create a mask for the returned 238 QPixmap. 239 240 Note that this method will attempt to auto-detect the presence of the real 241 alpha chennel in the high 8 bits of the 32-bit pixel value for each pixel if 242 the \a bitmap has 1 plane and the 32-bit depth. This alpha channel will be 243 used to create an alpha channel for the returned QPixmap. 236 244 237 245 \warning This function is only available on OS/2. … … 241 249 */ 242 250 // static 243 QPixmap QPixmap::fromPmHBITMAP(HBITMAP hbm )251 QPixmap QPixmap::fromPmHBITMAP(HBITMAP hbm, HBITMAP hbmMask) 244 252 { 245 253 QPixmap res; … … 258 266 return res; 259 267 260 HPS hps = qt_alloc_mem_ps(bmh->cx, bmh->cy );268 HPS hps = qt_alloc_mem_ps(bmh->cx, bmh->cy * 2); 261 269 if (hps == NULLHANDLE) 262 270 return res; … … 270 278 // monochrome bitmap 271 279 img = QImage(bmh->cx, bmh->cy, QImage::Format_Mono); 272 if (GpiQueryBitmapBits(hps, 0, bmh->cy, (PBYTE)img.bits(),280 if (GpiQueryBitmapBits(hps, 0, img.height(), (PBYTE)img.bits(), 273 281 (PBITMAPINFO2)&bmi) != GPI_ALTERROR) { 274 282 succeeded = true; … … 277 285 colors[0] = QRgb(pal[0]); 278 286 colors[1] = QRgb(pal[1]); 287 img.setColorTable(colors); 279 288 } 280 289 } else { … … 283 292 bmh->cPlanes = 1; 284 293 bmh->cBitCount = 32; 285 if (GpiQueryBitmapBits(hps, 0, bmh->cy, (PBYTE)img.bits(),294 if (GpiQueryBitmapBits(hps, 0, img.height(), (PBYTE)img.bits(), 286 295 (PBITMAPINFO2)&bmi) != GPI_ALTERROR) { 287 296 succeeded = true; … … 300 309 img = alphaImg; 301 310 } 311 // flip the bitmap top to bottom to cancel PM inversion 312 img = img.mirrored(); 302 313 } 303 314 } 304 315 316 QImage mask; 317 318 if (hbmMask != NULLHANDLE) { 319 // get the AND+XOR mask 320 GpiSetBitmap(hps, hbmMask); 321 mask = QImage(bmh->cx, bmh->cy * 2, QImage::Format_Mono); 322 bmh->cPlanes = 1; 323 bmh->cBitCount = 1; 324 if (GpiQueryBitmapBits(hps, 0, mask.height(), (PBYTE)mask.bits(), 325 (PBITMAPINFO2)&bmi) != GPI_ALTERROR) { 326 // take the palette 327 QVector<QRgb> colors(2); 328 colors[0] = QRgb(pal[0]); 329 colors[1] = QRgb(pal[1]); 330 mask.setColorTable(colors); 331 // flip the bitmap top to bottom to cancel PM inversion 332 mask = mask.mirrored(false, true); 333 // drop the XOR mask 334 mask = mask.copy(0, 0, mask.width(), mask.height() / 2); 335 // create a normal mask from the AND mask 336 mask.invertPixels(); 337 } 338 } 339 305 340 qt_free_mem_ps(hps); 306 341 307 342 if (succeeded) { 308 // flip the bitmap top to bottom to cancel PM inversion309 img = img.mirrored();310 343 res = QPixmap::fromImage(img); 344 if (!mask.isNull()) 345 res.setMask(QBitmap::fromImage(mask)); 311 346 } 312 347 … … 399 434 } 400 435 436 /*! 437 Returns a QIcon that is equivalent to the given \a pointer. Optionally 438 returns pixmaps used to comprise the icon in the respective arguments. 439 440 Note that this method will attempt to auto-detect the presence of the real 441 alpha chennel in the high 8 bits of the 32-bit pixel value for each pixel if 442 the bitmaps in \a hpointer have 1 plane and the 32-bit depth. This alpha 443 channel will be used to create an alpha channel for the pixmaps comprising 444 the icon. 445 446 \warning This function is only available on OS/2. 447 448 \sa toPmHPOINTER(), {QPixmap#Pixmap Conversion}{Pixmap Conversion} 449 450 */ 451 // static 452 QIcon QPixmap::fromPmHPOINTER(HPOINTER hpointer, QPixmap *pixmap, 453 QPixmap *pixmapMini) 454 { 455 QIcon res; 456 457 if (hpointer == NULLHANDLE) 458 return res; 459 460 POINTERINFO info = { 0 }; 461 if (!WinQueryPointerInfo(hpointer, &info)) 462 return res; 463 464 QPixmap pm = fromPmHBITMAP(info.hbmColor, info.hbmPointer); 465 if (!pm.isNull()) 466 res.addPixmap(pm); 467 468 QPixmap pmMini = fromPmHBITMAP(info.hbmMiniColor, info.hbmMiniPointer); 469 if (!pmMini.isNull()) 470 res.addPixmap(pmMini); 471 472 if (pixmap) 473 *pixmap = pm; 474 if (pixmapMini) 475 *pixmapMini = pmMini; 476 477 return res; 478 } 479 401 480 QPixmap QPixmap::grabWindow(WId winId, int x, int y, int w, int h) 402 481 {
Note:
See TracChangeset
for help on using the changeset viewer.