基本信息
源码名称:winform 图片查看器源码(支持:翻转/放大/缩小以及gif图片)
源码大小:0.23M
文件格式:.rar
开发语言:C#
更新时间:2016-07-09
   友情提示:(无需注册或充值,赞助后即可获取资源下载链接)

     嘿,亲!知识可是无价之宝呢,但咱这精心整理的资料也耗费了不少心血呀。小小地破费一下,绝对物超所值哦!如有下载和支付问题,请联系我们QQ(微信同号):78630559

本次赞助数额为: 2 元 
   源码介绍

using System;
using System.Collections.Generic;
using System.Text;
using System.Drawing;
using System.Drawing.Imaging;

namespace KaiwaProjects
{
    public class GifImage
    {
        private KpImageViewer KpViewer;
        private Image gif;
        private FrameDimension dimension;
        private int frameCount;
        private int rotation = 0;
        private Bitmap currentFrameBmp = null;

        public GifImage(KpImageViewer KpViewer, Image img)
        {
            this.KpViewer = KpViewer;
            this.gif = img;
            this.dimension = new FrameDimension(gif.FrameDimensionsList[0]);
            this.frameCount = gif.GetFrameCount(dimension);

            this.gif.SelectActiveFrame(dimension, 0);

            this.currentFrameBmp = (Bitmap)gif.Clone();

            UpdateAnimator();
        }

        public void UpdateAnimator()
        {
            if (KpViewer.GifAnimation)
            {
                ImageAnimator.Animate(this.gif, OnFrameChanged);
            }
            else
            {
                ImageAnimator.StopAnimate(this.gif, OnFrameChanged);
            }
        }

        public int Rotation
        {
            get { return rotation; }
        }

        public void Rotate(int rotation)
        {
            this.rotation = (this.rotation   rotation) % 360;
        }

        public void Dispose()
        {
            gif.Dispose();
        }

        private void OnFrameChanged(object o, EventArgs e)
        {
            this.currentFrameBmp = (Bitmap)gif;

            this.KpViewer.InvalidatePanel();
        }

        public Bitmap CurrentFrame
        {
            get
            {
                return currentFrameBmp;
            }
        }

        public int FrameCount
        {
            get { return frameCount; }
        }
    }
}