Mark Harmstone hellas@burntcomma.com writes:
- /* loop through the image looking for transparent pixels,
* grouping together horizontal runs into one rect */
- ptr = bits;
- for (y = 0; y < r.bottom; y++) {
BOOL trans = FALSE;
int transstart;
for (x = 0; x < r.right; x++) {
COLORREF colour = ptr[2] << 16 | ptr[1] << 8 | ptr[0];
ptr += 4;
if (colour == transcolour) {
if (!trans) {
transstart = x;
trans = TRUE;
}
} else if (trans) {
rgntemp = CreateRectRgn(transstart, y, x, y+1);
CombineRgn(hrgn, hrgn, rgntemp, RGN_DIFF);
DeleteObject(rgntemp);
trans = FALSE;
}
}
if (trans) {
rgntemp = CreateRectRgn(transstart, y, r.right, y+1);
CombineRgn(hrgn, hrgn, rgntemp, RGN_DIFF);
DeleteObject(rgntemp);
}
- }
That's going to be pretty slow. There's a better implementation in winex11.drv:update_surface_region(), you could just copy that.