Ich versuche gerade eines meiner Delphi projeckte unter Lazarus zum laufen zu bekommen, doch so ganz will es noch nicht.
Ich möchte einfach nur eine Procedure haben, die ein "Übergebenes" Bild um 90 grad dreht. Unter Delphi ja kein Problem.
Das man in Lazarus FPC mit IntfImages arbeiten mus weis ich und habe mir daher dieses monstrum hier überlegt. doch irgendwie gehts nicht. Das Bild wird nach der Rotation eindach schwarz. Könnt ihr mir meinen Fehler zeigen ?
Code: Alles auswählen
Procedure Drehen90Grad(Const Bitmap: TBitmap);
Var
tmp: Tbitmap;
TempIntfImg2, TempIntfImg: TLazIntfImage;
ImgHandle, ImgMaskHandle: HBitmap;
i, j: integer;
Begin
bitmap.pixelformat := pf24bit;
tmp := TBitmap.create;
tmp.pixelformat := pf24bit;
tmp.width := Bitmap.Height;
tmp.height := Bitmap.Width;
TempIntfImg := TLazIntfImage.Create(0, 0);
TempIntfImg.LoadFromBitmap(tmp.Handle, tmp.MaskHandle);
TempIntfImg2 := TLazIntfImage.Create(0, 0);
TempIntfImg2.LoadFromBitmap(Bitmap.Handle, Bitmap.MaskHandle);
For i := 0 To bitmap.width - 1 Do
For j := 0 To bitmap.height - 1 Do Begin
TempIntfImg.Colors[j, i] := TempIntfImg2.Colors[i, j];
End;
TempIntfImg.CreateBitmaps(ImgHandle, ImgMaskHandle, false);
tmp.Handle := ImgHandle;
tmp.MaskHandle := ImgMaskHandle;
TempIntfImg.free;
bitmap.assign(tmp);
tmp.free;
TempIntfImg2.free;
End;