Exemple #1
0
 public sd.Bitmap GetBitmap(sd.RenderTarget target)
 {
     if (targetBitmap == null || !Equals(targetBitmap.Tag, target.NativePointer))
     {
         if (targetBitmap != null)
         {
             targetBitmap.Dispose();
         }
         targetBitmap     = CreateDrawableBitmap(target);
         targetBitmap.Tag = target.NativePointer;
     }
     return(targetBitmap);
 }
Exemple #2
0
        public unsafe void UpdateData(Image image)
        {
            if ((image is System.Drawing.Bitmap) == false)
            {
                return;
            }

            lock (mData)
            {
                if (image.Width != mWidth || image.Height != mHeight)
                {
                    if (mBitmap != null)
                    {
                        mBitmap.Dispose();
                    }
                    mData.Dispose();
                    mData   = new DataStream(image.Width * image.Height * 4, true, true);
                    mWidth  = image.Width;
                    mHeight = image.Height;

                    mBitmap = new Bitmap(InterfaceManager.Instance.Surface.RenderTarget, new Size2(mWidth, mHeight),
                                         mProperties);
                }

                mData.Position = 0;
                var data = new byte[mWidth * mHeight * 4];
                fixed(byte *ptr = data)
                {
                    var bmp  = (System.Drawing.Bitmap)image;
                    var bmpd = bmp.LockBits(new System.Drawing.Rectangle(0, 0, mWidth, mHeight),
                                            ImageLockMode.ReadOnly, System.Drawing.Imaging.PixelFormat.Format32bppArgb);


                    UnsafeNativeMethods.CopyMemory(ptr, (byte *)bmpd.Scan0.ToPointer(),
                                                   mWidth * mHeight * 4);
                    bmp.UnlockBits(bmpd);
                }

                if (mProperties.PixelFormat.AlphaMode == AlphaMode.Premultiplied)
                {
                    for (var i = 0; i < mWidth * mHeight * 4; i += 4)
                    {
                        data[i]     = (byte)(data[i] * data[i + 3] / 255.0f);
                        data[i + 1] = (byte)(data[i + 1] * data[i + 3] / 255.0f);
                        data[i + 2] = (byte)(data[i + 2] * data[i + 3] / 255.0f);
                    }
                }

                mBitmap.CopyFromMemory(data, mWidth * 4);
            }
        }
Exemple #3
0
 public void Dispose()
 {
     if (DX_Child != null)
     {
         DX_Child.Clear();
         GC.SuppressFinalize(DX_Child);
     }
     if (gaussian != null)
     {
         gaussian.Dispose();
     }
     BitmapBuffer.Dispose();
     DX_Core.DisposeSwapChain(ref com);
     GC.SuppressFinalize(this);
 }
Exemple #4
0
        void DrawToWindow()
        {
            while (_queue.Count != 0)
            {
                if (_queue.TryTake(out SharpDX.Direct2D1.Bitmap bitmap) == true)
                {
                    if (_lastBitmap != null)
                    {
                        _lastBitmap.Dispose();
                    }

                    _lastBitmap = bitmap;
                }

                if (_lastBitmap == null)
                {
                    return;
                }

                _renderTarget.Render(
                    (renderer) =>
                {
                    renderer.DrawBitmap(_lastBitmap, 1.0f, BitmapInterpolationMode.Linear);
                });

                Captured?.Invoke(this, new CapturedEventArgs(_lastBitmap, _dataStream));
            }
        }
Exemple #5
0
        private void UnloadResources()
        {
            m_compositeEffect.Dispose();
            m_affineTransformEffect.Dispose();
            m_ShadowFullScreen.Dispose();
            m_Shadow.Dispose();
            m_Bitmap1FullScreen.Dispose();
            m_Bitmap1.Dispose();
            fontFamily.Dispose();
            m_textFormat15.Dispose();
            m_textFormat10.Dispose();
            roundedRecInColor.Dispose();
            roundedRecOutColor.Dispose();
            m_textBrush.Dispose();

            if (m_TitleName != null)
            {
                m_TitleName.Dispose();
            }
            if (m_VideoBitmap != null)
            {
                m_VideoBitmap.Dispose();
            }
            if (m_CDGBitmap != null)
            {
                m_CDGBitmap.Dispose();
            }
        }
