Animatroller.Framework.LogicalDevice.VirtualPixel2D3.SetColorRange C# (CSharp) Метод

SetColorRange() публичный Метод

public SetColorRange ( Color color, double brightness = 1.0, int startX, int startY, int width = null, int height = null, IControlToken token = null ) : void
color Color
brightness double
startX int
startY int
width int
height int
token IControlToken
Результат void
        public void SetColorRange(
            Color color,
            double? brightness = 1.0,
            int startX = 0,
            int startY = 0,
            int? width = null,
            int? height = null,
            IControlToken token = null)
        {
            IData data = GetFrameBuffer(token, this);

            Color injectColor;
            if (brightness.GetValueOrDefault(1.0) < 1.0)
                injectColor = GetColorFromColorAndBrightness(color, brightness.Value);
            else
                injectColor = color;

            if (!width.HasValue)
                width = this.pixelWidth;
            if (!height.HasValue)
                height = this.pixelHeight;

            var bitmap = (Bitmap)data[DataElements.PixelBitmap];

            lock (this.lockObject)
            {
                using (var g = Graphics.FromImage(bitmap))
                using (var b = new SolidBrush(injectColor))
                {
                    g.FillRectangle(b, startX, startY, width.Value, height.Value);
                }
            }

            PushOutput(token);
        }