[转] WTL-Vista/Win7中内建的缓冲动画(buffered animation)
来源:互联网 发布:斐讯路由器淘宝下架 编辑:程序博客网 时间:2024/06/05 03:37
Windows Vista/Windows 7操作系统除了提供GDI双缓冲绘图内建支持外,也添加了几个API用于创建缓冲动画(buffered animation),用于在GDI程序中实现一些平滑渐变过渡的动画效果。这里有一篇文章介绍如何在Win32程序中使用这些API创建GDI动画效果:
Using the Windows Vista/Windows 7 Built-In Buffered Animation API
幸运的是,我们的WTL库也对这些新的API进行了封装,使得在WTL中应用这些API非常方便。WTL中的封装类是CBufferedAnimationImpl和CBufferedAnimationWindowImpl。
下面是一个使用CBufferedAnimationImpl创建的一个小程序,当用户按下空格键时,客户区的图片会自动切换,而且在切换时有非常平滑的“消隐渐变”(fade)的效果:
程序主窗口的源代码:
const int PIC_COUNT = 4;class CMainWindow :public CWindowImpl, public CBufferedAnimationImpl{public:typedef CMainWindow _thisClass;typedef CBufferedAnimationImpl<_thisClass,int> _baseBufAnimationImpl;BEGIN_MSG_MAP(_thisClass)MSG_WM_KEYUP(OnKeyUp)MSG_WM_CREATE(OnCreate)MSG_WM_DESTROY(OnDestroy)CHAIN_MSG_MAP(_baseBufAnimationImpl)END_MSG_MAP()CMainWindow() : _baseBufAnimationImpl(0){}int OnCreate(LPCREATESTRUCT /*lpCreateStruct*/){for (int i=0;i {m_Pictures[i] = AtlLoadGdiplusImage(IDB_BITMAP1+i,_T("JPG"));ATLASSERT(!m_Pictures[i].IsNull());}//The default duration is 500msSetDuration(400);CSize bmpSize;m_Pictures[0].GetSize(bmpSize);ResizeClient(bmpSize.cx,bmpSize.cy);CenterWindow();return 0;}void OnDestroy(){PostQuitMessage(0);}void DoPaint(CDCHandle dc, RECT& rect, int picIndex){CRect rc(rect);dc.FillSolidRect(&rc,WHITE_COLOR);CSize bmpSize;m_Pictures[picIndex].GetSize(bmpSize);CDC dcImage;dcImage.CreateCompatibleDC(dc);HBITMAP hOldBitmap = dcImage.SelectBitmap(m_Pictures[picIndex]);dc.BitBlt(0,0,bmpSize.cx,bmpSize.cy,dcImage,0,0,SRCCOPY);dcImage.SelectBitmap(hOldBitmap);}void OnKeyUp(UINT nChar, UINT /*nRepCnt*/, UINT /*nFlags*/){//Start animation if the user hit the space barif (nChar == VK_SPACE)DoAnimation(GetNextPictureIndex());}int GetNextPictureIndex(){static int picIndex = 0;picIndex = (picIndex+1)%PIC_COUNT;return picIndex;}private:CBitmap m_Pictures[PIC_COUNT];};
- [转] WTL-Vista/Win7中内建的缓冲动画(buffered animation)
- Blend的11种Animation Easing(缓冲动画)动画
- java 缓冲(Buffered。。。。)流
- 【转】WTL-Open file dialog of new vista/win7 style
- 动画缓冲或叫缓动函数(Animation Easing)
- 动画缓冲或叫缓动函数(Animation Easing)
- IO学习之使用带缓冲的字符流(Buffered)读取数据
- Animation(动画的基本原理)
- WTL双缓冲类CDoubleBufferImpl的缺陷
- WTL-双缓冲(double buffer)绘图
- Animation动画效果的实现(二)
- Unity3D之动画(Animation)的制作
- 属性动画(Property Animation)的使用
- android5.0:全新的动画(animation)
- Android的animation(动画)
- css3的animation 动画
- uiview的animation动画
- animation动画的基础知识
- 使magento的分层菜单以下拉菜单显示插件 - Improved Layered Navigation
- Magento分类页面默认图片插件-EASY TOP CENTER COLUMN IMAGE
- Magento中实现Highslide的功能-Highslide Plugin
- 可以修改Magento的订单号,Invoice,Shipment和Credit Memo号码的插件-Flex Invoice
- Magento产品更新通知顾客插件-Product Updates Notifications
- [转] WTL-Vista/Win7中内建的缓冲动画(buffered animation)
- BouncingOrange TinyMCE (WYSIWYG)的功能增强插件 - BouncingOrange TinyBrowser (file uploader/manager) for TinyMCE
- Magento的TinyMCE整合插件-BouncingOrange TinyMCE (WYSIWYG)
- Magento军用产品主题
- 一个行李类的主题,当然也可以做其他类的
- 兼容IE Firefox Opera 的禁止下载
- RTMPT 协议
- Magento快速添加产品的插件 - Quick Product Adder Client
- scapy-其中迭代器的实现细节