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;
Edit1: TEdit;
Image1: TImage;
Image2: TImage;
Label1: TLabel;
Label2: TLabel;
Label3: TLabel;
Label4: TLabel;
OpenDialog1: TOpenDialog;
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
procedure Button3Click(Sender: TObject);
procedure Image2Click(Sender: TObject);
private
{ private declarations }
public
{ public declarations }
end;
var
Form1: TForm1;
datei:
file of integer;
const Dateiname=('
Versteckt.dat');
implementation
{$R *.lfm}
{ TForm1 }
procedure TForm1.Button1Click(Sender: TObject);
VAR
pfad:
string;
begin
if opendialog1.execute
then
begin
pfad:=opendialog1.filename;
image1.picture.loadfromfile(pfad);
end;
end;
procedure TForm1.Button2Click(Sender: TObject);
var
Bildbreite,Bildhoehe,Zeile,Spalte,X,Y,farbe,r,g,b,v,Versteckte_Zahl,f:integer;
begin
Bildbreite:=image1.Width;
Bildhoehe:=image1.height;
//For zeile:=0 to bildbreite-1 do
// begin
// For spalte:=0 to bildhoehe-1 do
// begin
// farbe:=image1.canvas.pixels[zeile,spalte];
farbe:=image1.canvas.pixels[270,80];
//Versteckte_Zahl:=80;
r:=farbe
and $0000FF;
g:=(farbe
and $00FF00)
shr 8;
b:=(farbe
and $FF0000)
shr 16;
v:=versteckte_Zahl + farbe
and $FF000000;
//image2.canvas.pixels[zeile,spalte]:=r;
label1.caption:=('
rot: '+inttostr(r));
label2.caption:=('
grün: '+inttostr(g));
label3.caption:=('
blau: '+inttostr(b));
label4.caption:=('
Versteckte_Zahl: '+ inttostr(v));
image2.Canvas.brush.color:=farbe;
image2.canvas.fillrect(rect(0,0,300,300));
f:=r+g+b+v;
ASSIGNFILE(DATEI,DATEINAME);
REWRITE(DATEI);
WRITE(DATEI,f);
Closefile(Datei);
end;
procedure TForm1.Button3Click(Sender: TObject);
var
s:integer;
begin
ASSIGNFILE(DATEI,'
versteckt.dat');
Rewrite(datei);
Read(datei,s);
showmessage(inttostr(s));
Closefile(datei);
end;
procedure TForm1.Image2Click(Sender: TObject);
begin
end;
end.