コード例 #1
0
        public ImageWindow()
        {
            InitializeComponent();

            this._gifPlayer = new GifPlayer();
            this._gifPlayer.AddWeakImageSourceChangedHandler(_gifPlayer_ImageSourceChanged);
        }
コード例 #2
0
 private void TKImage_Unloaded(object sender, RoutedEventArgs e)
 {
     if (this._gifPlayer != null)
     {
         this._gifPlayer.Dispose();
         this._gifPlayer = null;
     }
 }
コード例 #3
0
    private void SetupGifPlayer(ITexture asset)
    {
        if (!(asset is Asset_Gif gifAsset))
        {
            return;
        }

        gifPlayer = new GifPlayer(gifAsset);
        gifPlayer.Play();
        gifPlayer.OnFrameTextureChanged += UpdateTexture;
    }
コード例 #4
0
            //callback function which calls after change src
            private static void on_animated_changed(DependencyObject obj, DependencyPropertyChangedEventArgs args)
            {
                GifPlayer player = (GifPlayer)obj;

                player.update_src();
                RoutedPropertyChangedEventArgs <Bitmap> e = new RoutedPropertyChangedEventArgs <Bitmap>((Bitmap)args.OldValue,    //call listeners functions
                                                                                                        (Bitmap)args.NewValue,
                                                                                                        Animated_Bitmap_Changed_Event);

                player.on_animated_source_changed(e);
            }
コード例 #5
0
 public static void curtain_fx(Panel Element, System.Windows.Media.Brush CurtainColor, Bitmap bmp)                   //show curtain fx with animation
 {
     if (Load_Curtain == null)
     {
         Load_Curtain = new DockPanel();
         Load_Curtain.SetValue(Panel.ZIndexProperty, 99);
         GifPlayer player = new GifPlayer(bmp);
         player.Stretch          = System.Windows.Media.Stretch.None;
         Load_Curtain.Background = CurtainColor;
         Load_Curtain.Opacity    = 0.4;
         Load_Curtain.Children.Add(player);
         Element.Children.Add(Load_Curtain);
     }
 }
コード例 #6
0
 private void FrmGif_Load(object sender, EventArgs e)
 {
     _gif = new GifPlayer(pbImg);
     _gif.Play(AppDomain.CurrentDomain.BaseDirectory + "\\gif\\ScanQRInfo.gif", 3);
 }
コード例 #7
0
 void Start()
 {
     _gif = gameObject.AddComponent <GifPlayer>();
     _gif.SetGifPath(_path);
 }
コード例 #8
0
        public static INFTAsset CreateAsset(ITexture asset, NFTShapeConfig shapeConfig,
                                            Action <Texture2D> textureUpdateCallback, GifPlayer gifPlayer)
        {
            if (asset == null)
            {
                return(null);
            }

            if (asset is Asset_Gif gif)
            {
                return(new NFTGifAsset(gif, shapeConfig.hqGifResolution, gifPlayer));
            }

            return(new NFTImageAsset(asset, shapeConfig.hqImgResolution, textureUpdateCallback));
        }
コード例 #9
0
    IEnumerator Start()
    {
        rootDirectory = Application.dataPath + "/../";

        if (Application.platform == RuntimePlatform.OSXEditor || Application.platform == RuntimePlatform.OSXPlayer)
        {
            useWebMInsteadOfMp4 = true;
        }

        if (Application.platform == RuntimePlatform.OSXPlayer)
        {
            // OSX の場合にはアプリが別のパスに隔離されてしまうので問い合わせが必要
            var dir   = PlayerPrefs.HasKey("RootDirectory") ? PlayerPrefs.GetString("RootDirectory") : "";
            var paths = StandaloneFileBrowser.OpenFilePanel("audio.wav を選択してください", dir, "wav", false);
            if (paths.Length == 0)
            {
                Application.Quit();
                yield break;
            }

            rootDirectory = Uri.UnescapeDataString(Path.GetDirectoryName(paths[0]).Replace("file:", "") + "/");
            PlayerPrefs.SetString("RootDirectory", rootDirectory);
        }


        print("rootDir:" + rootDirectory);

        if (File.Exists(GetFilePath("background.png")))
        {
            print(GetFilePath("background.png"));
            var imageWWW = new WWW("file://" + GetFilePath("background.png"));
            yield return(imageWWW);

            image.texture = imageWWW.texture;
            SetResolution(imageWWW.texture.width, imageWWW.texture.height);
        }
        else if (File.Exists(GetFilePath("background.jpg")))
        {
            print(GetFilePath("background.jpg"));
            var imageWWW = new WWW("file://" + GetFilePath("background.jpg"));
            yield return(imageWWW);

            image.texture = imageWWW.texture;
            SetResolution(imageWWW.texture.width, imageWWW.texture.height);
        }
        else if (File.Exists(GetFilePath("background.gif")))
        {
            print(GetFilePath("background.gif"));
            var imageWWW = new WWW("file://" + GetFilePath("background.gif"));
            yield return(imageWWW);

            yield return(StartCoroutine(UniGif.GetTextureListCoroutine(imageWWW.bytes, (gifTexList, loopCount, width, height) =>
            {
                SetResolution(width, height);
                gifPlayer = GifPlayer.Create(image, gifTexList);
            })));
        }
        else
        {
            SetResolution(720, 304);
        }

        print(GetFilePath("audio.wav"));
        var audiosource = gameObject.AddComponent <AudioSource>();
        var audioWWW    = new WWW("file://" + GetFilePath("audio.wav"));

        yield return(audioWWW);

        audiosource.clip = audioWWW.GetAudioClip(false);

        var recorder = mp4Recorder;

        if (useWebMInsteadOfMp4)
        {
            recorder = webMRecorder;
        }

        recorder.outputDir = new DataPath(GetFilePath("Movie"));

        recorder.BeginRecording();
        if (gifPlayer != null)
        {
            gifPlayer.PlaySyncWith(audiosource);
        }
        audiosource.Play();
        print(LastPath);
        yield return(new WaitWhile(() => audiosource.isPlaying));

        recorder.EndRecording();

        yield return(new WaitForSeconds(2f));

        if (useWebMInsteadOfMp4)
        {
            var webmPath     = "\"" + LastPath + ".webm" + "\"";
            var mp4Path      = "\"" + LastPath + ".mp4" + "\"";
            var exeExtension = Application.platform == RuntimePlatform.WindowsEditor || Application.platform == RuntimePlatform.WindowsPlayer ? ".exe" : "";
            var process      = Process.Start(GetFilePath("ffmpeg/ffmpeg" + exeExtension), "-i " + webmPath + " " + mp4Path);
            process.WaitForExit();
            File.Delete(LastPath + ".webm");
        }

        Application.Quit();
    }
コード例 #10
0
 public NFTGifAsset(Asset_Gif previewGif, int hqResolution, GifPlayer gifPlayer)
 {
     this.previewGif   = previewGif;
     this.hqResolution = hqResolution;
     this.gifPlayer    = gifPlayer;
 }