HRGN CreateRgnFromBitmap(Graphics::TBitmap *bmp, TPoint pPoint, bool bEqaul = true) { int f, x, y; bool b = false; HRGN Rgn, ResRgn = CreateRectRgn(0, 0, 0, 0); for (y = 0; y < bmp->Height; y++) for (x = 0; x < bmp->Width; x++) { if (!bEqaul^(bmp->Canvas->Pixels[x][y] != bmp->Canvas->Pixels[pPoint.x][pPoint.y])) { if (!b) { f = x; b = true; } else if (x == (bmp->Width - 1)) { Rgn = CreateRectRgn(f, y, x, y + 1); CombineRgn(ResRgn, ResRgn, Rgn, RGN_OR); b = false; } } else if (b) { Rgn = CreateRectRgn(f, y, x, y + 1); CombineRgn(ResRgn, ResRgn, Rgn, RGN_OR); b = false; } } return ResRgn; }
|