![]() |
Re: Totale Pointer-Verwirrung
Zitat:
Einen hab ich noch. Ich bin jetzt ziemlich weit gekommen, bloß mit dem Indexzugriff klappt es noch nicht. Ich habe mal ein Beispielprogramm erstellt:
Delphi-Quellcode:
program Project1; {$APPTYPE CONSOLE} uses SysUtils; const width = 4; const height = 4; const mapsused = 4; type TLayer = array of double; //Feld von doubles type pTLayer = ^TLayer; //Zeiger auf eben jenes type TMap = array of pTLayer; //Feld von Zeigern var map : TMap; i : Integer; x,y : Integer; srcmap : pTLayer; srcline : pTLayer; begin GetMem(map, mapsused*sizeof(TLayer)); for i := 0 to mapsused-1 do begin GetMem(map[i], width*height*sizeof(double)); end; srcmap := map[0]; for y := 0 to height-1 do begin srcline := srcmap; Inc(srcline, y*width); for x := 0 to width-1 do begin srcline^[x] := 1.0; // <--- Hier krachts end; end; for i := 0 to mapsused-1 do begin FreeMem(map[i], width*height*sizeof(double)); end; FreeMem(map, mapsused*sizeof(TLayer)); end. Könnte mir bitte jemand den Knoten ausm Kopf nehmen? Danke! :gruebel: |
Re: Totale Pointer-Verwirrung
Ich schon wieder :lol:
Ich habs jetzt soweit:
Delphi-Quellcode:
Ich hätte jetzt nur noch gerne map[0,y*width+x] ersetzt, daß man nur noch srcline[x] schreiben muß. Wie ich es jetzt hier gemacht habe gehts nicht: 'Incompatible types'program Project1; {$APPTYPE CONSOLE} uses SysUtils; const width = 5; const height = 5; const mapsused = 5; type TLayer = array of double; //Feld von doubles type TMap = array of array of double; //Feld von Zeigern var map : TMap; i : Integer; x,y : Integer; srcline : array of double; begin SetLength(map, mapsused); for i := 0 to mapsused-1 do begin SetLength(map[i], width*height); end; for y := 0 to height-1 do begin srcline := map[0]; // <--- 'Incompatible types' for x := 0 to width-1 do begin map[0,y*width+x] := 1.0; end; end; for i := 0 to mapsused-1 do begin map[i] := nil; end; map := nil; end. Jemand noch eine Idee? |
Re: Totale Pointer-Verwirrung
Zitat:
|
Re: Totale Pointer-Verwirrung
Ich habs jetzt so gelöst:
Delphi-Quellcode:
also mit src := @FMap[outmap, FWidth*y];Procedure TImgProc.Byte2double(outmap : integer; img : TBitmap); var x,y : Integer; line : PByteArray; src : pDouble; begin if(img.PixelFormat <> pf8bit) then exit; for y := 0 to FHeight-1 do begin line := img.ScanLine[y]; src := @FMap[outmap, FWidth*y]; for x := 0 to FWidth-1 do begin src^ := line[x]; Inc(src); // FMap[outmap, y*FWidth+x] := line[x]; end; end; end; So richtig gefällt es mir nicht, aber geht erstmal. |
Alle Zeitangaben in WEZ +1. Es ist jetzt 18:59 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