Einzelnen Beitrag anzeigen

Benutzerbild von sakura
sakura

Registriert seit: 10. Jun 2002
Ort: München
11.412 Beiträge
 
Delphi 11 Alexandria
 
#8

AW: Bereichsüberlauf bei rin bitmap drehen

  Alt 27. Feb 2019, 13:39
Das währe ein dynamisches Array und das geht in diesem Fall garnicht.
Stimmt
Aber das geht:
Delphi-Quellcode:
procedure Rotate90(const aSource:TGraphic; const aBmp: TBitmap);
var
  SourceBmp : TBitmap;
  SourcePixel, DestPixel: PRGBQuad;
  Y, X, SourceWidth, SourceHeight: Integer;
begin
  SourceBmp := TBitmap.Create;
  try
    SourceBmp.PixelFormat := pf32bit;
    SourceBmp.Height := aSource.Height;
    SourceBmp.Width := aSource.Width;
    SourceBmp.Canvas.Draw(0, 0, aSource);
    SourceHeight := SourceBmp.Height;
    SourceWidth := SourceBmp.Width;

    aBmp.PixelFormat := pf32bit;
    aBmp.Height := SourceWidth;
    aBmp.Width := SourceHeight;

    for Y := 0 to SourceWidth - 1 do
    begin
      DestPixel := aBmp.ScanLine[Y];
      SourcePixel := SourceBmp.ScanLine[SourceBmp.Height - 1];
      Inc(SourcePixel, Y);

      for X := 0 to SourceHeight - 1 do
      begin
        DestPixel^ := SourcePixel^;
        Inc(SourcePixel, SourceWidth);
        Inc(DestPixel);
      end;
    end;
  finally
    SourceBmp.Free;
  end;
end;
......
Daniel W.
Ich bin nicht zurück, ich tue nur so
  Mit Zitat antworten Zitat