/// <summary>
        ///     Display a 1-bit bitmap
        ///
        ///     This method simply calls a similar method in the display hardware.
        /// </summary>
        /// <param name="x">Abscissa of the top left corner of the bitmap.</param>
        /// <param name="y">Ordinate of the top left corner of the bitmap.</param>
        /// <param name="width">Width of the bitmap in bytes.</param>
        /// <param name="height">Height of the bitmap in bytes.</param>
        /// <param name="bitmap">Bitmap to display.</param>
        /// <param name="bitmapMode">How should the bitmap be transferred to the display?</param>
        public void DrawBitmap(int x, int y, int width, int height, byte[] bitmap, DisplayBase.BitmapMode bitmapMode)
        {
            if ((width * height) != bitmap.Length)
            {
                throw new ArgumentException("Width and height do not match the bitmap size.");
            }

            for (var ordinate = 0; ordinate < height; ordinate++)
            {
                for (var abscissa = 0; abscissa < width; abscissa++)
                {
                    var  b    = bitmap[(ordinate * width) + abscissa];
                    byte mask = 0x01;

                    for (var pixel = 0; pixel < 8; pixel++)
                    {
                        if ((b & mask) > 0)
                        {
                            DrawPixel(x + (8 * abscissa) + pixel, y + ordinate);
                        }
                        mask <<= 1;
                    }
                }
            }
        }
        /// <summary>
        ///     Display a 1-bit bitmap
        ///
        ///     This method simply calls a similar method in the display hardware.
        /// </summary>
        /// <param name="x">Abscissa of the top left corner of the bitmap.</param>
        /// <param name="y">Ordinate of the top left corner of the bitmap.</param>
        /// <param name="width">Width of the bitmap in bytes.</param>
        /// <param name="height">Height of the bitmap in bytes.</param>
        /// <param name="bitmap">Bitmap to display.</param>
        /// <param name="bitmapMode">How should the bitmap be transferred to the display?</param>
        public void DrawBitmap(int x, int y, int width, int height, byte[] bitmap, DisplayBase.BitmapMode bitmapMode, ScaleFactor scaleFactor = ScaleFactor.X1)
        {
            if ((width * height) != bitmap.Length)
            {
                throw new ArgumentException("Width and height do not match the bitmap size.");
            }

            int scale = (int)scaleFactor;

            for (var ordinate = 0; ordinate < height; ordinate++)
            {
                for (var abscissa = 0; abscissa < width; abscissa++)
                {
                    var  b    = bitmap[(ordinate * width) + abscissa];
                    byte mask = 0x01;

                    for (var pixel = 0; pixel < 8; pixel++)
                    {
                        if ((b & mask) > 0)
                        {
                            //not elegant but works for now

                            /*     if(scaleFactor == ScaleFactor.X2)
                             *   {
                             *       //hard code for 2x for now
                             *       DrawPixel(x + (8 * abscissa) * 2 + pixel * 2,     y + ordinate * 2);
                             *       DrawPixel(x + (8 * abscissa) * 2 + pixel * 2 + 1, y + ordinate * 2);
                             *       DrawPixel(x + (8 * abscissa) * 2 + pixel * 2,     y + ordinate * 2 + 1);
                             *       DrawPixel(x + (8 * abscissa) * 2 + pixel * 2 + 1, y + ordinate * 2 + 1);
                             *   } */
                            if (scaleFactor != ScaleFactor.X1)
                            {
                                for (int i = 0; i < scale; i++)
                                {
                                    for (int j = 0; j < scale; j++)
                                    {
                                        DrawPixel(x + (8 * abscissa) * scale + pixel * scale + i, y + ordinate * scale + j);
                                    }
                                }
                            }
                            else
                            {
                                //1x
                                DrawPixel(x + (8 * abscissa) + pixel, y + ordinate);
                            }
                        }
                        mask <<= 1;
                    }
                }
            }
        }
 /// <summary>
 ///     Display a 1-bit bitmap
 ///
 ///     This method simply calls a similar method in the display hardware.
 /// </summary>
 /// <param name="x">Abscissa of the top left corner of the bitmap.</param>
 /// <param name="y">Ordinate of the top left corner of the bitmap.</param>
 /// <param name="width">Width of the bitmap in bytes.</param>
 /// <param name="height">Height of the bitmap in bytes.</param>
 /// <param name="bitmap">Bitmap to display.</param>
 /// <param name="bitmapMode">How should the bitmap be transferred to the display?</param>
 public void DrawBitmap(int x, int y, int width, int height, byte[] bitmap, DisplayBase.BitmapMode bitmapMode)
 {
     _display.DrawBitmap(x, y, width, height, bitmap, bitmapMode);
 }
        //public class ProportionalFontDisplay<DB> : DisplayBase where DB : DisplayBase {
        //	protected DB instance;

        //	private ProportionalFontDisplay() { }
        //	public ProportionalFontDisplay( DB instance ) {
        //		this.instance = instance;
        //	}

        //	public override DisplayColorMode ColorMode => instance.ColorMode;

        //	public override uint Width => instance.Width;

        //	public override uint Height => instance.Width;

        //	public override void Clear( bool updateDisplay = false ) => instance.Clear( updateDisplay );

        //	public override void DrawBitmap( int x, int y, int width, int height, byte[] bitmap, BitmapMode bitmapMode ) => instance
        //		.DrawBitmap( x, y, width, height, bitmap, bitmapMode );

        //	public override void DrawBitmap( int x, int y, int width, int height, byte[] bitmap, Color color ) => instance
        //		.DrawBitmap( x, y, width, height, bitmap, color );

        //	public override void DrawPixel( int x, int y, Color color ) => instance
        //		.DrawPixel( x, y, color );

        //	public override void DrawPixel( int x, int y, bool colored ) => instance
        //		.DrawPixel( x, y, colored );

        //	public override void Show() => instance.Show();

        public static void DrawBitmap(this DisplayBase displayBase, int x, int y, byte[][] buffer, DisplayBase.BitmapMode bitmapMode)
        {
            for (int row = 0; row < buffer.Length; row++)
            {
                displayBase.DrawBitmap(x, y + row, buffer[row].Length, 1, buffer[row], bitmapMode);
            }
        }
 public static void DrawBitmap(this GraphicsLibrary graphicsLibrary, int x, int y, int width, int height, Bitmap bitmap, DisplayBase.BitmapMode bitmapMode)
 {
     graphicsLibrary.
 }