我的程序需要每秒旋转30张图片,角度是90度或270度,现在是用ScanLine去做,但是速度太慢,有没有更高效的办法啊?

解决方案 »

  1.   

    现在我才发现类似的问题采用VMl很容易实现的~~
      

  2.   

    Delphi的程序执行javascript函数?不会吧。
      

  3.   

    看看 directx 是否有这个功能。
    或者到 www.torry.net 看看,有没有这种控件。肯定需要  mmx 指令才能快
      

  4.   

    为什么不呢?其实用javascript很简单就可以实现的
      

  5.   

    DirectX应该可以,用显卡内存怎么说也是要高效一点的
      

  6.   

    //旋转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;
      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;
      

  7.   

    //旋转270度
    procedure Rotate270(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;
      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[Width - i];
          Inc(rowOut,j);
          rowOut^ := rowIn^;
          Inc(rowIn);
        end;
      end;
      Bitmap.Assign(Bmp);
    end;
      

  8.   

    楼上,我就是用这两个方法,你可以试试一秒钟旋转25-30张一般大小的图片试试,CPU绝对上100%。
      

  9.   

    按搂住的要求,除了FastBmp和DirectX,没别的办法。
      

  10.   

    FastLIB 图像 函数 图片文件格式http://www.2ccc.com/article.asp?articleid=2059
      

  11.   

    我建议使用jackie168(三箭齐发)的算法,只是认为在循环之前需要加上一句:
      Bmp.PixelFormat:=pf24Bit;这样能大大提高效率.
      

  12.   

    循环如果在线程中做,还需要加Sleep(0)
    在主线程中做就要Application.processmessage
    这样CPU就不会100%了
      

  13.   

    把所有循环中的ScanLine全去掉,只取旋转前后位图的首地址做指针运算。procedure Rotate90(const ABitmap: TBitmap);
    var
      I, J: Integer;
      RowIn, RowOut, POut: PBGRA;
      Bmp: TBitmap;
      Width, Height: Integer;
      LineSize: Integer;
    begin
      Bmp := TBitmap.Create;
      Bmp.Width := ABitmap.Height;
      Bmp.Height := ABitmap.Width;
      ABitmap.PixelFormat := pf32Bit;
      Bmp.PixelFormat := ABitmap.PixelFormat;
      Width := ABitmap.Width-1;
      Height := ABitmap.Height-1;
      LineSize := Bmp.Width;
      RowIn := ABitmap.ScanLine[Height];
      POut := PBGRA(Cardinal(Bmp.ScanLine[0]) - 4);
      for  j := 0 to Height do
      begin
        Inc(POut);
        RowOut := POut;
        for I := 0 to Width do
        begin
          RowOut^ := RowIn^;
          Inc(RowIn);
          Dec(RowOut, LineSize);
        end;
      end;
      ABitmap.Assign(Bmp);
      Bmp.Free;
    end;>>我建议使用jackie168(三箭齐发)的算法,只是认为在循环之前需要加上一句:
    Bmp.PixelFormat:=pf24Bit;>>这样能大大提高效率.错,24位位图的旋转肯定比32位慢的多(除非是内存不够)。除了数据位数,位图数据的结构也决定了32位处理是最快的。在X86下,这就是最快的算法了。你后面说的就和算法完全无关了,任何单线程程序都会出现这情况。