龙
龙飞凤舞316
Unregistered / Unconfirmed
GUEST, unregistred user!
有个旋转涵数如下,如果要水平翻转,要如何改一下??
procedure RotateBmp(Bitmap: TBitmap; Angle: integer);
var
i,j: Integer;
rowIn, rowOut: pRGBTriple;
Bmp: TBitmap;
Width,Height:Integer;
begin
if not (Angle in [1..3]) then exit;
Bmp:=TBitmap.Create;
try
if Angle=2 then
begin
Bmp.Width := Bitmap.Width;
Bmp.Height :=Bitmap.Height;
end
else
begin
Bmp.Width := Bitmap.Height;
Bmp.Height := Bitmap.Width;
end;
Bmp.PixelFormat := pf24bit;
Width:=Bitmap.Width-1;
Height:=Bitmap.Height-1;
for j := 0 to Height do
begin
rowIn := Bitmap.ScanLine[j];
if Angle=1 then
for i := 0 to Width do
begin
rowOut := Bmp.ScanLine;
Inc(rowOut,Height - j);
rowOut^ := rowIn^;
Inc(rowIn);
end;
if Angle=2 then
for i := 0 to Width do
begin
rowOut := Bmp.ScanLine[Height - j];
Inc(rowOut,Width - i);
rowOut^ := rowIn^;
Inc(rowIn);
end;
if Angle=3 then
for i := 0 to Width do
begin
rowOut := Bmp.ScanLine[Width - i];
Inc(rowOut,j);
rowOut^ := rowIn^;
Inc(rowIn);
end;
end;
Bitmap.Assign(Bmp);
finally
bmp.Free;
end;
end;
procedure RotateBmp(Bitmap: TBitmap; Angle: integer);
var
i,j: Integer;
rowIn, rowOut: pRGBTriple;
Bmp: TBitmap;
Width,Height:Integer;
begin
if not (Angle in [1..3]) then exit;
Bmp:=TBitmap.Create;
try
if Angle=2 then
begin
Bmp.Width := Bitmap.Width;
Bmp.Height :=Bitmap.Height;
end
else
begin
Bmp.Width := Bitmap.Height;
Bmp.Height := Bitmap.Width;
end;
Bmp.PixelFormat := pf24bit;
Width:=Bitmap.Width-1;
Height:=Bitmap.Height-1;
for j := 0 to Height do
begin
rowIn := Bitmap.ScanLine[j];
if Angle=1 then
for i := 0 to Width do
begin
rowOut := Bmp.ScanLine;
Inc(rowOut,Height - j);
rowOut^ := rowIn^;
Inc(rowIn);
end;
if Angle=2 then
for i := 0 to Width do
begin
rowOut := Bmp.ScanLine[Height - j];
Inc(rowOut,Width - i);
rowOut^ := rowIn^;
Inc(rowIn);
end;
if Angle=3 then
for i := 0 to Width do
begin
rowOut := Bmp.ScanLine[Width - i];
Inc(rowOut,j);
rowOut^ := rowIn^;
Inc(rowIn);
end;
end;
Bitmap.Assign(Bmp);
finally
bmp.Free;
end;
end;