コード例 #1
0
        public static byte[] EncodeExample(Gif gif)
        {
            var stopwatch = new Stopwatch();

            stopwatch.Start();

            var binary = gif.Encode();

            stopwatch.Stop();

            Console.WriteLine("GIF encoded in {0:n2}s to binary.", stopwatch.Elapsed.TotalSeconds);

            return(binary);
        }
コード例 #2
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);
        }
コード例 #3
0
    IEnumerator TinyCapture()
    {
        bool rer = true;
        int  num = 0;

        while (rer)
        {
            yield return(new WaitForEndOfFrame());

            texture = new Texture2D(Screen.width, Screen.height, TextureFormat.RGB24, false);

            texture.ReadPixels(new Rect(0, 0, Screen.width, Screen.height), 0, 0);
            //texture.ReadPixels(new Rect(0, 0, 256, 256), 0, 0);
            texture.Apply();
            Vector2 tewer = new Vector2(192, 192);
            texture = ResizeTexture(texture, tewer);
            Frames.Add(texture);

            yield return(0);

            byte[] bytes     = texture.EncodeToPNG();
            string timestamp = System.DateTime.Now.ToString("dd_MM_yyyy_HH_mm_ss");

            Debug.Log(Application.dataPath + "/ScreenCapture/" + fileName + "_" + num + ".png");
            File.WriteAllBytes(Application.dataPath + "/ScreenCapture/" + fileName + "_" + num + ".png", bytes);
            num++;
            yield return(new WaitForSeconds(0.1f));

            if (num >= 10)
            {
                rer = false;
            }
        }
        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 bytes2 = gif.Encode();

        //File.WriteAllBytes(path, bytes2);
        File.WriteAllBytes(Application.dataPath + "/ScreenCapture/" + fileName + "_" + "" + ".gif", bytes2);
        //Debug.LogFormat("Saved to: {0}", path);
    }
コード例 #4
0
        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
        }