轉載請標明出處,原文地址:http://blog.csdn.net/morewindows/article/details/8696726
歡迎關注微博:http://weibo.com/MoreWindows
Windows介面編程之位元影像顯示特效系列目錄:
1. 《Windows介面編程第九篇位元影像顯示特效交錯效果》
http://blog.csdn.net/morewindows/article/details/8696720
2. 《Windows介面編程第十篇位元影像顯示特效百葉窗效果》
http://blog.csdn.net/morewindows/article/details/8696722
3. 《Windows介面編程第十一篇位元影像顯示特效隨機積木效果》
http://blog.csdn.net/morewindows/article/details/8696724
4. 《Windows介面編程第十二篇位元影像顯示特效飛入效果與伸展效果》
http://blog.csdn.net/morewindows/article/details/8696726
5. 《Windows介面編程第十三篇位元影像顯示特效合集》
http://blog.csdn.net/morewindows/article/details/8696730
本篇《Windows介面編程第十二篇位元影像顯示特效飛入效果與伸展效果》將講解位元影像的飛入效果與伸展效果。飛入效果與伸展效果非常常見,在《Windows介面編程第六篇動畫啟動效果(動畫效果顯示及隱藏視窗)》(http://blog.csdn.net/morewindows/article/details/8656068)可以體驗程式視窗在啟動和退出的飛入動畫效果與伸展動畫效果。
從上往下的伸展效果(圖片不能開啟,請訪問http://blog.csdn.net/morewindows/article/details/8696726)
從下往上的伸展效果(圖片不能開啟,請訪問http://blog.csdn.net/morewindows/article/details/8696726)
從左往右的飛入效果(圖片不能開啟,請訪問http://blog.csdn.net/morewindows/article/details/8696726)
從右往左的飛入效果(圖片不能開啟,請訪問http://blog.csdn.net/morewindows/article/details/8696726)
在程式設計上,只要計算好顯示座標就可以了,直接給出代碼:
// 飛入與伸展 - 從上往下//《Windows介面編程第十二篇 位元影像顯示特效 飛入效果與伸展效果》//http://blog.csdn.net/morewindows/article/details/8696726void AnimateDraw_FlyingTopToBottom(HDC hdc, HDC hdcMem, int nWidth, int nHeight, UINT nIntervalTime = 2, BOOL bFade = TRUE){int j;if (bFade){for (j = 0; j <= nHeight; j++){BitBlt(hdc, 0, 0, nWidth, j, hdcMem, 0, 0, SRCCOPY); Sleep(nIntervalTime);}}else{for (j = 0; j <= nHeight; j++){BitBlt(hdc, 0, 0, nWidth, j, hdcMem, 0, nHeight - j, SRCCOPY); Sleep(nIntervalTime);}}BitBlt(hdc, 0, 0, nWidth, nHeight, hdcMem, 0, 0, SRCCOPY);}// 飛入與伸展 - 從下往上//《Windows介面編程第十二篇 位元影像顯示特效 飛入效果與伸展效果》//http://blog.csdn.net/morewindows/article/details/8696726void AnimateDraw_FlyingBottomToTop(HDC hdc, HDC hdcMem, int nWidth, int nHeight, UINT nIntervalTime = 2, BOOL bFade = TRUE){int j;if (bFade){for (j = nHeight; j >= 0; j--){BitBlt(hdc, 0, j, nWidth, nHeight - j, hdcMem, 0, j, SRCCOPY); Sleep(nIntervalTime);}}else{for (j = nHeight; j >= 0; j--){BitBlt(hdc, 0, j, nWidth, nHeight - j, hdcMem, 0, 0, SRCCOPY); Sleep(nIntervalTime);}}BitBlt(hdc, 0, 0, nWidth, nHeight, hdcMem, 0, 0, SRCCOPY);}// 飛入與伸展 - 從左往右//《Windows介面編程第十二篇 位元影像顯示特效 飛入效果與伸展效果》//http://blog.csdn.net/morewindows/article/details/8696726void AnimateDraw_FlyingLeftToRight(HDC hdc, HDC hdcMem, int nWidth, int nHeight, UINT nIntervalTime = 2, BOOL bFade = TRUE){int i;if (bFade){for (i = 0; i <= nWidth; i++){BitBlt(hdc, 0, 0, i, nHeight, hdcMem, 0, 0, SRCCOPY); Sleep(nIntervalTime);}}else{for (i = 0; i <= nWidth; i++){BitBlt(hdc, 0, 0, i, nHeight, hdcMem, nWidth - i, 0, SRCCOPY); Sleep(nIntervalTime);}}BitBlt(hdc, 0, 0, nWidth, nHeight, hdcMem, 0, 0, SRCCOPY);}// 飛入與伸展 - 從右往左//《Windows介面編程第十二篇 位元影像顯示特效 飛入效果與伸展效果》//http://blog.csdn.net/morewindows/article/details/8696726void AnimateDraw_FlyingRightToLeft(HDC hdc, HDC hdcMem, int nWidth, int nHeight, UINT nIntervalTime = 2, BOOL bFade = TRUE){int i;if (bFade){for (i = nWidth; i >= 0; i--){BitBlt(hdc, i, 0, nWidth - i, nHeight, hdcMem, i, 0, SRCCOPY); Sleep(nIntervalTime);}}else{for (i = nWidth; i >= 0; i--){BitBlt(hdc, i, 0, nWidth - i, nHeight, hdcMem, 0, 0, SRCCOPY); Sleep(nIntervalTime);}}BitBlt(hdc, 0, 0, nWidth, nHeight, hdcMem, 0, 0, SRCCOPY);}
完整的程式在《Windows介面編程第十三篇位元影像顯示特效合集》
http://blog.csdn.net/morewindows/article/details/8696730
轉載請標明出處,原文地址:http://blog.csdn.net/morewindows/article/details/8696726
歡迎關注微博:http://weibo.com/MoreWindows