【发布时间】:2013-06-09 01:36:38
【问题描述】:
我目前有一个CView,它由一个集中的CImage 组成,它会在我的应用程序立即加载时显示。
我想通过在启动时使CImage 淡入而不是简单地显示来美化它(我已经有一个启动屏幕,所以我不问如何为CWnd 设置动画)。
为了显示我的图片,我重写了CView::OnDraw方法,如下:
void CWelcomeView::OnDraw( _In_ CDC* pDC )
{
CView::OnDraw( pDC );
static CImage backgroundImage;
static bool bImageLoaded = false;
if( !bImageLoaded )
{
backgroundImage.LoadFromResource( AfxGetInstanceHandle(), IDB_WELCOMESCREEN );
bImageLoaded = true;
}
CRect clientRect;
GetClientRect( &clientRect );
// The detination rectangle should be the same size as the image:
POINT pointTopLeft = {(clientRect.Width()-backgroundImage.GetWidth())/2, (clientRect.Height()-backgroundImage.GetHeight())/2};
CRect destRect( pointTopLeft, CSize( backgroundImage.GetWidth(), backgroundImage.GetHeight() ) );
// Draw the image in the right space:
backgroundImage.Draw( pDC->GetSafeHdc(), destRect );
}
现在我不完全确定如何在创作时淡化它。我目前的行动计划是创建一个基于std::chrono::steady_clock 的计时器,并根据当前时间点和时钟开始时间之间的差异更改CImage 的alpha 值(我将作为成员保留)多变的)。
但是,我不确定如何更改整个图像的 alpha 值?
提前致谢!
【问题讨论】: