im trying to rotate a tbitmap image using scanlines, and cant figure out how to do it!
ive go it working moving pixel by pixel but i want to be able to speed it up using scanlines.
im using borland 6 C++, and doin some reasearch they (borland) gave away this sample of code of their website that does exactly it, but its in pascal and ive had trouble trying to convert the language =(
ive included the file you get from the site which does it, if anyone can help translate!
hi thanks alot! it worked wounders! i just had to change a couple of things to make it work in borland! =D
thanks very muchly =)
would it be easy to translate the reverse function (using scan lines)?
if its to much trouble thats find since you help me lots! i spent hours thursday and friday night trying to do that!!
i think its just this function:
FUNCTION FlipReverseScanLine(CONST Flip, Reverse: BOOLEAN;
CONST Bitmap: TBitmap): TBitmap;
VAR
i : INTEGER;
j : INTEGER;
RowIn : pRGBArray;
RowOut: pRGBArray;
BEGIN
IF Bitmap.PixelFormat <> pf24bit
THEN RAISE EBitmapError.Create('Can Flip/Reverse only 24-bit bitmap');
RESULT := TBitmap.Create;
RESULT.Width := Bitmap.Width;
RESULT.Height := Bitmap.Height;
RESULT.PixelFormat := Bitmap.PixelFormat;
FOR j := 0 TO Bitmap.Height-1 DO
BEGIN
RowIn := Bitmap.Scanline[j];
IF Flip
THEN RowOut := RESULT.Scanline[Bitmap.Height - 1 - j]
ELSE RowOut := RESULT.Scanline[j];
// Optimization technique: Use two FOR loops so IF is outside of inner loop
IF Reverse
THEN BEGIN
FOR i := 0 TO Bitmap.Width-1 DO
RowOut[i] := RowIn[Bitmap.Width-1-i]
END
ELSE BEGIN
FOR i := 0 TO Bitmap.Width-1 DO
RowOut[i] := RowIn[i]
END
END
END {FlipReverseScanLine};
With what I've given you already you should be able to do it yourself. I know it is tough at first but the functions are all so similar that you can do it.