Exemple #6
0
        private static Bitmap LoadBitmapFromMemory(RenderTarget device, byte[] bytes)
        {
            if (device == null)
            {
                throw new ArgumentNullException(nameof(device));
            }
            if (bytes == null)
            {
                throw new ArgumentNullException(nameof(bytes));
            }
            if (bytes.Length == 0)
            {
                throw new ArgumentOutOfRangeException(nameof(bytes));
            }

            Bitmap            bmp       = null;
            MemoryStream      stream    = null;
            BitmapDecoder     decoder   = null;
            BitmapFrameDecode frame     = null;
            FormatConverter   converter = null;

            try
            {
                stream  = new MemoryStream(bytes);
                decoder = new BitmapDecoder(ImageFactory, stream, DecodeOptions.CacheOnDemand);

                bmp = ImageDecoder.Decode(device, decoder);

                decoder.Dispose();
                stream.Dispose();

                return(bmp);
            }
            catch
            {
                if (converter?.IsDisposed == false)
                {
                    converter.Dispose();
                }
                if (frame?.IsDisposed == false)
                {
                    frame.Dispose();
                }
                if (decoder?.IsDisposed == false)
                {
                    decoder.Dispose();
                }
                if (stream != null)
                {
                    TryCatch(() => stream.Dispose());
                }
                if (bmp?.IsDisposed == false)
                {
                    bmp.Dispose();
                }

                throw;
            }
        }
        public void Dispose()
        {
            Target?.Dispose();
            Bitmap?.Dispose();
#if DEBUG
            _redBrush?.Dispose();
#endif
        }
Exemple #8
0
 protected override void DisposeDirectXResources()
 {
     lock (this)
     {
         _bitmap?.Dispose();
         _bitmap = null;
     }
     base.DisposeDirectXResources();
 }
Exemple #9
0
 public void Dispose()
 {
     if (_disposed)
     {
         return;
     }
     _disposed = true;
     _bmp.Dispose();
 }
Exemple #10
0
        /// <summary>
        /// Releases all resources used by this Image.
        /// </summary>
        /// <param name="disposing">A Boolean value indicating whether this is called from the destructor.</param>
        protected virtual void Dispose(bool disposing)
        {
            if (!disposedValue)
            {
                Bitmap?.Dispose();

                disposedValue = true;
            }
        }
Exemple #11
0
 public override void Dispose()
 {
     _defaultBg?.Dispose();
     _coverBg?.Dispose();
     _oldBg?.Dispose();
     _newBg?.Dispose();
     _newBgObj?.Dispose();
     _oldBgObj?.Dispose();
 }
Exemple #12
0
 public void UnloadImage()
 {
     if (_img != null && !_img.IsDisposed)
     {
         _img.Dispose();
     }
     _img      = null;
     ImgCenter = Vector2.Zero;
 }
Exemple #13
0
 public void Dispose()
 {
     if (self_control)
     {
         if (source != null)
         {
             source.Dispose();
         }
     }
 }
Exemple #14
0
        protected override void OnClosed(EventArgs e)
        {
            base.OnClosed(e);

            bitmap.Dispose();
            renderTarget.Dispose();
            for (int i = 0; i < grayCodeImages.Length; i++)
            {
                grayCodeImages[i].Dispose();
            }
        }
