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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Real Time TImage refresh

Status
Not open for further replies.

Bussotao

Programmer
Mar 26, 2002
11
BR
Hi there:
I'm trying to plot some xy charts using the Canvas of a TImage, changing some pixels color. Does somebody know if it is possible to refresh the image so that I can see the points being plotted one by one?

Tks
 
Sure, you can call Refresh or Repaint. If you refresh it often though, it will flicker. You'll want to double buffer to prevent it in that case. If you double buffer, you must override the Paint method of the Canvas. You'll need to create a new component to do this.

The code below assumes you created a new component TMyNewTImage from TImage and are overriding the Paint method.

void __fastcall TMyNewTImage::paint(void)
{
static Graphics::TBitmap *Buffer = new Graphics::TBitmap();

/* You can put the next two lines elsewhere in code to speed up the painting. Only call them if Width or Height changes */
Buffer->Width = Width;
Buffer->Height = Height;

Buffer->Canvas->Draw(0,0,this);

Buffer->Canvas->Pixels[whatever][whatever2] = clSomeNewColor;
Canvas->Draw(0,0,Buffer);
}

Chris
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top