Ich hab jetzt alles so geändert wie ich es glaube verstanden zu haben, aber das Bild dreht sich immer noch nicht.
Delphi-Quellcode:
procedure TForm1.Button1Click(Sender: TObject);
begin
bmp:=image1.Picture.Bitmap;
bmp:=rotate(bmp,67,34,5);
image1.picture.bitmap.assign(bmp);
bmp.free; //das free ist wichtig, sonst hast du ein speicherleck
end;
FUNCTION Tform1.rotate(CONST BitmapOriginal: TBitmap;
CONST iRotationAxis, jRotationAxis: INTEGER;
CONST AngleOfRotation: DOUBLE {radians} ): TBitmap;
VAR
cosTheta : EXTENDED;
i : INTEGER;
iOriginal : INTEGER;
iPrime : INTEGER;
j : INTEGER;
jOriginal : INTEGER;
jPrime : INTEGER;
RowOriginal: pRGBTripleArray;
RowRotated : pRGBTRipleArray;
sinTheta : EXTENDED;
BEGIN
RESULT := BitmapOriginal;
RESULT.Width := BitmapOriginal.Width;
RESULT.Height := BitmapOriginal.Height;
RESULT.PixelFormat := pf24bit;
cosTheta := COS(AngleOfRotation);
FOR j := RESULT.Height-1 DOWNTO 0 DO
BEGIN
RowRotated := RESULT.Scanline[j];
jPrime := j - jRotationAxis;
FOR i := RESULT.Width-1 DOWNTO 0 DO
BEGIN
iPrime := i - iRotationAxis;
iOriginal := iRotationAxis + ROUND(iPrime * CosTheta - jPrime * sinTheta);
jOriginal := jRotationAxis + ROUND(iPrime * sinTheta + jPrime * cosTheta);
IF (iOriginal >= 0) AND (iOriginal <= BitmapOriginal.Width-1) AND
(jOriginal >= 0) AND (jOriginal <= BitmapOriginal.Height-1)
THEN BEGIN
RowOriginal := BitmapOriginal.Scanline[jOriginal];
RowRotated[i] := RowOriginal[iOriginal]
END
ELSE BEGIN
RowRotated[i].rgbtBlue := 255;
RowRotated[i].rgbtGreen := 0;
RowRotated[i].rgbtRed := 0;
END
END
END
END;
euer arukas