Link to home
Start Free TrialLog in
Avatar of chudy
chudy

asked on

TCanvas memory usage and FloodFill

I designed simply class with TBitmap as main output variable.
1) After drawing function canvas needs to be cleared but if I clear it manualy (by changing colors of pixels) amount of used memory is growing. After many loops it returns exception like "there is no memory to confirm that procedure". I don't know exactly how it translate from polish (very probably that system returns that exception). How can I stop memory from growing?

2) FloodFill is a method from TCanvas and.... it don't work properly or just I can't use this function. I tried several times with other settings but I can't fill one-color square.

----
Sorry for my poor English knowledge.
Avatar of _corey_
_corey_

Could you post a little of the code around the call to clear the canvas?  perhaps the method if it's small enough.
1. Maybe you are trapped in a loop and your function instead of doing what you ask appents data to the bitmap till memory overflow.
2. More info needed to answer.

If you can post some code here 2 see where is the problem.

gtokas.
Avatar of Cayce
Don't use FloodFill to change color of individual pixels. That's why there's a Pixels[int X][int Y] property on TCanvas.

Example 1 (Pulled from my own ....):

// Not that is a good idea to do this, but works!!!
void __fastcall TForm1::someProcedure(TObject* Sender) {
  for(int x = 0; x < 640; x++)
    for(int y = 0; y < 480; y++)
      Canvas->Pixels[x][y] = cBlack;
}

Example 2 (BCB docs):

void __fastcall TForm1::Button1Click(TObject *Sender)
{
  for (int i = 10; i <= 200; i++)
    Canvas->Pixels[i][10] = clRed;
}
Avatar of chudy

ASKER

First problem is no longer a trouble for me but I give points to someone who explain me how to use FloodFill or why it don't work properly.

Cayce: I know this method but it is too slow. Can't do this when fps should be no less than 60 and CPU usage with blankscreen no more than 1% on 2ghz CPU. I used rectangle method to draw blank screen but I still need to know how to use FloodFill method.
ASKER CERTIFIED SOLUTION
Avatar of Cayce
Cayce
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of chudy

ASKER

As I say, memory usage problem is no longer a trouble. big thanks