GDI特效3

本文介绍了四个使用GDI实现的图形特效:从上到下移动、从左到右移动、瓷砖填充和闭合效果。通过BitBlt函数进行位块传输,结合Windows系统指标调整效果。还提供了一个时钟动画特效,利用三角函数模拟指针移动。
摘要由CSDN通过智能技术生成
void CEffect::utdMove(HDC dc, HDC memdc, CRect rtReDraw)
{
	int x = 0;
	int y = 0;
	LONG i = 0;
	int nDeta =4;
	BOOL bDone =FALSE;
	
	while(!bDone)
	{
		if (i > rtReDraw.Height())
		{
			i = rtReDraw.Height();
			bDone = TRUE;
		}
		 BitBlt(dc,x,
			y,
			rtReDraw.Width(),
			i+nDeta,
			memdc,
			0,
			rtReDraw.Height()-i,
			SRCCOPY);
		    i += nDeta;

	}
}
void CEffect::ltrMove(HDC dc, HDC memdc, CRect rtReDraw)
{
	int x = 0;
	int y = 0;
	LONG i = 0;
	int nDeta =4;
	BOOL bDone =FALSE;
	
	while(!bDone)
	{
		if (i > rtReDraw.Width())
		{
			i = rtReDraw.Width();
			bDone = TRUE;
		}
		 BitBlt(dc,x,
			y,
			i+nDeta,
			rtReDraw.Height(),
			memdc,
			rtReDraw.Width()-i,
			0,
			SRCCOPY);
		i += nDeta;
	}
}
void CEffect::LRTile(HDC dc, HDC memdc, CRect rtReDraw)  
{
	int ScreenW = GetSystemMetrics(SM_CXSCREEN);
	int ScreenH = GetSystemMetrics(SM_CYSCREEN);
	int HalfW = ScreenW/2 ;
	int Left = HalfW;
	for(int i = HalfW; i <= ScreenW; i +=1 )
	{
		Left =  ScreenW - i;
		::BitBlt(dc, Left, 0, 1, ScreenH, memdc, Left, 0, SRCCOPY);
		::BitBlt(dc, i, 0, 1, ScreenH, memdc, i, 0, SRCCOPY);
	}
	::BitBlt(dc,  rtReDraw.left, rtReDraw.top, rtReDraw.Width(), rtReDraw.Height(), memdc, 0, 0, SRCCOPY);
}
void CEffect::LRClose(HDC dc, HDC memdc, CRect rtReDraw)
{
	int ScreenW = GetSystemMetrics(SM_CXSCREEN);
	int ScreenH = GetSystemMetrics(SM_CYSCREEN);
	int HalfW = ScreenW/2 ;
	int Left = HalfW;
	for(int i=0; i <= HalfW; i +=3 )
	{
		::BitBlt(dc, 0, 0, i, ScreenW, memdc, 0, 0, SRCCOPY);
	 	::BitBlt(dc, ScreenW-i, 0, i, ScreenW, memdc, ScreenW-i, 0, SRCCOPY);
	}
	::BitBlt(dc,  rtReDraw.left, rtReDraw.top, rtReDraw.Width(), rtReDraw.Height(), memdc, 0, 0, SRCCOPY);
}
void CEffect::Clock(HDC dc, HDC memdc, CRect rtReDraw)
{
	const double PI = 3.141592653589793f;
	CPoint Center(rtReDraw.Width()/2, rtReDraw.Height()/2);
	int Width = rtReDraw.Width()-Center.x;
	CPoint *point , *pointold;
	point = new CPoint[Width];
	pointold = new CPoint[Width];
	for( int k = 0; k< Width; k++ )
	{
		point[k].x= pointold[k].x = Center.x + k;
		point[k].y= pointold[k].y = 0;
	}
	int Start = GetTickCount();
	int i;
	float t;
	for(t = PI/(float)2;  t >= -PI*3/(float)2; t -= PI*(float)25/180 )
	{
		float TanValue = (float)tan(t);
		if ( TanValue < -Center.y )
			TanValue = (float)Center.x;

		for(i = 0; i<= Width; i++ )
		{
			point[i].x = Center.x + i*( t > -PI/(float)2?1:-1 );
			if ( t > -PI/(float)2&& t - PI*(float)5/180 < -PI/(float)2 )
			{
				point[i].y = rtReDraw.Height();
			}
			else if ( t - PI*(float)5/180 < -PI*3/(float)2)
			{
				point[i].y = 0;
			}
			else
			{
				point[i].y = (int)(Center.y - i*TanValue*( t > -PI/(float)2?1:-1 ) );
			}
			
			if ( point[i].y < 0 )
			{
				point[i].y = 0;
				
			}
			if ( point[i].x >= 0 && point[i].x < rtReDraw.Width() )
			{	
				::BitBlt(dc, point[i].x, min(abs(pointold[i].y), abs(point[i].y) ), 1, abs(pointold[i].y-point[i].y), 
					memdc, point[i].x, min(abs(pointold[i].y), abs(point[i].y) ), SRCCOPY);
			}
			pointold[i] = point[i];
		}	
	}
	if (rtReDraw.Width() > 720)
	   ::BitBlt(dc,0,0,rtReDraw.Width(),rtReDraw.Height(),memdc,0,0,SRCCOPY);

	delete [] point;
    delete [] pointold;
}

 
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值