Autor Beitrag
toenne
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 51



BeitragVerfasst: Sa 25.10.08 22:41 
Ich habe ein SW-Bitmap als image1: www.toenne-online.de/Pics/sw-1.jpg
Mittels folgender Routine sollen die Farbwerte der Pixel zunächst in ein Array 'Farbwert' geschrieben werden und anschliessend als ASCII-Datei mit 3D-Koordinaten (Format X,Y,Z) gespeichert werden:
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:
  // Array füllen
  for y := 0 to image1.Picture.Bitmap.Height-1 do begin
    pFarbe := image1.Picture.Bitmap.ScanLine[y];
    for x := 0 to image1.Picture.Bitmap.width -1 do begin
     Farbwert[X,Y] := pFarbe^.rgbRed;
     inc(pFarbe);
    end;
  end;

  // Array schreiben
 if SaveDialog1.Execute then
 begin
  AssignFile(F,SaveDialog1.FileName);
  Rewrite(F);
  for y := 0 to image1.Picture.Bitmap.Height-1 do begin
   for x := 0 to image1.Picture.Bitmap.width-1 do begin
     str(Farbwert[X,image1.Picture.Bitmap.Height - Y]/25:5:3,StringDummy);
     StringDummy := inttostr(x) + ',' + inttostr(y) + ',' + StringDummy;
     writeln(F,StringDummy);
   end;
  end;
  CloseFile(F);
 end;


In einem anderen Programm kann ich diese Datei einlesen und als Punktewolke/Drahtgittermodell/Flächenmodell darstellen (das Prog funktioniert auch, da liegt nicht der Fehler).
Das Ergebnis: www.toenne-online.de/Pics/sw-2.jpg :?
Die Abmessungen von Quelle und Ziel sind identisch, hatte also die Ursprungsdatei 200x100 Pixel so werden im anderen Programm auch 200x100 Punkte dargestellt. Nur wird das erste Drittel des Ursprungsbild hinten wieder angehängt und die Höhe um eben jenes drittel verzerrt.

Kann mir mal jemand auf die Sprünge helfen wo mein Denkfehler ist?

Danke & Gruss
Toenne
littleDave
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 111
Erhaltene Danke: 2

Win 7
Delphi 7 Prof, Turbo Delphi, VS 2008 Team System, VS 2010 Premium
BeitragVerfasst: Sa 25.10.08 22:45 
Von welchem Typ ist denn pFarbe? PRGBTribble? Hast du dann mal image1.Picture.Bitmap.PixelFormat auf pf24Bit gesetzt?
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
var pFarbe : PRGBTribble;
{ ... }
  Image1.Picture.Bitmap.PixelFormat := pf24Bit;
  // Array füllen
  for y := 0 to image1.Picture.Bitmap.Height-1 do begin
    pFarbe := image1.Picture.Bitmap.ScanLine[y];
    for x := 0 to image1.Picture.Bitmap.width -1 do begin
     Farbwert[X,Y] := pFarbe^.rgbRed;
     inc(pFarbe);
    end;
  end;
toenne Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 51



BeitragVerfasst: Sa 25.10.08 22:53 
Zitat:
Von welchem Typ ist denn pFarbe? PRGBTribble?

Mein Gott bin ich blind - das wars!
Ich muss dazusagen dass ich zwischenzeitlich was anderes probiert und in dem Zug pFarbe als PRGBQuad deklariert hatte...und natürlich prompt vergass das wieder zu korrigieren.
Da stiert man auf den Code und stiert und stiert...und sieht sowas doch nicht :P
Du bist jedenfalls mein Held des Abends, vielen Dank!

Gruss
Toenne