예제 #1
0
        public void Start()
        {
            var bytes = File.ReadAllBytes(LargeSample);
            var gif   = Gif.Decode(bytes);

            AnimatedImage.Play(gif);
        }
예제 #2
0
        public void Start()
        {
            var path = "Assets/GifAssets/PowerGif/Examples/Samples/Small.gif";

            if (path == "")
            {
                return;
            }

            var bytes = File.ReadAllBytes(path);

            _stopwatch.Reset();
            _stopwatch.Start();

            var gif = Gif.Decode(bytes);

            UnityEngine.Debug.LogFormat("Decoded in {0:N2}s", _stopwatch.Elapsed.TotalSeconds);

            _stopwatch.Reset();
            _stopwatch.Start();

            gif.Encode();

            UnityEngine.Debug.LogFormat("Encoded in {0:N2}s", _stopwatch.Elapsed.TotalSeconds);

            AnimatedImage.Play(gif);
        }
예제 #3
0
    public void Play(Color color, System.Action finishedCallback)
    {
        m_finishedCallback = finishedCallback;
        m_image.color      = color;
        m_anim.Play();

        if (m_baseScale == 0.0f)
        {
            m_baseScale = Mathf.Abs(transform.localScale.x);
        }

        m_animScaleProgress = 0.0f;
    }
        public void Start()
        {
            var path = "Assets/GifAssets/PowerGif/Examples/Samples/Large.gif";

            if (path == "")
            {
                return;
            }

            var bytes = File.ReadAllBytes(path);
            var gif   = Gif.Decode(bytes);

            AnimatedImage.Play(gif);
        }
예제 #5
0
        public void Start()
        {
            var frames = Frames.Select(f => new GifFrame(f, 0.1f)).ToList();
            var gif    = new Gif(frames);
            var path   = UnityEditor.EditorUtility.SaveFilePanel("Save", SampleFolder, "Encoded", "gif");

            if (path == "")
            {
                return;
            }

            var bytes = gif.Encode();

            File.WriteAllBytes(path, bytes);
            Debug.LogFormat("Saved to: {0}", path);
            AnimatedImage.Play(gif);
        }
        public void Start()
        {
#if UNITY_EDITOR
            var frames = Frames.Select(f => new GifFrame(f, 0.1f)).ToList();
            var gif    = new Gif(frames);
            var path   = UnityEditor.EditorUtility.SaveFilePanel("Save", "Assets/GifAssets/PowerGif/Examples/Samples", "EncodeExample", "gif");

            if (path == "")
            {
                return;
            }

            var bytes = gif.Encode();

            File.WriteAllBytes(path, bytes);
            Debug.LogFormat("Saved to: {0}", path);
            AnimatedImage.Play(gif);
#endif
        }
        public IEnumerator Start()
        {
            var bytes        = File.ReadAllBytes(LargeSample);
            var iterator     = Gif.DecodeIterator(bytes);
            var iteratorSize = Gif.GetDecodeIteratorSize(bytes);
            var frames       = new List <GifFrame>();
            var index        = 0f;

            foreach (var frame in iterator)
            {
                frames.Add(frame);
                ProgressFill.fillAmount = ++index / iteratorSize;
                yield return(null);
            }

            var gif = new Gif(frames);

            AnimatedImage.Play(gif);
        }
예제 #8
0
        public void Start()
        {
            var bytes = File.ReadAllBytes(SmallSample);

            _stopwatch.Reset();
            _stopwatch.Start();

            var gif = Gif.Decode(bytes);

            UnityEngine.Debug.LogFormat("Decoded in {0:N2}s", _stopwatch.Elapsed.TotalSeconds);

            _stopwatch.Reset();
            _stopwatch.Start();

            gif.Encode();

            UnityEngine.Debug.LogFormat("Encoded in {0:N2}s", _stopwatch.Elapsed.TotalSeconds);

            AnimatedImage.Play(gif);
        }
예제 #9
0
        public IEnumerator Start()
        {
            var path = UnityEditor.EditorUtility.SaveFilePanel("Save", SampleFolder, "Encoded", "gif");

            if (path == "")
            {
                yield break;
            }

            var bytes        = File.ReadAllBytes(LargeSample);
            var gif          = Gif.Decode(bytes);
            var iterator     = gif.EncodeIterator();
            var iteratorSize = gif.GetEncodeIteratorSize();
            var parts        = new List <byte>();
            var index        = 0;      // 0 = first frame, 2 = second frame, penultimate index = GIF header with global color table, last index = GIF trailer

            foreach (var part in iterator)
            {
                if (index == iteratorSize - 1)                 // GIF header should be placed to sequence start!
                {
                    parts.InsertRange(0, part);
                }
                else
                {
                    parts.AddRange(part);
                }

                parts.AddRange(part);
                ProgressFill.fillAmount = ++index / (float)iteratorSize;
                yield return(null);
            }

            bytes = parts.ToArray();
            File.WriteAllBytes(path, bytes);
            Debug.LogFormat("Saved to: {0}", path);
            AnimatedImage.Play(gif);
        }