当前位置:编程文档 >> DELPHI >> Delphi实现将位图旋转90度
首页

Delphi实现将位图旋转90度

所属类别:DELPHI
文章作者:sgxcn
推荐指数:★★★☆
文档人气:1
本周人气:1
发布日期:2008-9-15

写了一个将位图TBitmap顺时针旋转90度的小函数,原理很简单,就是将新图片的X,Y坐标互换,函数可以直接加在其他项目调用。

//by sgxcn  www.programbbs.com
function RotateBmp90(SrcBmp: TBitmap): TBitmap;
var
  x, y: Integer;
  DstBmp: TBitmap;
begin
  DstBmp := TBitmap.create;
  DstBmp.PixelFormat := pf24bit;
  DstBmp.Height := SrcBmp.Width;
  DstBmp.Width := SrcBmp.Height;
  for x := 0 to DstBmp.Width do
    for y := 0 to DstBmp.Height do
      DstBmp.Canvas.Pixels[x, y] := SrcBmp.Canvas.Pixels[y, SrcBmp.Height - x];
  Result := DstBmp;
end;

调用方法:
newBmp := RotateBmp90(myBmp);

由于时间关系,没有用Scanline方式,相信Scanline会提高不少执行效率,感兴趣的朋友可以自行研究。

文档说明:

     

相关文档


读取评论列表……