Exemple #1
0
        static public void D2dRelease(Direct2DInformation info)
        {
            info._bufferBack?.Dispose();
            info.View?.Dispose();

            info.ImagingFacy?.Dispose();


            info.d2DDevice?.Dispose();
            info.D2DFacy?.Dispose();
            info.dxgiDevice?.Dispose();
            info.d3DDevice?.Dispose();
        }
Exemple #2
0
        public Direct2DImage(Size2 size, int Fps)
        {
            TargetDpi = Fps;

            Speed     = 1.0d / TargetDpi;
            Width     = size.Width;
            Height    = size.Height;
            isRunning = true;



            m_d2d_info = D2dInit(size);

            buffer = new WriteableBitmap(size.Width, size.Height, 72, 72, System.Windows.Media.PixelFormats.Pbgra32, null);
        }
Exemple #3
0
        private bool isRunning = false;//指示是否正在运行

        static public Direct2DInformation D2dInit(Size2 size)
        {
            Direct2DInformation result = new Direct2DInformation();

            result.d3DDevice = new SharpDX.Direct3D11.Device(DriverType.Hardware, DeviceCreationFlags.BgraSupport);
            var __dxgiDevice = result.d3DDevice.QueryInterface <Device>();

            result.dxgiDevice = __dxgiDevice.QueryInterface <SharpDX.DXGI.Device>();
            __dxgiDevice.Dispose();

            result.D2DFacy   = new D2DFactory();
            result.d2DDevice = new SharpDX.Direct2D1.Device(result.D2DFacy, result.dxgiDevice);

            result.View        = new DeviceContext(result.d2DDevice, DeviceContextOptions.EnableMultithreadedOptimizations);
            result.ImagingFacy = new ImagingFactory();
            result._bufferBack = new D2DBitmap(result.View, size,
                                               new BitmapProperties1(new PixelFormat(Format.B8G8R8A8_UNorm, AlphaMode.Premultiplied), 72, 72, BitmapOptions.Target | BitmapOptions.CannotDraw));
            result.View.Target = result._bufferBack;

            return(result);
        }