|
Borland C ++ Builder FAQ
|
||
| The content | The last update: 12/12/2008 | |
|
How to generate region on a picture? The author: KAV 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;
}
|