Pixel example for Delphi
procedure TForm1.Lead1MouseDown (Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
var
xycolor : Longint;
xfraction, yfraction : Single;
xPixel, yPixel, xWidth : Integer;
begin
Lead1.AutoRepaint := False;
{Translate mouse coordinates to fractions of the destination width and height }
xfraction := (x - Lead1.DstLeft) / Lead1.DstWidth;
yfraction := (y - Lead1.DstTop) / Lead1.DstHeight;
{Convert fractions to bitmap pixel coordinates}
xPixel := Round((Lead1.SrcWidth * xfraction) + Lead1.SrcLeft);
yPixel := Round((Lead1.SrcHeight * yfraction) + Lead1.SrcTop);
{Make the whole line the same color as the pixel}
xycolor := Lead1.Pixel[xPixel, yPixel];
xWidth := Lead1.BitmapWidth;
Y := yPixel;
for X := 0 to xWidth-1 do
Lead1.Pixel[X, Y] := xycolor;
Lead1.ForceRepaint();
end;