delphi 图像翻转


代码:

//旋转90度

procedure Rotate90(const Bitmap: TBitmap);
var
i, j: Integer;
rowIn, rowOut: pRGBTriple;
Bmp: TBitmap;
Width, Height: Integer;
begin
Bmp := TBitmap.Create;
Bmp.Width := Bitmap.Height;
Bmp.Height := Bitmap.Width;
Bmp.PixelFormat := pf24bit;

Width := Bitmap.Width - 1;
Height := Bitmap.Height - 1;

for j := 0 to Height do
begin
rowIn := Bitmap.ScanLine[j];

for i := 0 to Width do
begin
rowOut := Bmp.ScanLine[i];

Inc(rowOut, Height - j);

rowOut^ := rowIn^;

Inc(rowIn);
end;
end;

Bitmap.Assign(Bmp);
end;


//旋转180度

procedure Rotate180(const Bitmap:TBitmap);

var

i,j:Integer;

rowIn,rowOut:pRGBTriple;

Bmp:TBitmap;

Width,Height:Integer;

begin

Bmp:=TBitmap.Create;

Bmp.Width := Bitmap.Width;

Bmp.Height := Bitmap.Height;

Bmp.PixelFormat := pf24bit;

Width:=Bitmap.Width-1;

Height:=Bitmap.Height-1;

for j := 0 to Height do

begin

rowIn := Bitmap.ScanLine[j];

for i := 0 to Width do

begin

rowOut := Bmp.ScanLine[Height - j];

Inc(rowOut,Width - i);

rowOut^ := rowIn^;

Inc(rowIn);

end;

end;

Bitmap.Assign(Bmp);

end;

联系电话:
020-00000000
联系电话:
020-00000000
联系电话:
020-12345678