Exemple #15
0
        private bool _disposedValue; // To detect redundant calls

        /// <summary>
        ///     Releases unmanaged and - optionally - managed resources.
        /// </summary>
        /// <param name="disposing">
        ///     <c>true</c> to release both managed and unmanaged resources; <c>false</c> to release only
        ///     unmanaged resources.
        /// </param>
        protected virtual void Dispose(bool disposing)
        {
            if (_disposedValue)
            {
                return;
            }

            SharpDxBitmap.Dispose();
            SharpDxBitmap = null;

            _disposedValue = true;
        }
Exemple #16
0
 private void DisposeDirectXResources()
 {
     _bitmap?.Dispose();
     _textFormat.Dispose();
     _dwFactory.Dispose();
     _renderTarget.Dispose();
     _renderTargetView.Dispose();
     _d2DFactory.Dispose();
     _swapChain.Dispose();
     _d3DDeviceContext.Dispose();
     _d3DDevice.Dispose();
 }
Exemple #17
0
        /// <summary>
        /// Releases all resources used by this Image.
        /// </summary>
        /// <param name="disposing">A Boolean value indicating whether this is called from the destructor.</param>
        protected virtual void Dispose(bool disposing)
        {
            if (!disposedValue)
            {
                if (Bitmap != null)
                {
                    Bitmap.Dispose();
                }

                disposedValue = true;
            }
        }
Exemple #18
0
 public virtual void Reset()
 {
     if (targetBitmap != null)
     {
         targetBitmap.Dispose();
         targetBitmap = null;
     }
     if (sdimage != null)
     {
         sdimage.Dispose();
         sdimage = null;
     }
 }
        /// <inheritdoc />
        /// <summary>
        ///   Refreshes the control
        /// </summary>
        internal override void Refresh()
        {
            if (this.invert && Bitmap != null)
            {
                var effect = new Effect(Toolbar.ToolbarRenderTarget.QueryInterface <DeviceContext>(), Effect.Invert);
                effect.SetInput(0, Bitmap, true);
                this.image     = effect.Output;
                this.imageSize = Bitmap.Size;
                Bitmap?.Dispose();
                Bitmap = null;
            }

            base.Refresh();
        }
Exemple #20
0
        public virtual void Reset()
        {
            if (targetBitmap != null)
            {
                targetBitmap.Dispose();
                targetBitmap = null;
            }
#if WINFORMS
            if (sdimage != null)
            {
                sdimage.Dispose();
                sdimage = null;
            }
#endif
        }
