Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Slow Pixels, slow image clearing ...

Status
Not open for further replies.

bluefeather

Programmer
Jun 6, 2006
1
0
0
GB
I have a function drawing pixels to the screen to form a grid.
When the screen is resized I redraw the grid.
e.g

for(float y=0;y<Height;y+=yadd)
{
for(float x=0;x<Width;x+=xadd)
Canvas->Pixels[x][y]=clBlack;
}


Is there a quicker way to access the pixels ?

Also I am drawing inside images on a form, when they are resized the image is first cleared. I use the canvas->rectangle function to clear the image. Its sooo slow, is there a quicker way ?

Your help is much appreciated :)

Thanks.
BlueFeather.
 
Since you're drawing a grid, why not draw lines (Canvas->MoveTo and Canvas->LineTo) instead of setting individual pixels, it will be much faster. Of course I don't know what your xadd is, maybe your grid isn't composed of solid lines.

As far as clearing the image, try setting the Picture to Null as in: Image1->Picture = NULL; That should be faster.
 
And you're using a float.... why?
Pixels is a integer number which means that for each set the float has to be converted. Alter to 'unsigned int', 'int' or another variable type that can cope with the size, do NOT use floating point if not absloute nessecary to anything.

Totte
Keep making it perfect and it will end up broken.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top