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); |
| 165 | if (hasAlpha()) { |
| 166 | if (!embedRealAlpha) { |
| 167 | // We prefer QImage::createAlphaMask() over QPixmap::mask() |
| 168 | // since the former will dither while the latter will convert any |
| 169 | // non-zero alpha value to an opaque pixel |
| 170 | mask = image.createAlphaMask().convertToFormat(QImage::Format_Mono); |
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); |
| 176 | // create the AND mask |
| 177 | mask.invertPixels(); |
| 178 | // add the XOR mask (and leave it zeroed) |
| 179 | mask = mask.copy(0, -h, w, h * 2); |
| 180 | } else { |
| 181 | // if we embedded real alpha, we still need a mask if we are going |
| 182 | // to create a pointer out of this pixmap (WinCreatePointerIndirect() |
| 183 | // requirement), but we will use QPixmap::mask() because it won't be |
| 184 | // able to destroy the alpha channel of non-fully transparent pixels |
| 185 | // when preparing the color bitmap for masking later. We could also |
| 186 | // skip this prepare step, but well, let's go this way, it won't hurt. |
| 187 | mask = this->mask().toImage().convertToFormat(QImage::Format_Mono); |
| 188 | |
| 189 | // create the AND mask |
| 190 | mask.invertPixels(); |
| 191 | // add the XOR mask (and leave it zeroed) |
| 192 | mask = mask.copy(0, 0, w, h * 2); |
| 193 | // flip the bitmap top to bottom for PM |
| 194 | mask = mask.mirrored(false, true); |
| 195 | } |
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); |
| 197 | mask = QImage(w, h * 2, QImage::Format_Mono); |
| 198 | mask.fill(0); |