Friday, June 08, 2007

.
.
.
type
EBitmapError = Class(Exception);
TRGBArray = array[0..0] of TRGBTriple;
pRGBArray = ^TRGBArray;
.
.
.

procedure MirrorVertical(Bitmap: TBitmap);
var
i, j, w : integer;
RowIn : pRGBArray;
RowOut : pRGBArray;
begin
w := Bitmap.Width * SizeOf(TRGBTriple);
GetMem(RowIn, w);
for j := 0 to Bitmap.Height - 1 do
begin
Move(Bitmap.ScanLine[j]^, RowIn^, w);
RowOut := Bitmap.ScanLine[j];
for i := 0 to Bitmap.Width -1 do RowOut[i] := RowIn[Bitmap.Width -1 - i];
end;
Bitmap.Assign(Bitmap);
FreeMem(RowIn);
end;

procedure MirrorHorizontal(Bitmap: TBitmap);
var
j, w :integer;
Tmp :Tbitmap;
begin
Tmp := TBitmap.Create;
Tmp.Width := Bitmap.Width;
Tmp.Height := Bitmap.Height;
Tmp.PixelFormat := Bitmap.PixelFormat;
w := Bitmap.Width * SizeOf(TRGBTriple);
for j := 0 to Bitmap.Height - 1 do Move(Bitmap.ScanLine[j]^, Tmp.ScanLine[Bitmap.Height -1 -j]^, w);
Bitmap.Assign(Tmp);
Tmp.Free;
end;

Labels: