GIF动画文件在C#中有较低的帧率比他们应该 [英] Gif Animated Files in C# have Lower framerates than they should

查看:263
本文介绍了GIF动画文件在C#中有较低的帧率比他们应该的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

香港专业教育学院有一个全屏页面加载了软件的完成后运行,其中包括一个预加载gif文件....这是完全一样的一台Windows 8使用商店和地铁。
然而问题是,不管是什么gif文件的FPS和速度,C#的形式将表现出同样的,我真的不知道该怎么用它做的香港专业教育学院试图搜索网络试图获得一个解决方案,但无论我遇到了要么不清或unrelated.i真的很感激,就如何我可以修复它​​的一些信息。
I犯罪嫌疑人,不知怎的,在Visual Studio软件是忽略了FPS的gif文件我imported.but内部集成了,我不知道我怎么能fps设置为它是什么文件,或者使视觉工作室完全以无视其当涉及到file..please意见<规则; 3。

ive got a full screen loading page after my software's done running,which includes a preloader gif file .... which is exactly like the one windows 8 is using for store and metro. however the problem is that no matter what the fps and speed of the gif file is,the C# form will show the same,i really dont know what to do with it as ive tried to search the net trying to get a solution but whatever i ran into was either unclear or unrelated.i would really appreciate some info on how i can fix it. i suspect that somehow the visual studio software is ignoring the fps integrated within the gif file i imported.but i do not know how i can set the fps to what it is for the file,or make the visual studio totaly ignore its rules when it comes to that file..please advice <3

下面是对文件属性的链接即时通讯使用
http://preloaders.net/en/search/windows%208
一个从中间最上面一排......它有75帧,剩下的就是因为它是...

here is the link to the file properties im using http://preloaders.net/en/search/windows%208 the one in the middle from the top row...it has 75 frames and the rest is as it is...

即时通讯目前正在使用一个PictureBox,包括在我的项目的GIF(其内WinForm的项目)

im currently using a picturebox to include the gif in my project (its within a winform project)

推荐答案

这是一个正常的事故,GIF格式指定显示时间为10毫秒为单位的帧。但在Windows定时器,在默认情况下,都没有足够精确的时间间隔低。定时器由系统时钟中断更新,它由缺省蜱每秒64次。给定时器的精度不超过15.625毫秒更好。实际上,你的GIF将播放在2/3的速度,给予或采取。

This is a normal mishap, GIFs specify the display time for a frame in units of 10 milliseconds. But timers on Windows, by default, are not sufficiently accurate to time intervals that low. Timers are updated by the system clock interrupt, it ticks 64 times per second by default. Giving timers an accuracy no better than 15.625 milliseconds. In effect, your GIF will playback at 2/3rd speed, give or take.

您可以通过启动另一个程序改变结果,如Windows Media Player或类似浏览器Firefox或Chrome。你会突然看到你在GIF设计速度播放。

You can change the outcome by starting another program, like Windows Media Player or a browser like Firefox or Chrome. And you'll suddenly see your GIF playing back at design speed.

您将不得不做这些程序做同样的事情,改变时钟中断率获得一致播放速度。你需要的PInvoke timeBeginPeriod ,经过10提高定时器精度为10毫秒。您可能需要再低,如果你的UI线程不敏感,来不及启动定时器。 。一定要再次的PInvoke timeEndPeriod(),当你不再需要的播放,一般在FormClosed事件处理程序

You'll have to do the same thing these programs do, alter the clock interrupt rate to get consistent playback speeds. You need to pinvoke timeBeginPeriod, pass 10 to improve the timer accuracy to 10 milliseconds. You may need to go lower if your UI thread isn't responsive and starts the timer too late. Be sure to pinvoke timeEndPeriod() again when you no longer need the playback, typically in the FormClosed event handler.

样板代码:

public partial class Form1 : Form {
    public Form1() {
        InitializeComponent();
        timeBeginPeriod(timerAccuracy);
    }

    protected override void OnFormClosed(FormClosedEventArgs e) {
        timeEndPeriod(timerAccuracy);
        base.OnFormClosed(e);
    }

    // Pinvoke:
    private const int timerAccuracy = 10;
    [System.Runtime.InteropServices.DllImport("winmm.dll")]
    private static extern int timeBeginPeriod(int msec);
    [System.Runtime.InteropServices.DllImport("winmm.dll")]
    public static extern int timeEndPeriod(int msec);
}

这篇关于GIF动画文件在C#中有较低的帧率比他们应该的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