Exemple #21
0
 public void Dispose()
 {
     if (Img != null)
     {
         Img.Dispose();
         Img = null;
         bs.Converter.Dispose();
         bs.Decoder.Dispose();
         bs.FrameDecoder.Dispose();
     }
     if (imgsteam != null)
     {
         imgsteam.Dispose(); imgsteam = null;
     }
     GC.SuppressFinalize(this);
 }
        /// <summary>
        /// Unload content and cleanup unmanaged resources.
        /// </summary>
        public override void UnloadContent()
        {
            base.UnloadContent();

            foreach (var proxy in _substationProxies)
            {
                if (proxy.Value.PieGeometry != null)
                {
                    proxy.Value.PieGeometry.Dispose();
                }
                proxy.Value.PieGeometry = null;
            }

            _textFormat = null;
            if (_dashStyle != null)
            {
                _dashStyle.Dispose();
            }
            _dashStyle = null;

            if (UnitFrequencyControlBitmap != null)
            {
                UnitFrequencyControlBitmap.Dispose();
            }
            UnitFrequencyControlBitmap = null;

            if (OutagedAutoTransformerBitmap != null)
            {
                OutagedAutoTransformerBitmap.Dispose();
            }
            OutagedAutoTransformerBitmap = null;

            if (SynchroscopeBitmap != null)
            {
                SynchroscopeBitmap.Dispose();
            }
            SynchroscopeBitmap = null;
        }
        private void RenderThread()
        {
            int i = 0;

            SharpDX.Direct2D1.Bitmap bmp = null;

            try {
                PopupState popupstate = PopupState.NotVisible;

                while (true)
                {
                    int seconds;
                    System.Drawing.Point wndLoc;
                    System.Drawing.Point newpopupLoc;

                    //update
                    Process p = this.Update(out seconds, ref popupstate, out newpopupLoc);

                    if (p != null)
                    {
                        lastTargetWindow = p.MainWindowHandle;
                        int style;

                        switch (popupstate)
                        {
                        case PopupState.Visible:
                            style = GetWindowLong(p.MainWindowHandle, -16);    //get GWL_STYLE

                            if ((style & WS_MINIMIZE) == WS_MINIMIZE)          //It's minimized, show placeholder in center of screen

                            {
                                this.Draw(seconds, null, newpopupLoc);

                                this.Invoke(new Action(() => {
                                    System.Drawing.Rectangle rcScreen = Screen.PrimaryScreen.WorkingArea;
                                    Location = new System.Drawing.Point(
                                        rcScreen.Left + rcScreen.Width / 2 - this.Width / 2,
                                        rcScreen.Top + rcScreen.Height / 2 - this.Height / 2
                                        );
                                }));

                                if (!this.Visible)
                                {
                                    this.Invoke(new Action(() => {
                                        this.Visible = true;
                                    }));

                                    try {
                                        if (System.IO.File.Exists("alert.wav"))
                                        {
                                            new System.Media.SoundPlayer("alert.wav").Play();
                                        }
                                    } catch (Exception ex) {
                                        MessageBox.Show(ex.ToString());
                                    }
                                }
                            }
                            else
                            {
                                if (bmp == null)
                                {
                                    //get image from client
                                    bmp = ConvertBitmap(this.Device, (System.Drawing.Bitmap)PrintWindow(p.MainWindowHandle, out wndLoc).Clone());

                                    popupLoc = new System.Drawing.Point(newpopupLoc.X + 10, newpopupLoc.Y + 36);

                                    //add offsets by window frame
                                    POINT clientCoord = new POINT();
                                    ClientToScreen(p.MainWindowHandle, ref clientCoord);

                                    popupLoc.X += clientCoord.X - wndLoc.X;
                                    popupLoc.Y += clientCoord.Y - wndLoc.Y;

                                    //position popup at same position as ingame
                                    this.Invoke(new Action(() => {
                                        Location = new System.Drawing.Point(wndLoc.X + popupLoc.X - 17, wndLoc.Y + popupLoc.Y - 53);
                                    }));

                                    if (!this.Visible)
                                    {
                                        this.Invoke(new Action(() => {
                                            this.Visible = true;
                                        }));
                                    }

                                    try {
                                        if (System.IO.File.Exists("alert.wav"))
                                        {
                                            new System.Media.SoundPlayer("alert.wav").Play();
                                        }
                                    } catch (Exception ex) {
                                        MessageBox.Show(ex.ToString());
                                    }
                                }


                                this.Draw(seconds, bmp, popupLoc);
                            }
                            break;

                        case PopupState.NotVisible:
                        case PopupState.Locked:
                            if (null != bmp)
                            {
                                bmp.Dispose();
                                bmp = null;
                            }
                            if (this.Visible)
                            {
                                this.Invoke(new Action(() => {
                                    this.Visible = false;
                                }));
                            }
                            break;
                        }
                    }
                    else
                    {
                        if (this.Visible)
                        {
                            this.Invoke(new Action(() => {
                                this.Visible = false;
                            }));
                        }
                    }

                    System.Threading.Thread.Sleep(1000);
                }
            } catch (System.Threading.ThreadAbortException) {
            } catch (Exception ex) {
                MessageBox.Show(ex.ToString());
            }
        }
