![]() |
zu Laufzeit erstellter 2D Array mach Unsinn...
Hi Delphiler,
Mein zur Laufzeit mit lenght() bestimmter 2D Array:
Delphi-Quellcode:
macht nicht nachvollziehbaren Murks:
AssortmentAlphaMap: array of array of boolean;
mit folgender Routine möchte ich bei dem Array, der die gleichen Maße hat wie das Bild, überall dort, wo ein blaues Pixel ist den Wert auf "true" setzten. Das funktioniert wunderbar:
Delphi-Quellcode:
jetzt will ich jedoch auf Nummer sichergehen und alle die nicht blau sind auf "false" setzten:
for I := low(AssortmentAlphaMap) to high(AssortmentAlphaMap) do
begin for u := low(AssortmentAlphaMap) to high(AssortmentAlphaMap) do begin if bmp.Canvas.Pixels[u,i] = clblue then AssortmentAlphaMap[u,i]:= true; end; end;
Delphi-Quellcode:
bzw:
for I := low(AssortmentAlphaMap) to high(AssortmentAlphaMap) do
begin for u := low(AssortmentAlphaMap) to high(AssortmentAlphaMap) do begin if bmp.Canvas.Pixels[u,i] = clblue then AssortmentAlphaMap[u,i]:= true; If bmp.Canvas.Pixels[u,i] <> clblue then AssortmentAlphaMap[u,i]:= false; end; end;
Delphi-Quellcode:
jetzt stürzt aber das Programm ab (AccesViolation) Hallo???
for I := low(AssortmentAlphaMap) to high(AssortmentAlphaMap) do
begin for u := low(AssortmentAlphaMap) to high(AssortmentAlphaMap) do begin if bmp.Canvas.Pixels[u,i] = clblue then AssortmentAlphaMap[u,i]:= true else AssortmentAlphaMap[u,i]:= false; end; end; Kann mir jemand erklären warum das so ist? Wäre seeehr dankbar, MfG Spiderpig |
Re: zu Laufzeit erstellter 2D Array mach Unsinn...
Du hast die 2. Dimension vergessen. Versuch es mal so:
Delphi-Quellcode:
Evtl. musst Du u und i umdrehen, aber das hängt davon ab, wie Du die Länge festgelegt hast.
for I := low(AssortmentAlphaMap) to high(AssortmentAlphaMap) do
for u := low(AssortmentAlphaMap[i]) to high(AssortmentAlphaMap[i]) do AssortmentAlphaMap[u,i]:= bmp.Canvas.Pixels[u,i] = clblue; |
Alle Zeitangaben in WEZ +1. Es ist jetzt 12:19 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