Einzelnen Beitrag anzeigen

zeina

Registriert seit: 8. Jun 2018
56 Beiträge
 
#8

AW: Bild um 270° drehen

  Alt 20. Feb 2019, 09:50
Stell dir ein rechteckiges Bild vor. Such dir in diesem Bild ein Pixel (am besten am Rand) aus.
Dann dreh das Bild in deinem Kopf um 90° nach links schau dir an von wo nach wo dein Pixel wandert (X/Y-Position im Bild).
Danke Für Die Antwort.mein Programm kann ein bild nach rechts drehen.Ich würde gerne es auch nach links drehen.

Delphi-Quellcode:
type TRGBarray = array[0..0] of TRGBQuad;


procedure TFoto.rotate90(const Source:TGraphic ; Target: TBitmap);
var P: PRGBQuad;
  y, x, h, b: integer;
  Rowout: ^TRGBarray;
  sourcebmp: TBitmap;
begin
  sourcebmp := TBitmap.Create;
  try
    sourcebmp.PixelFormat := pf32bit;
    sourcebmp.Height := Source.Height;
    sourcebmp.Width := Source.Width;
    sourcebmp.Canvas.Draw(0, 0, Source);
    Target.PixelFormat := pf32bit;
    b := sourcebmp.Height;
    h := sourcebmp.Width;
    Target.Height := h;
    Target.Width := b;
    for y := 0 to (h - 1) do begin
      rowout := Target.ScanLine[y];
      p := sourcebmp.ScanLine[sourcebmp.height-1];
      inc(p, y);
      for x := 0 to (b-1) do begin
      rowout[x] := p^;
      inc(p, h);
    end;
    end;
  finally
    sourcebmp.Free;
  end;
end;
  Mit Zitat antworten Zitat