Flush() public méthode

Executes all pending drawing commands.
This command does not flush the device that is associated with the render target. Calling this method resets the error state of the render target.
public Flush ( ) : void
Résultat void
Exemple #1
0
        /// <summary>
        /// Draw a bitmap on the Render Target (Game Launcher Window).
        /// </summary>
        /// <param name="target">Destination render target which is ready to be drawn.</param>
        /// <param name="bitmapData">Bitmap data.</param>
        /// <param name="windowSize">Destination window size.</param>
        /// <param name="rect">Which rectangle range on the render target(window) should be drawn by the bitmap?</param>
        /// <param name="opacity">What opacity we should use to draw the bitmap? (Range: [0,1])</param>
        /// <param name="isFlushInstantly">Should we flush render target instantly after drawing the bitmap?</param>
        public static void DrawBitmap(D2D.RenderTarget target, byte[] bitmapData, Size2F windowSize, RawRectangleF rect, float opacity = 1.0f, bool isFlushInstantly = true)
        {
            var stream = new MemoryStream(bitmapData);

            stream.Seek(0, SeekOrigin.Begin);
            var bitmapWrapper = (Bitmap)Image2.FromStream(stream);

            if (bitmapWrapper.Width > windowSize.Width)
            {
                bitmapWrapper = bitmapWrapper.ScaleBitmap((double)windowSize.Width / bitmapWrapper.Width);
            }
            else if (bitmapWrapper.Height > windowSize.Height)
            {
                bitmapWrapper = bitmapWrapper.ScaleBitmap((double)windowSize.Height / bitmapWrapper.Height);
            }
            var bitmap = target.LoadD2DBitmapFromBitmap(bitmapWrapper);

            if (bitmap != null)
            {
                target.DrawBitmap(bitmap, opacity, D2D.BitmapInterpolationMode.Linear, rect);
                if (isFlushInstantly)
                {
                    target.Flush();
                }
            }
        }
Exemple #2
0
        /// <summary>
        /// Draw a bitmap on the Render Target (Game Launcher Window).
        /// </summary>
        /// <param name="target">Destination render target which is ready to be drawn.</param>
        /// <param name="bitmapData">Bitmap data.</param>
        /// <param name="rect">Which rectangle range on the render target(window) should be drawn by the bitmap?</param>
        /// <param name="scaleMultiple">Which multiple should be used to scale the bitmap?</param>
        /// <param name="opacity">What opacity we should use to draw the bitmap? (Range: [0,1])</param>
        /// <param name="isFlushInstantly">Should we flush render target instantly after drawing the bitmap?</param>
        public static void DrawBitmap(D2D.RenderTarget target, byte[] bitmapData, RawRectangleF rect, float scaleMultiple, float opacity = 1.0f, bool isFlushInstantly = true)
        {
            var stream = new MemoryStream(bitmapData);

            stream.Seek(0, SeekOrigin.Begin);
            var bitmapWrapper = (Bitmap)Image2.FromStream(stream);

            bitmapWrapper = bitmapWrapper.ScaleBitmap(scaleMultiple);
            var bitmap = target.LoadD2DBitmapFromBitmap(bitmapWrapper);

            if (bitmap != null)
            {
                target.DrawBitmap(bitmap, opacity, D2D.BitmapInterpolationMode.Linear, rect);
                if (isFlushInstantly)
                {
                    target.Flush();
                }
            }
        }