Donnee pixels ds1fichier txt -> image

Résolu
Nicolas___ Messages postés 992 Date d'inscription jeudi 2 novembre 2000 Statut Membre Dernière intervention 24 avril 2013 - 23 sept. 2005 à 23:18
Nicolas___ Messages postés 992 Date d'inscription jeudi 2 novembre 2000 Statut Membre Dernière intervention 24 avril 2013 - 29 sept. 2005 à 20:13
Tout d abbord BONJOUR,

Bon le sujet n est peut etre pas bien expliquer donc je vous mets ce code :

procedure TForm1.EnregisterClick(Sender: TObject);
var
x,y:integer;
begin
gauge1.MaxValue:=image1.Picture.Bitmap.Width;
memo1.Lines.Add(inttostr(image1.Picture.Bitmap.Width));
memo1.Lines.Add(inttostr(image1.Picture.Bitmap.height));



for x:=1 to image1.Picture.Bitmap.Width do
begin
gauge1.Progress:=x;
for y:=1 to image1.Picture.Bitmap.Height do
begin
memo1.Lines.Add(inttostr(image1.Picture.Bitmap.Canvas.Pixels[x,y]));
end;
end;


gauge1.Progress:=0;
memo1.Lines.SaveToFile(BDP.FileName+'.txt');
end;

Et voila le probleme c est une fois l image mis ds 1 txt je n arrive pas a la charger , je veux dire par la que j aimerais bien faire 1 procedure pour lire le fichier txt et mettre les donnees de chaque pixels ds 1 image.

Bon je l admets ca sert a rien mais c etait juste pour m amuser et la ca m amuse plus

Alors si qqun a une sol ...

Merci bcp

Nicolas

2 réponses

cs_Kenavo Messages postés 702 Date d'inscription vendredi 21 mars 2003 Statut Membre Dernière intervention 1 octobre 2009 5
27 sept. 2005 à 09:42
Salut Nicolas



Tu peux utiliser un TBitmap temporaire :

var

Bmp : TBitmap;

x, y, n: integer;

begin

memo1.Clear;

memo1.Lines.LoadFromFile(.......);

Bmp := TBitmap.Create;
// création et
dimensionnement du Bitmap

Bmp.Width := StrToInt(Memo1.Lines[0]);

Bmp.Height := StrToInt(Memo1.Lines[1]);


Image2.Width:=Bmp.Width; // Dimensionnement de l'image finale

Image2.Height:=Bmp.Height;


n:=2;

for x := 0 to Bmp.Width-1 do

begin

gauge1.Progress := x;

for y := 0 to Bmp.Height-1 do

begin

Bmp.Canvas.Pixels[x,y] := StrToInt(Memo1.Lines[n]);

memo1.Lines.Add(inttostr(image1.Picture.Bitmap.Canvas.Pixels[x, y]));

inc(n);

end;

end;

Image2.Picture.Bitmap.Assign(Bmp); // Bmp -> image2

Bmp.Free;

end;




Et fais gaffe : for x:=<strike>1</strike>0 to image1.Picture.Bitmap.Width -1
do



Ken@vo

<hr size ="2" width="100%">Code, Code, Codec !

[%3C/body ]
3
Nicolas___ Messages postés 992 Date d'inscription jeudi 2 novembre 2000 Statut Membre Dernière intervention 24 avril 2013 1
29 sept. 2005 à 20:13
Merci beaucoup Kenavo

Bon meme si dans l absolu c est inutile j aimais bien (j avais presque trouve la bonne methode, pas de chance !)

Ciao
Nico
0
Rejoignez-nous