Autor Beitrag
Tweafis
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 647

WinXP + fbsd
Delphi 5 Prof
BeitragVerfasst: Fr 06.06.03 19:43 
So, ich hab mích mal ein bisschen mit Dateien probiert, aber stehe vor folgendem Problem: Ich will aus einer Textdatei auslesen und immer wenn 1 dann weiß und wenn 0 dann schwarz. Die Datei sieht folgendermaßen aus

800
600
0000000000000...000000000111110101111111111111100000001111...00011

das erste sind die breite und höhe und dann kommen dei zeilen. Mein bisheriger code:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
procedure TForm1.FormCreate(Sender: TObject);
var picwidth, picheight: integer;
    wstr, hstr:string;
    ch: char;
    x,y:integer;

    openfile: textfile;

begin
  if Opendialog1.Execute then begin
    AssignFile(openfile, Opendialog1.Filename);
    Reset(openfile);
    readln(openfile, wstr);
    readln(openfile, hstr);
    picwidth := StrToInt(wstr);
    picheight := StrToInt(hstr);
    Image1.Width := picwidth;
    Image1.Height := picheight;
    for x:=0 to picwidth-1 do
      for y:=0 to picheight-1 do begin
        read(openfile, ch);
        case ch of
          '0':  Image1.Canvas.Pixels[x,y] := clblack;
          '1':  Image1.Canvas.Pixels[x,y] := clwhite;
        end;
      end;
    CloseFile(openfile);
  end;
end;


geht aber nicht :(

_________________
.: Es wird der Tag kommen, an dem wir es nicht mehr ändern können :.
DaFox
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 189



BeitragVerfasst: Fr 06.06.03 20:54 
Bei mir aber :)

(Sorry, habe keine Frage von Dir gelesen, auf die ich antworten konnte)

Gruß,
Markus
Tweafis Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 647

WinXP + fbsd
Delphi 5 Prof
BeitragVerfasst: Fr 06.06.03 20:56 
hmm, wenn ich ne datei hab die z.B. so aussieht:

30
30
111111111111111111111111111111
111111111111111111111111111111
111111111111111111111111111111
111111111111111111111111111111
111111111111111111111111111111
111111111111111111111111111111
111111111111111111111111111111
111111111111111111111111111111
111111111111111111111111111111
111111111111111111111111111111
111111111111111111111111111111
111111111111111111111111111111
111111111111111111111111111111
111111111111111111111111111111
111111111111111111111111111111
111111111111111111111111111111
111111111111111111111111111111
111111111111111111111111111111
111111111111111111111111111111
111111111111111111111111111111
111111111111111111111111111111
111111111111111111111111111111
111111111111111111111111111111
111111111111111111111111111111
111111111111111111111111111111
111111111111111111111111111111
111111111111111111111111111111
111111111111111111111111111111
111111111111111111111111111111
111111111111111111111111111111

dann geht das bei mir net *nommeltest*

_________________
.: Es wird der Tag kommen, an dem wir es nicht mehr ändern können :.
mars
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 238

Debian Woody, Win 2000, Win XP
D7 Ent, Kylix 3
BeitragVerfasst: Fr 06.06.03 22:30 
Am Schluss jeder Zeile musst du ein ReadLn einfügen, dann sollte es klappen.