Einzelnen Beitrag anzeigen

Alter Mann

Registriert seit: 15. Nov 2003
Ort: Berlin
934 Beiträge
 
Delphi 10.2 Tokyo Professional
 
#10

AW: Bild um 270° drehen

  Alt 20. Feb 2019, 10:09
Versuch es hiermit mal:
Delphi-Quellcode:
procedure RotateBitmap(Degree: Word; Source, Dest: TBitmap);
var
  Points: array[0..2] of TPoint;
  Angle: Double;
  X1, X2,
  Y1, Y2: integer;
begin
  if Degree <= 360 then
  begin
    Angle:= (Degree- Degree div 90* 90)/ 180* pi;
    X1:= Round(Source.Width* sin(Angle));
    X2:= Round(Source.Width* cos(Angle));
    Y2:= Round(Source.Height* sin(Angle));
    Y1:= Round(Source.Height* cos(Angle));
    Case Degree of
      0..89, 360:
      begin
        Points[1] := Point(X2, 0);//rechts oben
        Points[0] := Point(0, X1);//links oben
        Points[2] := Point(Y2, Y1+ X1);//links unten
        Dest.Width:= X2+ Y2;
        Dest.Height:= Y1+ X1;
      end;
      90..179:
      begin
        Points[1] := Point(0, Y2);//rechts oben
        Points[0] := Point(X1, Y2+ X2);//links oben
        Points[2] := Point(X1+ Y1, X2);//links unten
        Dest.Width:= Y1+ X1;
        Dest.Height:= X2+ Y2;
      end;
      180..269:
      begin
        Points[1] := Point(Y2, X1+ Y1);//rechts oben
        Points[0] := Point(Y2+ X2, Y1);//links oben
        Points[2] := Point(X2, 0);//links unten
        Dest.Width:= X2+ Y2;
        Dest.Height:= Y1+ X1;
      end;
      270..359:
      begin
        Points[1] := Point(X1+ Y1, X2);//rechts oben
        Points[0] := Point(Y1, 0);//links oben
        Points[2] := Point(0, Y2);//links unten
        Dest.Width:= Y1+ X1;
        Dest.Height:= X2+ Y2;
      end;
    end;
    PlgBlt(Dest.Canvas.Handle, Points, Source.Canvas.Handle, 0, 0, Source.Width, Source.Height, 0, 0, 0);
  end;
end;
Habe ich hier in der DP gefunden.
  Mit Zitat antworten Zitat