Урок на делфи 83. ascii графика (рисунок в текст)


задание на delphi. Задание на Delphi. Перевод рисунка в текст. ascii графика

unit Unit1;
interface
uses
Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.StdCtrls;
type
TForm1 = class(TForm)
Button1: TButton;
Button2: TButton;
Button3: TButton;
Button4: TButton;
Label1: TLabel;
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
procedure Button3Click(Sender: TObject);
procedure Button4Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
temp1:TStringList;
implementation
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
var i:Integer;
temp2:TStringList;
begin
temp2:=TStringList.Create;
for I := 0 to 10000000 do
temp2.Add('000000000000000000000000000000000000000000000000000000000000000');
temp2.Clear;
end;
procedure TForm1.Button2Click(Sender: TObject);
var i:Integer;
temp2:TStringList;
begin
temp2:=TStringList.Create;
for I := 0 to 10000000 do
temp2.Add('000000000000000000000000000000000000000000000000000000000000000');
temp2.Free;
end;
procedure TForm1.Button3Click(Sender: TObject);
var i:Integer;
temp2:TStringList;
begin
temp2:=TStringList.Create;
for I := 0 to 10000000 do
temp2.Add('000000000000000000000000000000000000000000000000000000000000000');
FreeAndNil(temp2);
end;
procedure TForm1.Button4Click(Sender: TObject);
var i:Integer;
temp2:TStringList;
begin
temp2:=TStringList.Create;
for I := 0 to 10000000 do
temp2.Add('000000000000000000000000000000000000000000000000000000000000000');
temp2.Destroy;
end;
end.
unit Unit1;
interface
uses
Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.ExtCtrls, Vcl.StdCtrls;
type
TForm1 = class(TForm)
Button1: TButton;
Image1: TImage;
procedure Button1Click(Sender: TObject);
procedure FormCreate(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
pic,temp:TBitmap;
implementation
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
begin
temp.Canvas.CopyRect(Rect(0, 0, pic.Width, pic.Height), pic.Canvas, Rect(Button1.Tag, 0, pic.Width+Button1.Tag, pic.Height));
Image1.Picture.Assign(temp);
Button1.Tag:=Button1.Tag+2;
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
pic:=TBitmap.Create;
pic.LoadFromFile('..\..\pic.bmp');
temp:=TBitmap.Create;
temp.Height:=pic.Height;
temp.Width:=pic.Width;
Image1.Proportional:=true;
end;
end.
unit Unit1;
interface
uses
Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.ExtCtrls, Vcl.StdCtrls;
type
TForm1 = class(TForm)
Button1: TButton;
Image1: TImage;
procedure Button1Click(Sender: TObject);
procedure FormCreate(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
pic:TBitmap;
implementation
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
var i,j:integer;
s:string;
c:TColor;
temp:TStringList;
begin
temp:=TStringList.Create;
for I := 0 to pic.Height do
begin
for j := 0 to pic.Width do
begin
c:=pic.Canvas.Pixels[j,i];
if c s:=s+'0'
else
s:=s+' ';
end;
temp.Add(s);
s:='';
end;
temp.SaveToFile('ascci.txt');
temp.Free;
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
pic:=TBitmap.Create;
pic.LoadFromFile('..\..\pic.bmp');
Image1.Proportional:=true;
Image1.Picture.Assign(pic);
end;
end.



Скачать