unit Unit1;
{$mode objfpc}{$H+}
interface
uses
Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, ExtCtrls,
StdCtrls;
type
{ TForm1 }
TForm1 =
class(TForm)
Button1: TButton;
Button2: TButton;
Button3: TButton;
Button4: TButton;
Edit1: TEdit;
Image1: TImage;
Image2: TImage;
Image3: TImage;
Label1: TLabel;
Label2: TLabel;
Memo1: TMemo;
OpenDialog1: TOpenDialog;
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;
F:
File of integer;
implementation
{$R *.lfm}
{ TForm1 }
procedure TForm1.Button1Click(Sender: TObject);
var
filename:
string;
filesize,len:Int64;
begin
if opendialog1.execute
then
begin
filename:=opendialog1.filename;
end;
image1.picture.loadfromfile(filename);
end;
procedure TForm1.Button2Click(Sender: TObject);
var
bildhoehe,bildbreite,zeile,spalte,farbe,X,Y: integer;
b:byte;
begin
application.processmessages;
ASSIGNFILE(f,'
NeuesBild.dat');
REWRITE(F);
for spalte:=0
to image1.width-1
do
begin
application.processmessages;
for zeile:=0
to image1.height-1
do
begin
application.processmessages;
farbe:=image1.Canvas.Pixels[spalte,zeile];
//Image2.Canvas.pixels[spalte,zeile]:=farbe;
//b:=farbe;
//label1.caption:=inttostr(b);
write(f,farbe);
end;
end;
//image1.canvas.brush.color:=255;
//image2.canvas.fillrect(rect(50,50,150,150));
Closefile(f);
end;
procedure TForm1.Button3Click(Sender: TObject);
var
farbwert:byte;
begin
farbwert:=strtoint(Edit1.text);
//image1.canvas.pixels[40,40];
label2.caption:=inttostr(farbwert);
image3.canvas.brush.color:=farbwert;
image3.canvas.fillrect(rect(0,0,image3.height,image3.width));
end;
procedure TForm1.Button4Click(Sender: TObject);
var
index1,index2,farbe1: integer;
begin
ASSIGNFILE(f,'
NeuesBild.dat');
RESET(f);
READ(F,farbe1);
For index1:=1
to 300
do
begin
for index2:=1
to 300
do
begin
image2.canvas.pixels[index1,index2]:=farbe1;
end;
end;
Closefile(f);
end;
end.