C++Builder Programming Forum
C++Builder  |  Delphi  |  FireMonkey  |  C/C++  |  Free Pascal  |  Firebird
볼랜드포럼 BorlandForum
 경고! 게시물 작성자의 사전 허락없는 메일주소 추출행위 절대 금지
C++빌더 포럼
Q & A
FAQ
팁&트릭
강좌/문서
자료실
컴포넌트/라이브러리
메신저 프로젝트
볼랜드포럼 홈
헤드라인 뉴스
IT 뉴스
공지사항
자유게시판
해피 브레이크
공동 프로젝트
구인/구직
회원 장터
건의사항
운영진 게시판
회원 메뉴
북마크
볼랜드포럼 광고 모집

C++빌더 Q&A
C++Builder Programming Q&A
[15636] Re:[질문] Rect 그릴때에 일반적인거 말고 그라데이션 효과주려면?
방태윤 [nabty] 984 읽음    2002-02-19 18:48
void __fastcall DrawClientWindow (HDC &Hdc)
{
  // this routine paints a gradient background that slowly
  // changes from StartColor at the top to black at the bottom
  const int    NumGradients = 64;   // number of shading levels
  const TColor StartColor = clBlue; // initial color

  TRect rect ;                      // calculate size of backgnd
  ::GetClientRect (Form1->Handle, (RECT *) &rect) ;

  // painting a shaded gradient is slow, and can cause flickering
  // eliminate flicker by using memory bitmaps and BitBlit
  Graphics::TBitmap *MemBitmap = new Graphics::TBitmap;
  MemBitmap->Width = rect.Right - rect.Left;
  MemBitmap->Height= rect.Bottom- rect.Top;
  MemBitmap->Canvas->Brush->Style = bsSolid;
  MemBitmap->Canvas->Brush->Color = clBlack;
  MemBitmap->Canvas->FillRect(Rect(0,0,
                                   MemBitmap->Width,
                                   MemBitmap->Height));
  // calculate the height of each little gradient section
  int GradientHeight = MemBitmap->Height / NumGradients;

  // calculate individual RGB intensities of the starting color.
  int InitialRed   = GetRValue(StartColor);
  int InitialGreen = GetGValue(StartColor);
  int InitialBlue  = GetBValue(StartColor);
  int RedIncrement  = (InitialRed + 1)  / NumGradients; // calculate
  int GreenIncrement= (InitialGreen + 1)/ NumGradients; // increment of
  int BlueIncrement = (InitialBlue + 1) / NumGradients; // each gradient

  TColor FillColor;
  // the for loop draws each gradient section. the loop stops one pass
  // away from black because black was drawn by FillRect above
  for (int j=0;j< NumGradients;j++)
  {
    rect.Bottom = rect.Top + GradientHeight;
    FillColor = (TColor) RGB( InitialRed   -(RedIncrement * j),
                              InitialGreen -(GreenIncrement* j),
                              InitialBlue  -(BlueIncrement * j));
    MemBitmap->Canvas->Brush->Color = FillColor;
    MemBitmap->Canvas->FillRect(rect);
    rect.Top += GradientHeight;
  }
  // Use API BitBlt to copy pixels to the screen.
  ::BitBlt(Hdc,0,0,MemBitmap->Width, MemBitmap->Height,
           MemBitmap->Canvas->Handle,0,0,SRCCOPY);
  delete MemBitmap; // delete the temporary bitmap.
}
void __fastcall TForm1::Button1Click(TObject *Sender)
{
  DrawClientWindow(Canvas->Handle);
}
<출처를알수없음>

박용우 님이 쓰신 글 :
: 그라데이션 효과 아시죠..
: 점점 진해진다든지 점점 밝아지는 그런 효과를 주려고하는데
: 어떻게 하시는지 아시는분
: 캔버스에 사각형을 그리고 싶어요 입체감있게 보이는.

+ -

관련 글 리스트
15632 [질문] Rect 그릴때에 일반적인거 말고 그라데이션 효과주려면? 박용우 781 2002/02/19
15636     Re:[질문] Rect 그릴때에 일반적인거 말고 그라데이션 효과주려면? 방태윤 984 2002/02/19
15641         Re:Re:[질문] 고마워요 덕분에 문제가 쉽게 해결되었습니다.. 감사합니다 박용우 835 2002/02/19
Google
Copyright © 1999-2015, borlandforum.com. All right reserved.