在winform中播放GIF

首先將GIF資源嵌入到程序集中,然後在播放的時候再取出來,具體的如下: <?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

右鍵資源管理器--添加現有項目(添加一個名爲123的GIF圖片)

選中圖片,在屬性欄中把生成操作設爲嵌入的資源

代碼:

System.Reflection.Assembly   thisExe;

thisExe   =   System.Reflection.Assembly.GetExecutingAssembly();

//WindowsApplication1爲程序集的命名空間

//123.GIF爲圖片的名字

System.IO.Stream   file   =   thisExe.GetManifestResourceStream( "WindowsApplication1.123.jpg ");

this.pictureBox1.Image   =   Image.FromStream(file);

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章