Einzelnen Beitrag anzeigen

EWeiss
(Gast)

n/a Beiträge
 
#64

AW: Circular spectrum visualizer

  Alt 4. Apr 2019, 10:48
Meine einfache Lösung..
Delphi-Quellcode:
  case FEffect of
    0:
      begin
        d := round(FFade * 255);

        for y := 0 to 239 do
        begin
          for x := 0 to 239 do
          begin
            GDIP_BitmapGetPixel(imgSpectrum, x, y, Color);
            SKAERO_SplitColorARGB(Color, _a, _r, _g, _b);

            a := _a;

            if a >= d then
              a := a - d
            else
            a := 0;

            c := Color and $ffffff;
            GDIP_BitmapSetPixel(imgSpectrum, x, y, (a shl 24) or c);
          end;
        end;
      end;
Wie man sich vorstellen kann ist Get\SetPixel nicht die allerbeste Methode weil zu langsam und geht extrem auf die CPU.
Also neue Methode.
Delphi-Quellcode:
  case FEffect of
    0:
      begin
        d := round(FFade * 255);

        if GDIP_BitmapLockBits(imgSpectrum, nil, ImageLockModeRead or ImageLockModeWrite,
          PixelFormat32bppARGB, @BitmapData) = OK then
        begin
          GDIP_BitmapUnlockBits(imgSpectrum, @BitmapData);

          for Row := 0 to BitmapData.Height - 1 do
          begin
            RGBQuad := Scanline(BitmapData, Row);

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

              if alpha >= d then
                alpha := alpha - d
              else
              alpha := 0;

              Color := Byte(@Pixel) and $ffffff;
              GDIP_BitmapSetPixel(imgSpectrum, Col, Row, (alpha shl 24) or Color);
              inc(RGBQuad);
            end;
          end;
      end;
GDIP_BitmapGetPixel ist Vergangenheit..
GDIP_BitmapSetPixel aber leider nicht da ich nicht weis wie ich die gesamt Farbe des Pixel an das Bitmap übergeben soll.

Wo ist mein Denkfehler, oder was verstehe ich nicht.

gruss

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