티스토리 뷰


제작환경
Visual Studio 2005
C++/Win32 API

그림을 확대/축소할 때 스무스하게 이루어지도록 코딩했습니다.

더블버퍼링 예제로도 도움이 될거에요. 감사합니다.


주요코드

 case WM_TIMER:
  switch(wParam)
  {
  case 1:

   if(nSampleWidth != nDestWidth)
   {
    if(bZoomMode)
    {
     nCntWidth = abs(nDestWidth - nSampleWidth);
     nSampleWidth+=(nCntWidth/7);
    }
    else
    {
     nCntWidth = abs(nDestWidth - nSampleWidth);
     nSampleWidth-=(nCntWidth/7);
    }
   }
   if(nSampleHeight != nDestHeight)
   {
    if(bZoomMode)
    {
     nCntHeight = abs(nDestHeight - nSampleHeight);
     nSampleHeight+=(nCntHeight/7);
    }
    else
    {
     nCntHeight = abs(nDestHeight - nSampleHeight);
     nSampleHeight-=(nCntHeight/7);
    }
   }
   zDelta = 0;

   BitBlt(hBackDC,0,0,rt.right-rt.left,rt.bottom-rt.top,hCleanDC,0,0,SRCCOPY);
   StretchBlt(hBackDC,0,0,nSampleWidth,nSampleHeight,hMemDC,0,0,480,640,SRCCOPY);
   
   InvalidateRect(hWnd,NULL,FALSE);

   break;
  }

  break;
 
 
 case WM_MOUSEWHEEL:
  zDelta = GET_WHEEL_DELTA_WPARAM(wParam);
  if(zDelta > 0)
  {
   nDestWidth = nSampleWidth * 5 / 4;
   nDestHeight = nSampleHeight * 5 / 4;
   bZoomMode = TRUE;
  }
  if(zDelta < 0)
  {
   nDestWidth = nSampleWidth * 4 / 5;
   nDestHeight = nSampleHeight * 4 / 5;
   bZoomMode = FALSE;
  }
  break;

댓글
공지사항
최근에 올라온 글
최근에 달린 댓글
Total
Today
Yesterday
«   2024/04   »
1 2 3 4 5 6
7 8 9 10 11 12 13
14 15 16 17 18 19 20
21 22 23 24 25 26 27
28 29 30
글 보관함