Image 컴퍼넌트를 이용하여 Form Fade-Out 기법을 주는 방법에 대해서 알아보자.

Fade-Out 효과란 영화 "조명을 끄고 완전히 어두운 상태에서 장면전환을 하는 것 암전방법에는 페이드 아웃 서서히 조명을 끄는 것 과 컷 아웃 순간적으로 조명을 끄는 것 이 있다."

Form에 Image컴퍼넌트를 올려놓고, alClient 속성을 준후 적당한 Image(Bitmap)를 로딩한후에 아래의 함수를 호출하여 Fade-Out 효과를 줄 수 있다.

Procedure FadeOut(const BMP:TImage; Pause:integer) ;
Var
  BytesPorScan : integer;
  w,h : integer;
  p : pByteArray;
  counter : integer;
Begin
  If Not (BMP.Picture.Bitmap.PixelFormat in [pf24Bit, pf32Bit]) Then
    raise exception.create('지원하지 않는 BMP 포맷입니다.') ;
  Try
    BytesPorScan:= Abs(Integer(BMP.Picture.Bitmap.ScanLine[1])
                   -Integer(BMP.Picture.Bitmap.ScanLine[0])) ;
  Except
    raise exception.create('오류') ;
  End;
  { Image 픽셀의 RGB 값을 감소시킨다. }
  For Counter:=1 to 256 Do Begin
    For h:=0 to BMP.Picture.Bitmap.Height-1 Do Begin
      P:=BMP.Picture.Bitmap.ScanLine[h];
      For w:=0 to BytesPorScan-1 Do
        If P^[w] >0 then P^[w]:=P^[w]-1;
    End;
    Sleep(Pause) ;
    BMP.Refresh;
  End;
End;

2008/07/01 09:54 2008/07/01 09:54
포스팅이 유익 하셨다면 RSS 구독을 신청하세요

Trackback Address >> http://dolba.net/tt/k2club/trackback/1865