Exemplo n.º 1
0
        protected static BitmapProperties1 NewDescription(float dpiX, float dpiY, PixelFormat format, AlphaMode alphaMode,
                                                          BitmapOptions bitmapOptions, ColorContext colorContext)
        {
            var pixelFormat = new SharpDX.Direct2D1.PixelFormat(format, alphaMode);

            return(new BitmapProperties1(pixelFormat, dpiX, dpiY, bitmapOptions, colorContext));
        }
Exemplo n.º 2
0
        /// <summary>
        /// Creates a new texture description for a <see cref="BitmapTarget" />.
        /// </summary>
        /// <param name="dpiX">The width.</param>
        /// <param name="dpiY">The height.</param>
        /// <param name="format">Describes the format to use.</param>
        /// <param name="alphaMode">The <see cref="AlphaMode"/>.</param>
        /// <param name="options">Sets the bitmap options.</param>
        /// <param name="colorContext">The <see cref="ColorContext"/>.</param>
        /// <returns>A new instance of <see cref="BitmapTarget" /> class.</returns>
        public static BitmapProperties1 CreateDescription(float dpiX, float dpiY, PixelFormat format,
                                                          AlphaMode alphaMode   = AlphaMode.Premultiplied,
                                                          BitmapOptions options = BitmapOptions.Target | BitmapOptions.CannotDraw, ColorContext colorContext = null)
        {
            // Make sure that the texture to create is a render target
            options |= BitmapOptions.Target;
            var description = NewDescription(dpiX, dpiY, format, alphaMode, options, colorContext);

            return(description);
        }
Exemplo n.º 3
0
        public static BitmapTarget New(string name, Direct2DDevice device, int width, int height, PixelFormat format)
        {
            Texture2DDescription renderTargetDescription = new Texture2DDescription
            {
                Width             = width,
                Height            = height,
                ArraySize         = 1,
                SampleDescription = new SampleDescription(1, 0),
                BindFlags         = BindFlags.RenderTarget,
                Format            = format,
                MipLevels         = CalculateMipMapCount(width, height),
                Usage             = ResourceUsage.Default,
                CpuAccessFlags    = CpuAccessFlags.None,
                OptionFlags       = ResourceOptionFlags.None
            };

            Texture2D texture = new Texture2D(device, renderTargetDescription);

            return(new BitmapTarget(name, device, texture.QueryInterface <Surface>(), CreateDescription(device.HorizontalDpi, device.VerticalDpi, format)));
        }