Windows界面编程第十二篇 位图显示特效 飞入效果与伸展效果

转载请标明出处,原文地址: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/8696726
void 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/8696726
void 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/8696726
void 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/8696726
void 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


 

  • 7
    点赞
  • 13
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值