GDI+里如何使用gif

来源:百度知道 编辑:UC知道 时间:2024/09/23 06:28:16
如题

Graphics graphics(&dc); // Create a GDI+ graphics object

Image image(L"Test.Gif"); // Construct an image
graphics.DrawImage(&image, 0, 0, image.GetWidth(), image.GetHeight());
Gif分为两种,一种是静态的,对于这种格式的Gif,在GDI+中无需采用任何方法就能够直接显示(上面的代码就属于这种情况)。另一种是动态的, 这种文件能够显示简单的动画。动态的实际上由多幅静态的组成,在显示Gif时,每幅图片按照一定的时间间隔依次进行显示,从而实现了动画效果。首先要做的工作是判断GIF是动态的还是静态的。
UINT count = 0;
count = GetFrameDimensionsCount();
GUID* pDimensionIDs = new GUID[count];

// 得到子帧的对象列表
GetFrameDimensionsList(pDimensionIDs, count);

//获取总帧数
m_nFrameCount = GetFrameCount(&pDimensionIDs[0]);

// 假设图像具有属性条目 PropertyItemEquipMake.
// 获取此条目的大小.
int nSize = GetPropertyItemSize(PropertyTagFrameDelay);

// 为属性条目分配空间.
m_pPropertyItem = (PropertyItem*) malloc(nSize);
//m_pPropertyItem为PropertyItem*<