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.
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.
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.
2. More info needed to answer.
If you can post some code here 2 see where is the problem.
gtokas.
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(TObj ect* 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(TObje ct *Sender)
{
for (int i = 10; i <= 200; i++)
Canvas->Pixels[i][10] = clRed;
}
Example 1 (Pulled from my own ....):
// Not that is a good idea to do this, but works!!!
void __fastcall TForm1::someProcedure(TObj
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(TObje
{
for (int i = 10; i <= 200; i++)
Canvas->Pixels[i][10] = clRed;
}
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.
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
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
As I say, memory usage problem is no longer a trouble. big thanks