Artemis.DeviceProviders.Corsair.CorsairKeyboards.DrawBitmap C# (CSharp) Method

DrawBitmap() public method

Properly resizes any size bitmap to the keyboard by creating a rectangle whose size is dependent on the bitmap size.
public DrawBitmap ( Bitmap bitmap ) : void
bitmap System.Drawing.Bitmap
return void
        public override void DrawBitmap(Bitmap bitmap)
        {
            var image = ImageUtilities.ResizeImage(bitmap, Width, Height);

            // For STRAFE, stretch the image on row 2.
            if (_keyboard.DeviceInfo.Model == "STRAFE RGB")
            {
                var strafeBitmap = new Bitmap(22, 8);
                using (var g = Graphics.FromImage(strafeBitmap))
                {
                    g.DrawImage(image, new Point(0, 0));
                    g.DrawImage(image, new Rectangle(0, 3, 22, 7), new Rectangle(0, 2, 22, 7), GraphicsUnit.Pixel);
                }

                image.Dispose();
                image = strafeBitmap;
            }

            _keyboardBrush.Image = image;
            _keyboard.Update(true);

            image.Dispose();
        }