Exemple #24
0
 public void Dispose()
 {
     bitmap.Dispose();
 }
        public static void DrawPoint(D2D1.RenderTarget renderTarget, D2D1.Factory factory, IPoint point, D2D1.Bitmap symbol, Vector2 offset,
                                     float rotation, Map map)
        {
            if (point == null)
            {
                return;
            }

            var pp = TransformToImage(point.Coordinate, map);

            if (double.IsNaN(pp.X))
            {
                return;
            }
            pp += offset;

            bool symbolCreated = false;

            if (symbol == null) //We have no point style - Use a default symbol
            {
                symbol        = CreateDefaultsymbol(renderTarget);
                symbolCreated = true;
            }


            lock (symbol)
            {
                if (rotation != 0 && !Single.IsNaN(rotation))
                {
                    var startingTransform = new Matrix3x2(renderTarget.Transform.ToArray());

                    var transform      = renderTarget.Transform;
                    var rotationCenter = pp;
                    Matrix3x2.Rotation(rotation, rotationCenter);
                    transform *= Matrix3x2.Rotation(rotation, rotationCenter);
                    renderTarget.Transform = transform;

                    //if (symbolscale == 1f)
                    //{
                    //    g.DrawImage(symbol,  (pp.X - symbol.Width/2f + offset.X),
                    //                                (pp.Y - symbol.Height/2f + offset.Y));
                    //}
                    //else
                    //{
                    //    var width = symbol.Width*symbolscale;
                    //    var height = symbol.Height*symbolscale;
                    //    g.DrawImage(symbol, (int) pp.X - width/2 + offset.X*symbolscale,
                    //                        (int) pp.Y - height/2 + offset.Y*symbolscale, width, height);
                    //}
                    var dx = 0.5d * symbol.PixelSize.Width;
                    var dy = 0.5d * symbol.PixelSize.Height;
                    renderTarget.DrawBitmap(symbol, new SharpDX.RectangleF(Convert.ToSingle(pp.X - dx), Convert.ToSingle(pp.Y + dy),
                                                                           symbol.PixelSize.Width, symbol.PixelSize.Height),
                                            1f, SharpDX.Direct2D1.BitmapInterpolationMode.Linear);
                    renderTarget.Transform = startingTransform;
                }
                else
                {
                    //if (symbolscale == 1f)
                    //{
                    //    g.DrawImageUnscaled(symbol, (int) (pp.X - symbol.Width/2f + offset.X),
                    //                                (int) (pp.Y - symbol.Height/2f + offset.Y));
                    //}
                    //else
                    //{
                    //    var width = symbol.Width*symbolscale;
                    //    var height = symbol.Height*symbolscale;
                    //    g.DrawImage(symbol, (int) pp.X - width/2 + offset.X*symbolscale,
                    //                        (int) pp.Y - height/2 + offset.Y*symbolscale, width, height);
                    //}
                    var dx = 0.5d * symbol.PixelSize.Width;
                    var dy = 0.5d * symbol.PixelSize.Height;
                    renderTarget.DrawBitmap(symbol, new SharpDX.RectangleF(Convert.ToSingle(pp.X - dx), Convert.ToSingle(pp.Y + dy),
                                                                           symbol.PixelSize.Width, symbol.PixelSize.Height),
                                            1f, D2D1.BitmapInterpolationMode.Linear);
                }
            }
            if (symbolCreated)
            {
                symbol.Dispose();
            }
        }
