public GifPlayer() { InitializeComponent(); Gdip = this.CreateGraphics(); Looping = new Thread(() => { while (true) { if (Image != null && RenderState) { var isPlaying = CurrentState == OsuStatus.Playing; var delay = (int)(Delay / (isPlaying ? ModifierDelayMultiply : 1)); // atleast 30bpm if (delay > 2000) { delay = 2000; } Thread.Sleep(delay); if (CurrentFrame >= FrameCount) { CurrentFrame = 0; } Image.SelectActiveFrame(this.Frames, CurrentFrame++); Gdip.DrawImage(Image, new Rectangle(0, 0, this.Width, this.Height)); } Thread.Sleep(1); } }); Looping.Start(); }
private void _LoadImage(string path) { if (path == null || path.Length == 0) { return; } if (!File.Exists(path)) { return; } if (ImagePath != path) { RenderState = false; this.Image = Image.FromFile(path); this.Frames = new FrameDimension(this.Image.FrameDimensionsList[0]); FrameCount = Image.GetFrameCount(this.Frames); CurrentFrame = 0; ImagePath = path; this.Width = Image.Width; this.Height = Image.Height; try { Gdip.InterpolationMode = InterpolationMode.HighQualityBicubic; Gdip.DrawImage(Image, new Rectangle(0, 0, this.Width, this.Height)); } catch { } } }