Changeset 941
- Timestamp:
- Aug 5, 2011, 2:26:40 AM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/gui/image/qpixmap_pm.cpp
r940 r941 108 108 routines to do real alpha blending. 109 109 110 Note that if the pixmap does neither have a mask nor the alpha channel but 111 \a mask is not NULL, a NULLHANDLE value will be stored there. 110 Note that if \a mask is not NULL but the pixmap does neither have a mask nor 111 the alpha channel, an emptpy bitmap mask with no transparency (zeroed AND 112 and XOR parts) will be created and returned. 112 113 113 114 It is the caller's responsibility to free both returned \c HBITMAP handes … … 160 161 (PBITMAPINFO2)&bmi); 161 162 162 if (mask && hasAlpha()) {163 if (mask) { 163 164 // get the mask 164 165 QImage mask; 165 if (!embedRealAlpha) { 166 // We prefer QImage::createAlphaMask() over QPixmap::mask() 167 // since the former will dither while the latter will convert any 168 // non-zero alpha value to an opaque pixel 169 mask = image.createAlphaMask().convertToFormat(QImage::Format_Mono); 170 171 // note: for some strange reason, createAlphaMask() (as opposed to 172 // mask().toImage()) returns an image already flipped top to bottom, 173 // so take it into account 174 175 // create the AND mask 176 mask.invertPixels(); 177 // add the XOR mask (and leave it zeroed) 178 mask = mask.copy(0, -h, w, h * 2); 166 if (hasAlpha()) { 167 if (!embedRealAlpha) { 168 // We prefer QImage::createAlphaMask() over QPixmap::mask() 169 // since the former will dither while the latter will convert any 170 // non-zero alpha value to an opaque pixel 171 mask = image.createAlphaMask().convertToFormat(QImage::Format_Mono); 172 173 // note: for some strange reason, createAlphaMask() (as opposed to 174 // mask().toImage()) returns an image already flipped top to bottom, 175 // so take it into account 176 177 // create the AND mask 178 mask.invertPixels(); 179 // add the XOR mask (and leave it zeroed) 180 mask = mask.copy(0, -h, w, h * 2); 181 } else { 182 // if we embedded real alpha, we still need a mask if we are going 183 // to create a pointer out of this pixmap (WinCreatePointerIndirect() 184 // requirement), but we will use QPixmap::mask() because it won't be 185 // able to destroy the alpha channel of non-fully transparent pixels 186 // when preparing the color bitmap for masking later. We could also 187 // skip this prepare step, but well, let's go this way, it won't hurt. 188 mask = this->mask().toImage().convertToFormat(QImage::Format_Mono); 189 190 // create the AND mask 191 mask.invertPixels(); 192 // add the XOR mask (and leave it zeroed) 193 mask = mask.copy(0, 0, w, h * 2); 194 // flip the bitmap top to bottom for PM 195 mask = mask.mirrored(false, true); 196 } 179 197 } else { 180 // if we embedded real alpha, we still need a mask if we are going 181 // to create a pointer out of this pixmap (WinCreatePointerIndirect() 182 // requirement), but we will use QPixmap::mask() because it won't be 183 // able to destroy the alpha channel of non-fully transparent pixels 184 // when preparing the color bitmap for masking later. We could also 185 // skip this prepare step, but well, let's go this way, it won't hurt. 186 mask = this->mask().toImage().convertToFormat(QImage::Format_Mono); 187 188 // create the AND mask 189 mask.invertPixels(); 190 // add the XOR mask (and leave it zeroed) 191 mask = mask.copy(0, 0, w, h * 2); 192 // flip the bitmap top to bottom for PM 193 mask = mask.mirrored(false, true); 198 mask = QImage(w, h * 2, QImage::Format_Mono); 199 mask.fill(0); 194 200 } 195 201
Note:
See TracChangeset
for help on using the changeset viewer.