Registriert seit: 11. Feb 2007
Ort: Bergisch Gladbach
207 Beiträge
Delphi 10.4 Sydney
|
AW: 24-Bit Bitmap um 90 grad drehen - Resourcen-Optimierung
19. Okt 2020, 10:20
Nachtrag der Vollständigkeit halber
Delphi-Quellcode:
function GDIPRotateFlipBitmap(ABitmap: tBitmap; Mode: RotateFlipType): Boolean;
var
BM: tBitmap;
GR: tGPGraphics;
AGPBitmap: tGPBitmap;
AStatus: Status;
W: Integer;
begin
if Mode = RotateNoneFlipNone then begin
Result := True;
Exit;
end;
BM := tBitmap.Create;
BM.Assign(ABitmap);
AGPBitmap := tGPBitmap.Create(BM.Handle, 0);
AGPBitmap.RotateFlip(Mode);
if (ABitmap.Width <> ABitmap.Height) and
> (Mode in [Rotate90FlipNone, Rotate270FlipNone,
> Rotate90FlipX, Rotate270FlipX,
> Rotate90FlipY, Rotate270FlipY,
> Rotate90FlipXY, Rotate270FlipXY]) then begin
W := ABitmap.Width;
ABitmap.Width := ABitmap.Height;
ABitmap.Height := W;
end;
GR := tGPGraphics.Create(ABitmap.Canvas.Handle);
GR.DrawImage(AGPBitmap, 0, 0);
AStatus := GR.GetLastStatus;
Result := (AStatus = OK);
AGPBitmap.Free;
BM.Free;
GR.Free;
end;
|
|
Zitat
|