能否实现图像的“余辉”效果?
用一条扫描线从左到右扫描图像,扫描线处的图案显示出来,并且亮度最高,当扫描线离开时,亮度逐渐降低,直至消失。

解决方案 »

  1.   

    没人愿意写代码,我就写点,顺便加到我的图像处理库中。基本原理很简单,就是使用了图像的Alpha混合原理。到我的资源中去下载:http://download.csdn.net/source/754773关键部分代码:
    procedure TFadeThread.DrawImage;
    var
      pSrcLine: PByteArray;
      pDstLine: PByteArray;
      nAlpha  : BYTE;
      nStep   : BYTE;
      nTmp    : BYTE;
      nRow, nCol: Integer;
    begin
      nStep:= 255 div FadeWidth;  // Clear old images
      FBufBmp.Canvas.Pen.Color  := clBlack;
      FBufBmp.Canvas.Brush.Color:= clBlack;
      FBufBmp.Canvas.Rectangle(0, 0, FBufBmp.Width, FBufBmp.Height);  for nRow:= 0 to FBufBmp.Height - 1 do
      begin
        pSrcLine:= FBkBmp.ScanLine[nRow];
        pDstLine:= FBufBmp.ScanLine[nRow];    nAlpha:= 0;
        for nCol:= FCurCol to FBufBmp.Width - 1 do
        begin
          inc(nAlpha);
          if (nAlpha > FadeWidth) then break;      if nCol < 0 then continue;      nTmp:= nStep * nAlpha;
          pDstLine[nCol * 3    ]:= nTmp * pSrcLine[nCol * 3    ] div 255;
          pDstLine[nCol * 3 + 1]:= nTmp * pSrcLine[nCol * 3 + 1] div 255;
          pDstLine[nCol * 3 + 2]:= nTmp * pSrcLine[nCol * 3 + 2] div 255;
        end;
      end;  inc(FCurCol);  if (FCurCol > FBufBmp.Width - 1) then FCurCol:= -FadeWidth;
    end;