AGB  ·  Datenschutz  ·  Impressum  







Anmelden
Nützliche Links
Registrieren

problem mit dynamischem array

Ein Thema von chamop87 · begonnen am 20. Feb 2008 · letzter Beitrag vom 20. Feb 2008
 
busybyte

Registriert seit: 15. Sep 2006
165 Beiträge
 
#14

Re: problem mit dynamischem array

  Alt 20. Feb 2008, 20:51
Dein Code ist Horror,ich habe ihn in soweit korrigiert ,das er für mich halbwegs einen Sinn
ergeben könnte.

Delphi-Quellcode:
procedure TForm1.FormCreate(Sender: TObject);
var fa:integer;
begin
randomize;
zaehl:=0;
filelistbox1.Directory:='C:\';//Eigene Dateien\Eigene Bilder\';
filelistbox1.Mask:='*.bmp;*.jpg;*.jpeg';

if filelistbox1.Items.Count>1 then
begin
setlength(randoms,filelistbox1.Items.Count); //Edit
bildanzahl:=filelistbox1.items.count; //Edit
end;
ca:=0;
memo1.lines.add(inttostr(filelistbox1.Items.count));
for fa:=low(randoms) to high(randoms) do
randoms[fa]:=fa;
//randoms[11]:=11;
end;//procedure

procedure TForm1.Button1Click(Sender: TObject);
var dateiname,endung:string;
    fi,fa,fb,zufall,bildnr:integer;
begin
//for fa:=0 to filelistbox1.items.count-1 do begin



//Edit
  zufall:=bildanzahl;
  while zufall>high(randoms) do Zufall:=random(bildanzahl); //Edit

//while (zufall>Length(randoms)-1) do exit;
  bildnr:=randoms[zufall];

  //Edit
  for fa:=0 to filelistbox1.Items.count-1 do
  begin
  test:=inttostr(randoms[fa]);
  memo1.lines.add(inttostr(randoms[fa])+' '+inttostr(bildnr));
  end;


 //Letztes Edit memo1.lines.add(test+' '+inttostr(bildnr));
test:='';
  randoms[zufall]:=randoms[bildanzahl-1]; //Edit
  inc(bildanzahl,-1);
  if bildanzahl<0 then begin
    for fb:=0 to filelistbox1.items.count-1 do randoms[fb]:=fb;
    bildanzahl:=filelistbox1.items.count;
  end;

////EDIT
while (bildnr<0) or (bildnr>filelistbox1.items.count-1) do exit;

dateiname:=filelistbox1.items[bildnr];

for fi:=length(dateiname)-3 to length(dateiname) do endung:=endung+dateiname[fi];
endung:=lowercase(endung);
jpeganzeigen(dateiname,endung);
//inc(zaehl);
end;//procedure

procedure TForm1.jpeganzeigen(dateiname:TFilename;endung:string);
var jpeg: TJPEGImage;
begin
bmp := TBitmap.Create;
//Bitmaps anzeigen
if endung='.bmpthen bmp.loadfromfile(dateiname);
//Jpegs anzeigen
if (endung='.jpg') or (endung='jpeg') then begin
  jpeg := TJPEGImage.Create;
  try
    jpeg.CompressionQuality := 100; {Default Value}
    jpeg.LoadFromFile(dateiname);
    bmp.Assign(jpeg);
  finally
    jpeg.Free
  end;
end;//if
image1.picture.bitmap:=bmp;
image1.AutoSize:=true;
bmp.free;
end;//procedure;
I love DiscCat
  Mit Zitat antworten Zitat
 

Themen-Optionen Thema durchsuchen
Thema durchsuchen:

Erweiterte Suche
Ansicht

Forumregeln

Es ist dir nicht erlaubt, neue Themen zu verfassen.
Es ist dir nicht erlaubt, auf Beiträge zu antworten.
Es ist dir nicht erlaubt, Anhänge hochzuladen.
Es ist dir nicht erlaubt, deine Beiträge zu bearbeiten.

BB-Code ist an.
Smileys sind an.
[IMG] Code ist an.
HTML-Code ist aus.
Trackbacks are an
Pingbacks are an
Refbacks are aus

Gehe zu:

Impressum · AGB · Datenschutz · Nach oben
Alle Zeitangaben in WEZ +1. Es ist jetzt 19:23 Uhr.
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024-2025 by Thomas Breitkreuz