swf转图片

// flash : AxShockwaveFlashObjects.AxshockwaveFlash

flash.LoadMovie(0, @"H:\WorkProject\guoyue\0十大古曲\1春江花月夜.swf"); flash.Play(); for (int i = 0; i < flash.TotalFrames; i++) { flash.FrameNum = i; Application.DoEvents(); var bmp = GetImageOfControl(flash); bmp.Save("d:\\backup\\" + i + ".bmp"); }

 

private  Bitmap GetImageOfControl(Control control)
        {

            //var w = control.Size.Width;
            //var h = control.Size.Height;

            var w = 1920;
            var h = 1080;


            Graphics gOfCtrl = control.CreateGraphics();
            var bmp = new Bitmap(w, h, gOfCtrl);

            Graphics gOfBmp = Graphics.FromImage(bmp);

            IntPtr dc1 = gOfCtrl.GetHdc();
            IntPtr dc2 = gOfBmp.GetHdc();

            BitBlt(dc2, 0, 0, w, h, dc1, 0, 0, 13369376);

            gOfCtrl.ReleaseHdc(dc1);
            gOfBmp.ReleaseHdc(dc2);

            gOfCtrl.Dispose();
            gOfBmp.Dispose();

            return bmp;
        }
[System.Runtime.InteropServices.DllImportAttribute("gdi32.dll")]
        private static extern bool BitBlt(
            IntPtr hdcDest,//目标设备的句柄
            int nXDest,//目标对象的左上角x坐标
            int nYDest,//目标对象的左上角Y坐标
            int nWidth,//目标对象的矩形宽度
            int nHeight,//目标对象的矩形长度
            IntPtr hdcSrc,//源设备的句柄
            int nXSrc,//源对象的左上角x坐标
            int nYSrc,//源对象的左上角y坐标
            System.Int32 dwRop//光栅的操作值
            );

 

 这样处理后每张图片都是一片黑色的,不知哪里错了

上一篇:读书笔记-代码整洁之道(一)


下一篇:useEffect与react生命周期