Gif в C#
Формулировка задачи:
Можно ли будет добавить в приложение изображение формата gif и запускать его проигрывание с интервалом?
Например, я хочу сделать часы в стиле HTC и для этого создам guf-анимацию с перелистыванием часов, а в си шарпе это нужно настроить на минутный интервал
Решение задачи: «Gif в C#»
textual
Листинг программы
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Media;
using System.IO;
namespace Alarm
{
public partial class Form1 : Form
{
Bitmap animatedImage;
Boolean currentlyAnimating;
public Form1()
{
InitializeComponent();
animatedImage = new Bitmap("C:\\watch.gif");
currentlyAnimating = false;
}
public void AnimateImage()
{
if (!currentlyAnimating)
{
ImageAnimator.Animate(animatedImage, new EventHandler(this.OnFrameChanged));
currentlyAnimating = true;
}
}
private void OnFrameChanged(object o, EventArgs e)
{
this.Invalidate();
}
protected override void OnPaint(PaintEventArgs e)
{
AnimateImage();
ImageAnimator.UpdateFrames();
e.Graphics.DrawImage(this.animatedImage, new Point(0, 0));
}
public sealed class GifBitmapDecoder : BitmapDecoder
{
Stream qqq = new FileStream("C:\\Watch.gif", FileMode.Open, FileAccess.Read);
GifBitmapDecoder decoder = new GifBitmapDecoder(qqq);
}
}
}