Graphic Delphi

Title: How to Brighten / Darken a bitmap
Question: The following routine will allow you to whiten or darken an area of a bitmap.
The whitewash value is either added or removed from the red, blue and green components of each pixel. specify a negative value between 0 and 255 to darken or a positive value between 0 and 255 to lighten.
Answer:
procedure WhiteWash(src: TBitmap; ARect : TRect; WhiteWashValue : integer = 128);
function GetPixel(x,y : integer) : pRGBTriple;
var
line : pbytearray;
begin
line := src.ScanLine[y];
result := @line[x*3];
end;
var
x,y : integer;
begin
src.PixelFormat:=pf24bit;
if ARect.Top if ARect.left if ARect.bottom src.Height then exit;
if ARect.right src.Width then exit;
for y := ARect.top to ARect.bottom-1 do
for x := ARect.left to Arect.right-1 do
begin
getpixel(x,y).rgbtRed := IntToByte(WhiteWashValue + getpixel(x,y).rgbtRed );
getpixel(x,y).rgbtGreen := IntToByte(WhiteWashValue + getpixel(x,y).rgbtGreen );
getpixel(x,y).rgbtBlue := IntToByte(WhiteWashValue + getpixel(x,y).rgbtBlue );
end;
end;
function IntToByte(i:Integer):Byte;
begin
if i255 then
Result:=255
else if i Result:=0
else
Result:=i;
end;