RAD Studio VCL Reference
ContentsIndex
PreviousUpNext
TCanvas.Pixels Property

Specifies the color of the pixels within the current ClipRect.

Pascal
property Pixels [X, Y: Integer]: TColor;
C++
__property TColor Pixels[int X, Y];

Read Pixels to learn the color on the drawing surface at a specific pixel position within the current clipping region. If the position is outside the clipping rectangle, reading the value of Pixels returns -1. 

Write Pixels to change the color of individual pixels on the drawing surface. Use Pixels for detailed effects on an image. Pixels may also be used to determine the color that should be used for the FillRect method. 

Not every device context supports the Pixels property. Reading the Pixels property for such a device context will return a value of -1. Setting the Pixels property for such a device context does nothing.  

C++ Examples: 

 

/*
This example draws a red line (very slowly) when the user
presses a button. Attach the following code to the button’s 
OnClick event handler:
*/
void __fastcall TForm1::Button1Click(TObject *Sender)
{
  for (int i = 10; i <= 200; i++)
    Canvas->Pixels[i][10] = clRed;
}

 

Delphi Examples: 

{
This example draws a red line (very slowly) when the user 
presses a button. Attach the following code to the button’s 
OnClick event handler:
} 
procedure TForm1.Button1Click(Sender: TObject);
var
  W: Word;
begin
    for W := 10 to 200 do
      Canvas.Pixels[W, 10] := clRed;
end;

 

Copyright(C) 2008 CodeGear(TM). All Rights Reserved.
What do you think about this topic? Send feedback!