Board index » cppbuilder » Canvas->FloodFill operation

Canvas->FloodFill operation

    I have used in my component: Canvas->FloodFill method
    (under C++Builder5 with Win98)
for filling about 200 fields (about 4/4 pixels) in my application.
It was working pretty good.

Now I'm using C++Builder6 on WinXP
and it appears to be very slow!!! is there something changed since
C++Builder5 ???
I think it slowing down about 100 times. :(

My code is as is:

int x, y, iField,

  for (iField=0; iField<=200; iField++  )
  {
      x = GetFieldPositionX(iField);   // My function, that returns each
field x position
      y = GetFieldPositionY(iField);   // My function, that returns each
field y position

      Canvas->Brush->Color = clBlack;
      Canvas->FloodFill(x, y, clWhite, fsSurface);
  }

My fields are not rectangles, but:
for test purposes I have tried FillRect method instead FloodFill,
  and the speed is pretty good for me.
     Canvas->FillRect(Rect(xc,y,xc+4,y+4));

Why Canvas->FloodFill is so slow here, and how to make it faster?
(while my areas to fill are not rectangular).

Help please.

Regards,
    Gregory K.
musi...@polbox.com

 

Re:Canvas->FloodFill operation


Greg,

Quote
> Why Canvas->FloodFill is so slow here, and how to make it faster?
> (while my areas to fill are not rectangular).

IIRC, the FloodFill() GDI function [which TCanvas::FloodFill() wraps],
is simulated by the GDI via multiple calls to SetPixel(), thus making it
unbearably slow.  Try masking + BitBlt() as demonstrated here...

http://bcbcaq.freeservers.com/project_DR.html

or multi-pixel regions, as demonstrated here...

http://www.bridgespublishing.com/articles/issues/0111/Custom_buttons_...

Best of luck,
Damon (TeamB)

Other Threads