AGB  ·  Datenschutz  ·  Impressum  







Anmelden
Nützliche Links
Registrieren
Zurück Delphi-PRAXiS Projekte Circular spectrum visualizer
Thema durchsuchen
Ansicht
Themen-Optionen

Circular spectrum visualizer

Ein Thema von EWeiss · begonnen am 22. Mär 2019 · letzter Beitrag vom 23. Jun 2019
 
EWeiss
(Gast)

n/a Beiträge
 
#33

AW: Circular spectrum visualizer

  Alt 4. Apr 2019, 13:26
Wie komme ich an die X und y Position von BitmapData? bzw. RGBQuad
Muss ich ersetzen.

GDIP_BitmapGetPixel(imgSpectrum, Integer(Col) + dx, Integer(Row) + dy, Color);

Die Farbe muss ich über die Position erfragen.

Delphi-Quellcode:
    1:
      begin
        d := round(FFade * 10);

        if GDIP_BitmapLockBits(imgSpectrum, nil, ImageLockModeRead or ImageLockModeWrite,
          PixelFormat32bppARGB, @BitmapData) = OK then
        begin
          for Row := 0 to BitmapData.Height - 1 do
          begin
            RGBQuad := Scanline(BitmapData, Row);

            for Col := 0 to BitmapData.Width - 1 do
            begin
              Pixel := RGBQuad^;

              if (Col > 0) and (Row > 0) and (Col < BitmapData.Width - 1) and
                (Row < BitmapData.Height) then
              begin
                red := 0;
                green := 0;
                blue := 0;
                alpha := 0;

                for dy := -1 to 1 do
                begin
                  for dx := -1 to 1 do
                  begin
                    GDIP_BitmapGetPixel(imgSpectrum, Integer(Col) + dx, Integer(Row) + dy, Color);

                    alpha := alpha + ( Color and $ff000000 ) shr 24;
                    red := red + ( Color and $00ff0000 ) shr 16;
                    green := green + ( Color and $0000ff00 ) shr 8;
                    blue := blue + ( Color and $000000ff );
                  end;
                end;

                red := red div 9;
                green := green div 9;
                blue := blue div 9;
                alpha := alpha div 9;

                if alpha >= d then
                  Pixel.rgbReserved := alpha - d
                else
                Pixel.rgbReserved := 0;

                Color := blue or (green shl 8) or (red shl 16);
                GDIP_BitmapSetPixel(imgSpectrum, Col, Row, Color or (alpha shl 24));
              end else
                GDIP_BitmapSetPixel(imgSpectrum, Col, Row, 0);
            end;
            GDIP_BitmapUnlockBits(imgSpectrum, @BitmapData);
          end;
        end;
      end;
Get und Set Pixel ist noch nicht ersetzt.

Das RGBQuad hole ich mir hier drüber.
Delphi-Quellcode:
  function Scanline(BitmapData : TBitmapData; Stride: integer): PRGBQuad;
  begin
    result := BitmapData.Scan0;
    inc(PByte(result), Stride * bitmapData.stride);
  end;
EDIT:

Argghh..
Ich sehe gerade in der GDIObject.pas, die machen das auch nicht anders wie ich.
Aber genau das will ich nicht.

Delphi-Quellcode:
  function TGPBitmap.GetPixel(x, y: Integer; out color: TGPColor): TStatus;
  begin
    result := SetStatus(GdipBitmapGetPixel(GpBitmap(nativeImage), x, y, color));
  end;
Welchen sinn macht das? Dann kann ich mir GDIP_BitmapLockBits sparen macht so keinen sinn.
Ich hole mir alle Pixel in einem Rutsch und muss dann doch wieder die Position des Pixel mit GdipBitmapGetPixel einholen?
Was für ein Blödsinn. Oder?

EDIT2:
Ok die Lösung ist zurück zum Array.

gruss

Geändert von EWeiss ( 4. Apr 2019 um 15:26 Uhr)
  Mit Zitat antworten Zitat
 


Forumregeln

Es ist dir nicht erlaubt, neue Themen zu verfassen.
Es ist dir nicht erlaubt, auf Beiträge zu antworten.
Es ist dir nicht erlaubt, Anhänge hochzuladen.
Es ist dir nicht erlaubt, deine Beiträge zu bearbeiten.

BB-Code ist an.
Smileys sind an.
[IMG] Code ist an.
HTML-Code ist aus.
Trackbacks are an
Pingbacks are an
Refbacks are aus

Gehe zu:

Impressum · AGB · Datenschutz · Nach oben
Alle Zeitangaben in WEZ +1. Es ist jetzt 14:33 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