Image :: GetFrameCount将Image :: LastError设置为Win32Error C ++ GDI +

时间:2018-08-30 06:47:20

标签: c++ winapi gdi+

此功能会在一段时间后更改图像的活动帧 但是,当我尝试获取尺寸的帧数时,它将image-> lasterror设置为Win32Error

有什么办法可以解决? (Windows 10,Visual Studio 2017社区)

void PlayImageAnim(Gdiplus::Image*&image, int delay,bool Looped)
{
    using namespace Gdiplus;
    if (Looped == true)
    {
        while (true)
        {
            UINT dcount = 0;
            GUID *dimensionsIDs;
            dcount = image->GetFrameDimensionsCount();
            dimensionsIDs = new GUID[dcount];
            UINT frame_count = image->GetFrameCount(&dimensionsIDs[0]);
            int y = 0;
            GUID pageGUID = FrameDimensionTime;
            int size = image->GetPropertyItemSize(PropertyTagFrameDelay);
            Gdiplus::PropertyItem*pr_item = (Gdiplus::PropertyItem*)malloc(size);


            for (UINT i = 0; i <= frame_count; i++)
            {
                /*graphics.DrawImage(image, image_rect);*/
                /*long delay = ((long*)pr_item->value)[i] * 10;*/
                image->SelectActiveFrame(&pageGUID, i);
                std::this_thread::sleep_for(std::chrono::milliseconds(delay));
            }
            image->SelectActiveFrame(&pageGUID, 0);
        }
    }
    else
    {
        UINT dcount = 0;
        GUID *dimensionsIDs;
        dcount = image->GetFrameDimensionsCount();
        dimensionsIDs = new GUID[dcount];
        UINT frame_count = image->GetFrameCount(&dimensionsIDs[0]);

        GUID pageGUID = FrameDimensionTime;
        int size = image->GetPropertyItemSize(PropertyTagFrameDelay);
        Gdiplus::PropertyItem*pr_item = (Gdiplus::PropertyItem*)malloc(size);


        for (UINT i = 0; i <= frame_count; i++)
        {
            image->SelectActiveFrame(&pageGUID, i);
            std::this_thread::sleep_for(std::chrono::milliseconds(delay));
        }
        image->SelectActiveFrame(&pageGUID, 0);
    }
}

它与项目的其他部分具有相似的部分

0 个答案:

没有答案