Exemple #26
0
        private static Bitmap LoadBitmapFromMemory(RenderTarget device, byte[] bytes)
        {
            if (device == null)
            {
                throw new ArgumentNullException(nameof(device));
            }
            if (bytes == null)
            {
                throw new ArgumentNullException(nameof(bytes));
            }
            if (bytes.Length == 0)
            {
                throw new ArgumentOutOfRangeException(nameof(bytes));
            }

            Bitmap            bmp       = null;
            MemoryStream      stream    = null;
            BitmapDecoder     decoder   = null;
            BitmapFrameDecode frame     = null;
            FormatConverter   converter = null;

            try
            {
                stream  = new MemoryStream(bytes);
                decoder = new BitmapDecoder(ImageFactory, stream, DecodeOptions.CacheOnDemand);

                var pixelFormat = ImagePixelFormats.GetBestPixelFormat(decoder.DecoderInfo?.PixelFormats);

                frame = decoder.GetFrame(0);

                converter = new FormatConverter(ImageFactory);

                try
                {
                    converter.Initialize(frame, pixelFormat);
                    bmp = Bitmap.FromWicBitmap(device, converter);
                }
                catch
                {
                    TryCatch(() => converter.Dispose());

                    converter = new FormatConverter(ImageFactory);
                    converter.Initialize(frame, PixelFormat.Format32bppRGB);
                    bmp = Bitmap.FromWicBitmap(device, converter);
                }

                converter.Dispose();
                frame.Dispose();
                decoder.Dispose();
                stream.Dispose();

                return(bmp);
            }
            catch
            {
                if (converter?.IsDisposed == false)
                {
                    converter.Dispose();
                }
                if (frame?.IsDisposed == false)
                {
                    frame.Dispose();
                }
                if (decoder?.IsDisposed == false)
                {
                    decoder.Dispose();
                }
                if (stream != null)
                {
                    TryCatch(() => stream.Dispose());
                }
                if (bmp?.IsDisposed == false)
                {
                    bmp.Dispose();
                }

                throw;
            }
        }
