從 SWF 文件中截取圖片

此操作需要藉助於 SWFToImage 組件,此組件需註冊。

 

代碼如下:

 

        /// <summary>
        /// 截取指定 SWF 文件的縮略圖
        /// </summary>
        /// <param name="Filename">string 文件名</param>
        /// <param name="Thumb">string 縮略圖</param>
        /// <param name="Width">int 寬度</param>
        /// <param name="Height">int 高度</param>
        public bool GetThumbBySWF(string Filename, string Thumb, int Width, int Height)
        {
            SWFToImage.SWFToImageObject _swfImage = new SWFToImage.SWFToImageObject();
            _swfImage.InputSWFFileName = Filename;
            _swfImage.ImageWidth = Width;
            _swfImage.ImageHeight = Height;
            _swfImage.ImageOutputType = SWFToImage.TImageOutputType.iotJPG;
            try
            {
                _swfImage.Execute();
                _swfImage.SaveToFile(Thumb);
                return true;
            }
            catch
            {
                return false;
            }
            finally
            {
                _swfImage = null;
            }

        }

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