procedure TForm1.Button1Click(Sender: TObject);
label 2879;
var factor:single;
mycolor,newcolor:string;
newRed,newGreen,newBlue:byte;
RGB,tempcolor:TColor;
pointx,pointy:integer;
i,p:integer;
H, S, L: Word;
hvar,svar,lvar:integer;
var1,var2,var3:integer;
px,py,q:integer;
begin
haltscan := false;
button7.enabled := false;
button4.enabled := false;
button6.enabled := false;
button5.enabled := false;
button1.enabled := false;
image1.picture := image2.picture;
image1.visible := true;
if (edit1.text <> '0') then
begin
shape1.visible := true;
statictext8.visible := true;
imagealtered := true;
changeapplied := true;
memo1.text := memo1.text + '-Doing contrast-';
application.processmessages;
pointx := 0;
pointy := 0;
i := 0;
while (i < image1.width) and (haltscan = false) do
begin
pointy := 0;
p := 0;
while (p < image1.height) and (haltscan = false) do
begin
mycolor := ColorToString(image1.canvas.pixels[pointx,pointy]);
if safemode = true then
application.processmessages;
if (mycolor = 'clblack') or (mycolor = 'clMaroon') or (mycolor = 'clGreen') or (mycolor = 'clOlive') or
(mycolor = 'clNavy') or (mycolor = 'clPurple') or (mycolor = 'clTeal') or (mycolor = 'clGray') or
(mycolor = 'clSilver') or (mycolor = 'clRed') or (mycolor = 'clLime') or (mycolor = 'clYellow') or
(mycolor = 'clBlue') or (mycolor = 'clFuchsia') or (mycolor = 'clAqua') or (mycolor = 'clLtGray') or
(mycolor = 'cldkGray') or (mycolor = 'clWhite') then
begin
tempcolor := StringToColor(mycolor);
goto 2879;
end;
factor := (259 * (contrast + 255)) / (255 * (259 - contrast));
newRed := Trunc(factor * (Red(StringToColor(mycolor)) - 128) + 128);
newGreen := Trunc(factor * (Green(StringToColor(mycolor)) - 128) + 128);
newBlue := Trunc(factor * (Blue(StringToColor(mycolor)) - 128) + 128);
tempcolor := RGBToColor(newRed,newGreen,newBlue);
2879:
image1.canvas.pixels[pointx,pointy] := tempcolor;
pointy := pointy + 1;
p := p + 1;
if safemode = true then
application.processmessages;
end;
if safemode = true then
application.processmessages;
pointx := pointx + 1;
i := i + 1;
end;
end;
haltscan := false;
button7.enabled := true;
button1.enabled := true;
button4.enabled := true;
button6.enabled := true;
button5.enabled := true;
shape1.visible := false;
statictext8.visible := false;
end;