本文整理自网络,侵删。
代码:
//旋转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;
相关阅读 >>
Delphi 使用tmemorystream保存多张图片到文件,并读取
Delphi android路径 tpath 文件路径,文件管理
Delphi char数组、string和pchar的相互转换
Delphi tms web core messagedlg对话框 yes no
ttreeview的两个事件ondragdrop、ondragover 实现自动拖放功能
更多相关阅读请进入《Delphi》频道 >>