Коментраии к строчкам Delphi кода
Добавлено: 20 фев 2011, 22:34
Привет .....Помогите пожалуйста написать комментарии к строчкам данного кода ..тоесть что делает каждая строчка ..... заранее спасибо
Код: Выделить всё
it Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, ExtCtrls, StdCtrls, ComCtrls, ExtDlgs;
type
TForm1 = class(TForm)
Image1: TImage;
Button1: TButton;
ProgressBar1: TProgressBar;
Button2: TButton;
OpenDialog1: TOpenDialog;
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
var
Bitmap: TBitmap;
procedure TForm1.Button1Click(Sender: TObject);
var C: TColor;
var i, j, R, G, B, H, W, t: integer;
FR, FG, FB, GR, GG, GB : real;
begin
W:= Form1.Image1.Width-1;
H:= Form1.Image1.Height-1;
for i:=1 to W do
begin
for j:=1 to H do
begin
C:=Form1.Image1.Canvas.Pixels[i,j];
R:=GetRValue(C);
G:=GetGValue(C);
B:=GetBValue(C);
FR:=1-R/255;
FG:=1-G/255;
FB:=1-B/255;
if FR < 0.1 then
GR:=1 else GR:=0.1/FR;
if FG < 0.1 then
GG:=1 else GG:=0.1/FG;
if FB < 0.1 then
GB:=1 else GB:=0.1/FB;
R:=Round(GR*255);
G:=Round(GG*255);
B:=Round(GB*255);
if R > 255 then R:=255;
if G > 255 then G:=255;
if B > 255 then B:=255;
if R < 0 then R:=0;
if G < 0 then G:=0;
if B < 0 then B:=0;
Form1.Image1.Canvas.Pixels[i,j]:=RGB(R,G,B);
ProgressBar1.Position:=Round((i*H)/(W*H)*100);
end;
end;
ShowMessage('Complete');
end;
procedure TForm1.Button2Click(Sender: TObject);
begin
if Form1.OpenDialog1.Execute then
begin
bitmap := TBitmap.Create;
bitmap.LoadFromFile(OpenDialog1.FileName);
Form1.Image1.Canvas.Draw(0, 0, bitmap);
end;
end;
end.