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!

Read/write color of specific pixel on image

Status
Not open for further replies.

kristof

Programmer
Jun 2, 2000
234
BE
Hi all,

Is it possible to read the color of a specific pixel on an image?

What I'd like to get is something like this:

Code:
origColor = getPixelColor(x,y);
setPixelColor(x,y,'FF0000');

The origColor would later be used to restore it as it was.

Hope I'm making at least a bit sense? :)

Gtz,

Kristof
 
The TCanvas property is included in the TImage property.
Review the following TCanvas property for more info.
property Pixels[X, Y: Integer]: TColor;


Var anImage : TImage;
OriginalColor : TColor;

To get pixel color,
OriginalColor := anImage.Canvas.Pixels[x,y];

To set pixel color
anImage.Canvas.Pixels[x,y] := OriginalColor;


 
Tnx,

Works great! Shame it only works on a BMP, but doesn't really matter. :)

Gtz,

Kristof
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top