Example #1
0
////////////////////////////////////////////////////////////////////////////////
// 
// FUNCTION:	TestForAnimatedGIF
// 
// DESCRIPTION:	Check GIF/Image for avialability of animation
// 
// RETURNS:	
// 
// NOTES:		
// 
// MODIFICATIONS:
// 
// Name				Date		Version		Comments
// N T ALMOND       29012002	1.0			Origin
// 
////////////////////////////////////////////////////////////////////////////////
bool ImageEx::TestForAnimatedGIF()
{
	UINT count = 0;
	count = GetFrameDimensionsCount();
	GUID* pDimensionIDs = new GUID[count];

	// Get the list of frame dimensions from the Image object.
	GetFrameDimensionsList(pDimensionIDs, count);

	// Get the number of frames in the first dimension.
	m_nFrameCount = GetFrameCount(&pDimensionIDs[0]);

	// Assume that the image has a property item of type PropertyItemEquipMake.
	// Get the size of that property item.
	int nSize = GetPropertyItemSize(PropertyTagFrameDelay);
	if(nSize>0)
	{
		// Allocate a buffer to receive the property item.
		m_pPropertyItem = (PropertyItem*) malloc(nSize);

		GetPropertyItem(PropertyTagFrameDelay, nSize, m_pPropertyItem);

		delete  pDimensionIDs;
	}else
	{
		XTRACE("GIFͼƬ´íÎó\n");
		delete pDimensionIDs;
		return false;
	}

	return true;
}
Example #2
0
Image2::Image2(
               IN const WCHAR* filename,
               GifCallback * call_back, 
               IN BOOL useEmbeddedColorManagement// = FALSE
               )
               : Image(filename, useEmbeddedColorManagement)
               , m_gif_call_back(call_back)
               , m_gif_timer_task(*this)
               , m_gif_frame_count(0)
               , m_gif_total_delay_time(0)
               , m_gif_status(STATUS_STOP) 
               , m_gif_play_time(0)
               , m_gif_play_index(0)
{
    // 分析gif中的帧数和每帧之间的间隔时间

    int frame_dimension_count = GetFrameDimensionsCount() ;
    if (frame_dimension_count > 0)
    {
        GUID * dimension_ids = new GUID[frame_dimension_count] ;
        GetFrameDimensionsList(dimension_ids, frame_dimension_count) ;
        m_gif_frame_count = GetFrameCount(dimension_ids) ;
        delete [] dimension_ids ;

        if (m_gif_frame_count > 1)
        {
            int property_item_size = GetPropertyItemSize(PropertyTagFrameDelay) ;
            PropertyItem * items = (PropertyItem*) new char[property_item_size] ;
            GetPropertyItem(PropertyTagFrameDelay, property_item_size, items) ;

            UINT i, temp_delayed_time ;
            for (i = 0 ; i < m_gif_frame_count ; ++ i)
            {
                temp_delayed_time = *((UINT*)(items->value) + i) ;
                if (temp_delayed_time < 5) temp_delayed_time = 10 ;
                m_gif_frame_delay_times.push_back(temp_delayed_time * 10) ;
                m_gif_total_delay_time += (temp_delayed_time * 10) ;
            }

            delete [] items ;

            SelectActiveFrame(0) ;
        }
    }
}