Delphi-PRAXiS

Delphi-PRAXiS (https://www.delphipraxis.net/forum.php)
-   Sonstige Fragen zu Delphi (https://www.delphipraxis.net/19-sonstige-fragen-zu-delphi/)
-   -   Delphi zu Laufzeit erstellter 2D Array mach Unsinn... (https://www.delphipraxis.net/136551-zu-laufzeit-erstellter-2d-array-mach-unsinn.html)

Spiderpig_GER_15 2. Jul 2009 18:13


zu Laufzeit erstellter 2D Array mach Unsinn...
 
Hi Delphiler,

Mein zur Laufzeit mit lenght() bestimmter 2D Array:
Delphi-Quellcode:
  AssortmentAlphaMap: array of array of boolean;
macht nicht nachvollziehbaren Murks:
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:
  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;
jetzt will ich jedoch auf Nummer sichergehen und alle die nicht blau sind auf "false" setzten:
Delphi-Quellcode:
  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;
bzw:
Delphi-Quellcode:
  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;
jetzt stürzt aber das Programm ab (AccesViolation) Hallo???

Kann mir jemand erklären warum das so ist?

Wäre seeehr dankbar,

MfG Spiderpig

DeddyH 2. Jul 2009 18:30

Re: zu Laufzeit erstellter 2D Array mach Unsinn...
 
Du hast die 2. Dimension vergessen. Versuch es mal so:
Delphi-Quellcode:
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;
Evtl. musst Du u und i umdrehen, aber das hängt davon ab, wie Du die Länge festgelegt hast.


Alle Zeitangaben in WEZ +1. Es ist jetzt 13:08 Uhr.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz