Changeset 262 for trunk/src/gui/image
- Timestamp:
- Oct 28, 2009, 9:48:50 PM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/gui/image/qpixmap_pm.cpp
r260 r262 46 46 47 47 #include "qicon.h" 48 48 49 49 50 #include "qt_os2.h" … … 121 122 int h = d->image.height(); 122 123 123 HPS hps = qt_alloc_mem_ps(w, h );124 HPS hps = qt_alloc_mem_ps(w, h); 124 125 if (hps == NULLHANDLE) 125 126 return NULLHANDLE; … … 149 150 // since the former will dither while the latter will convert any 150 151 // non-zero alpha value to an opaque pixel 151 QImage mask = image.createAlphaMask().mirrored(); 152 153 // create the mask bitmap (AND and XOR stripes) 152 #if 1 153 QImage mask = image.createAlphaMask().convertToFormat(QImage::Format_Mono); 154 155 // note: for some strange reason, createAlphaMask() (as opposed to 156 // mask().toImage()) returns an image already flipped top to bottom, 157 // so take it into account 158 159 // create the AND mask 160 mask.invertPixels(); 161 // add the XOR mask (and leave it zeroed) 162 mask = mask.copy(0, -h, w, h * 2); 163 164 #else 165 QImage mask = this->mask().toImage().convertToFormat(QImage::Format_Mono); 166 167 // create the AND mask 168 mask.invertPixels(); 169 // add the XOR mask (and leave it zeroed) 170 mask = mask.copy(0, 0, w, h * 2); 171 // flip the bitmap top to bottom for PM 172 mask = mask.mirrored(false, true); 173 #endif 174 175 // create the mask bitmap 154 176 bmh.cbFix = sizeof(BITMAPINFOHEADER2); 155 177 bmh.cx = w; 156 bmh.cy = h ;178 bmh.cy = h; 157 179 bmh.cPlanes = 1; 158 180 bmh.cBitCount = 1; … … 160 182 pal[0] = 0; 161 183 pal[1] = 0x00FFFFFF; 162 hbmMask = GpiCreateBitmap(hps, &bmh, 0, NULL, NULL); 163 164 // create AND mask (XOR mask is left zeroed -- it's okay) 165 GpiSetBitmap(hps, hbmMask); 184 hbmMask = GpiCreateBitmap(hps, &bmh, CBM_INIT, 185 (PBYTE)(const uchar *)mask.bits(), 186 (PBITMAPINFO2)&bmi); 187 188 // prepare the bitmap for masking by setting transparent pixels to black 189 GpiSetBitmap(hps, hbm); 166 190 167 191 POINTL ptls[] = { 168 { 0, h }, { w - 1, h * 2 - 1 },// dst: inclusive-inclusive169 { 0, 0 }, { w, h },// src: inclusive-exclusive192 { 0, // dst: inclusive-inclusive 193 { 0, // src: inclusive-exclusive 170 194 }; 171 GpiDrawBits(hps, (PBYTE)(const uchar *)mask.bits(), (PBITMAPINFO2)&bmi,172 4, ptls, ROP_NOTSRCCOPY, BBO_IGNORE);173 174 // prepare the bitmap for masking by setting transparent pixels to black175 GpiSetBitmap(hps, hbmMask);176 177 195 ptls[0].y -= h; 178 196 ptls[1].y -= h; … … 234 252 info.yHotspot = hotY; 235 253 info.hbmColor = pm.toPmHBITMAP(&info.hbmPointer); 236 if (!pmMini.isNull()) 237 info.hbmMiniColor = pmMini.toPmHBITMAP(&info.hbmMiniPointer); 254 if (!pmMini.isNull()) { 255 info.hbmMiniColor = pmMini.toPmHBITMAP(&info.hbmMiniPointer); 256 } else { 257 info.hbmMiniPointer = NULLHANDLE; 258 info.hbmMiniColor = NULLHANDLE; 259 } 238 260 239 261 HPOINTER hIcon = WinCreatePointerIndirect(HWND_DESKTOP, &info);
Note:
See TracChangeset
for help on using the changeset viewer.