Einzelnen Beitrag anzeigen

zeina

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

AW: Image als Tbyte umwandeln

  Alt 16. Mai 2019, 13:38
How do you rotate the image?
Do you rotate it by changing the orientation tag in jpg header?
This can be done directly in the memorystream by modifying the appropriate bytes.

Best regards
Klaus
Delphi-Quellcode:
procedure TFormFoto.rotate90(const aSource: TGraphic; Bmp: 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;

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

    for Y := 0 to SourceWidth - 1 do
    begin
      DestPixel := Bmp.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;


procedure TFormFoto.Drehennach1Click(Sender: TObject);
Var
  Bmap:Tbitmap;
begin
  Bmap := TBitmap.Create;
  try
    rotate90(Image1.Picture.Graphic, Bmap);
    Image1.Picture.Assign(Bmap);
    Panel1.Width :=Bmap.Width;
    PAnel1.Height:=Bmap.Height;
    Image1.Refresh;
  finally
    Bmap.Free;
  end;
end;
  Mit Zitat antworten Zitat