轉載請標明出處,原文地址:http://blog.csdn.net/morewindows/article/details/8696724
歡迎關注微博: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介面編程第十一篇位元影像顯示特效隨機積木效果》將講解位元影像的隨機積木顯示效果。如所示
(圖片不能開啟,請訪問http://blog.csdn.net/morewindows/article/details/8696724):
在程式設計上,隨機積木效果是最簡單的啦,只要一格一格的顯示出整個位置即可:
// 隨機積木//《Windows介面編程第十一篇 位元影像顯示特效 隨機積木效果》//http://blog.csdn.net/morewindows/article/details/8696724void AnimateDraw_RandomBlocks(HDC hdc, HDC hdcMem, int nWidth, int nHeight, UINT nIntervalTime = 15, int nRowBlocks = 10, int nColBlocks = 10){int nStepRow, nStepCol, nDisplayCount;int nSumBlocks = nRowBlocks * nColBlocks;bool *pFlagArray = new bool[nSumBlocks];memset(pFlagArray, 0, sizeof(bool) * nSumBlocks);nStepRow = nWidth / nRowBlocks;nStepCol = nHeight / nColBlocks;srand((unsigned)time(NULL));nDisplayCount = 0; //已顯示方格個數while (true) { int row = rand() % nRowBlocks; int col = rand() % nColBlocks; if (pFlagArray[row * nColBlocks + col]) continue;pFlagArray[row * nColBlocks + col] = true;BitBlt(hdc, row * nStepRow, col * nStepCol, nStepRow, nStepCol, hdcMem, row * nStepRow, col * nStepCol, SRCCOPY);nDisplayCount++;if (nDisplayCount >= nSumBlocks)break;Sleep(nIntervalTime); }BitBlt(hdc, 0, 0, nWidth, nHeight, hdcMem, 0, 0, SRCCOPY);}
完整的程式在《Windows介面編程第十三篇位元影像顯示特效合集》
http://blog.csdn.net/morewindows/article/details/8696730
下一篇《Windows介面編程第十二篇位元影像顯示特效飛入效果與伸展效果》將講解位元影像的飛入效果與伸展效果。
地址:http://blog.csdn.net/morewindows/article/details/8696726
轉載請標明出處,原文地址:http://blog.csdn.net/morewindows/article/details/8696724
歡迎關注微博:http://weibo.com/MoreWindows