Exemple #27
0
 private void DialogPane_Disposed(object sender, EventArgs e)
 {
     bmp?.Dispose();
     renderTarget?.Dispose();
     factory?.Dispose();
 }
            private unsafe void DrawCursor(SharpDX.Direct2D1.RenderTarget renderTarger, CursorInfo cursor)
            {
                var position = cursor.Position;

                var shapeBuff = cursor.PtrShapeBuffer;
                var shapeInfo = cursor.ShapeInfo;

                int width  = shapeInfo.Width;
                int height = shapeInfo.Height;
                int pitch  = shapeInfo.Pitch;

                int left   = position.X;
                int top    = position.Y;
                int right  = position.X + width;
                int bottom = position.Y + height;

                //logger.Debug(left + " " + top + " " + right + " " + bottom);

                if (cursor.ShapeInfo.Type == (int)ShapeType.DXGI_OUTDUPL_POINTER_SHAPE_TYPE_COLOR)
                {
                    var data       = new DataPointer(shapeBuff, height * pitch);
                    var prop       = new Direct2D.BitmapProperties(new Direct2D.PixelFormat(Format.B8G8R8A8_UNorm, Direct2D.AlphaMode.Premultiplied));
                    var size       = new Size2(width, height);
                    var cursorBits = new Direct2D.Bitmap(renderTarger, size, data, pitch, prop);
                    try
                    {
                        var cursorRect = new RawRectangleF(left, top, right, bottom);

                        renderTarger.DrawBitmap(cursorBits, cursorRect, 1.0f, Direct2D.BitmapInterpolationMode.Linear);
                    }
                    finally
                    {
                        cursorBits?.Dispose();
                    }
                }
                else if (cursor.ShapeInfo.Type == (int)ShapeType.DXGI_OUTDUPL_POINTER_SHAPE_TYPE_MONOCHROME)
                {
                    height = height / 2;

                    left   = position.X;
                    top    = position.Y;
                    right  = position.X + width;
                    bottom = position.Y + height;
                    pitch  = width * 4;

                    Texture2D desktopRegionTex = null;
                    try
                    {
                        desktopRegionTex = new Texture2D(device,
                                                         new Texture2DDescription
                        {
                            CpuAccessFlags    = CpuAccessFlags.Read,
                            BindFlags         = BindFlags.None,
                            Format            = Format.B8G8R8A8_UNorm,
                            Width             = width,
                            Height            = height,
                            MipLevels         = 1,
                            ArraySize         = 1,
                            SampleDescription = { Count = 1, Quality = 0 },
                            Usage             = ResourceUsage.Staging,
                            OptionFlags       = ResourceOptionFlags.None,
                        });

                        var region           = new ResourceRegion(left, top, 0, right, bottom, 1);
                        var immediateContext = device.ImmediateContext;
                        immediateContext.CopySubresourceRegion(screenTexture, 0, region, desktopRegionTex, 0);

                        var dataBox = immediateContext.MapSubresource(desktopRegionTex, 0, MapMode.Read, MapFlags.None);
                        try
                        {
                            var desktopBuffer = new byte[width * height * 4];
                            Marshal.Copy(dataBox.DataPointer, desktopBuffer, 0, desktopBuffer.Length);

                            var shapeBufferLenght = width * height * 4;
                            var shapeBuffer       = new byte[shapeBufferLenght];

                            var maskBufferLenght = width * height / 8;
                            var andMaskBuffer    = new byte[maskBufferLenght];
                            Marshal.Copy(shapeBuff, andMaskBuffer, 0, andMaskBuffer.Length);

                            var xorMaskBuffer = new byte[maskBufferLenght];
                            Marshal.Copy(shapeBuff + andMaskBuffer.Length, xorMaskBuffer, 0, xorMaskBuffer.Length);

                            for (var row = 0; row < height; ++row)
                            {
                                byte mask = 0x80;

                                for (var col = 0; col < width; ++col)
                                {
                                    var maskIndex = row * width / 8 + col / 8;

                                    var andMask = ((andMaskBuffer[maskIndex] & mask) == mask) ? 0xFF : 0;
                                    var xorMask = ((xorMaskBuffer[maskIndex] & mask) == mask) ? 0xFF : 0;

                                    int pos = row * width * 4 + col * 4;
                                    for (int i = 0; i < 3; i++)
                                    {// RGB
                                        shapeBuffer[pos] = (byte)((desktopBuffer[pos] & andMask) ^ xorMask);
                                        pos++;
                                    }
                                    // Alpha
                                    shapeBuffer[pos] = (byte)((desktopBuffer[pos] & 0xFF) ^ 0);

                                    if (mask == 0x01)
                                    {
                                        mask = 0x80;
                                    }
                                    else
                                    {
                                        mask = (byte)(mask >> 1);
                                    }
                                }
                            }


                            Direct2D.Bitmap cursorBits = null;
                            try
                            {
                                fixed(byte *ptr = shapeBuffer)
                                {
                                    var data = new DataPointer(ptr, height * pitch);
                                    var prop = new Direct2D.BitmapProperties(new Direct2D.PixelFormat(Format.B8G8R8A8_UNorm, Direct2D.AlphaMode.Premultiplied));
                                    var size = new Size2(width, height);

                                    cursorBits = new Direct2D.Bitmap(renderTarger, size, data, pitch, prop);
                                };

                                var shapeRect = new RawRectangleF(left, top, right, bottom);

                                renderTarger.DrawBitmap(cursorBits, shapeRect, 1.0f, Direct2D.BitmapInterpolationMode.Linear);
                            }
                            finally
                            {
                                cursorBits?.Dispose();
                            }
                        }
                        finally
                        {
                            immediateContext.UnmapSubresource(desktopRegionTex, 0);
                        }
                    }
                    finally
                    {
                        desktopRegionTex?.Dispose();
                    }
                }
                else if (cursor.ShapeInfo.Type == (int)ShapeType.DXGI_OUTDUPL_POINTER_SHAPE_TYPE_COLOR)
                {
                    logger.Warn("Not supported cursor type " + ShapeType.DXGI_OUTDUPL_POINTER_SHAPE_TYPE_COLOR);
                }
            }
Exemple #29
0
 public void Dispose()
 {
     _bgBitmap.Dispose();
 }
Exemple #30
0
 public void Destroy()
 {
     _bitmap0?.Dispose();
     _bitmap1?.Dispose();
     _brush?.Dispose();
 }