![]() |
Bitmap nach Rotieren leer
Hallo zusammen,
ich benutze diese Routine um eine Bitmap zu drehen. Ich habe sie mehrfach im Netz und auch hier im Forum gefunden und angeblich soll sie funktionieren:
Delphi-Quellcode:
Wenn ich aber mein Image mit
procedure RotateBitmap(Bmp: TBitmap; Degs: Integer; AdjustSize: Boolean; BkColor: TColor = clNone);
var Tmp: TGPBitmap; Matrix: TGPMatrix; C: Single; S: Single; NewSize: TSize; Graphs: TGPGraphics; P: TGPPointF; begin Tmp := TGPBitmap.Create(Bmp.Handle, Bmp.Palette); Matrix := TGPMatrix.Create; try Matrix.RotateAt(Degs, MakePoint(0.5 * Bmp.Width, 0.5 * Bmp.Height)); if AdjustSize then begin C := Cos(DegToRad(Degs)); S := Sin(DegToRad(Degs)); NewSize.cx := Round(Bmp.Width * Abs(C) + Bmp.Height * Abs(S)); NewSize.cy := Round(Bmp.Width * Abs(S) + Bmp.Height * Abs(C)); Bmp.Width := NewSize.cx; Bmp.Height := NewSize.cy; end; Graphs := TGPGraphics.Create(Bmp.Canvas.Handle); try Graphs.Clear(ColorRefToARGB(ColorToRGB(BkColor))); Graphs.SetTransform(Matrix); Graphs.DrawImage(Tmp, (Cardinal(Bmp.Width) - Tmp.GetWidth) div 2, (Cardinal(Bmp.Height) - Tmp.GetHeight) div 2); finally Graphs.Free; end; finally Matrix.Free; Tmp.Free; end; end;
Delphi-Quellcode:
drehen lasse, ist das Bitmap/Image komplett leer.
RotateBitmap(image1.Picture.Bitmap,90,false);
Wahrscheinlich stehe ich nur gerade auf der Leitung, aber: Was mache ich falsch? Danke & Gruß Freejay |
Alle Zeitangaben in WEZ +1. Es ist jetzt 16:11 Uhr. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024-2025 by Thomas Breitkreuz