TBitmap - how to copy an "object"



hi,

i'm trying to copy an "object" of one color out of a TBitmap,
the problem i got is that i dont know when a pixel belongs to this object
when the image contains more then one objects. it's also not possible
to split the image, cause the objects are not seperated well.

this is my first try:

x:= 0;
while x < CacheBitmap.Width - 1 do
begin
for y := 0 to CacheBitmap.Height - 1 do
begin
P := CacheBitmap.ScanLine[y];
for i:= 0 to x do
inc(P);
if (P^.rgbRed = 0) and (P^.rgbGreen = 0) and (P^.rgbBlue = 0) then
begin
MyRect:= Rect(x, y, SmartBitmap.Height-1, SmartBitmap.Width-1);
MyOther:= Rect(x,y,SmartBitmap.Height-1, SmartBitmap.Width-1);
SmartBitmap.Canvas.CopyRect(MyOther,CacheBitmap.Canvas,MyRect);
end;
End;
inc(x);
end;

i also played around with a second pointer, but i got no luck :(

any ideas?


.