/// <summary> /// Copy a bitmap to the display. /// </summary> /// <remarks> /// Currently, this method only supports copying the bitmap over the contents /// of the display buffer. /// </remarks> /// <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 transfer</param> /// <param name="bitmapMode">How should the bitmap be transferred to the display?</param> public override void DrawBitmap(int x, int y, OneBppBitmap bitmap, BitmapMode bitmapMode) { var mergeMode = OneBppBitmap.MergeMode.Copy; switch (bitmapMode) { case BitmapMode.And: mergeMode = OneBppBitmap.MergeMode.And; break; case BitmapMode.Or: mergeMode = OneBppBitmap.MergeMode.Or; break; case BitmapMode.XOr: mergeMode = OneBppBitmap.MergeMode.XOr; break; case BitmapMode.Copy: mergeMode = OneBppBitmap.MergeMode.Copy; break; } this._backingStore.MergeInto(( uint )x, ( uint )y, bitmap, mergeMode); }
private void openToolStripMenuItem_Click(object sender, EventArgs e) { if (openFileDialog1.ShowDialog() == DialogResult.OK) { bitmapMode = BitmapMode.File; SetUpPictureBox(); } }
public Form1() { InitializeComponent(); toolWidth = float.Parse(numericUpDown1.Value.ToString()); pen = new Pen(activeColor, toolWidth); bitmapMode = BitmapMode.New; SetUpPictureBox(); }
static ImageFormat BitmapModeToImgFormat(BitmapMode mode) { if (mode == BitmapMode.DontSerializeBitmaps) { throw new InvalidOperationException("You need to set 'config.Advanced.BitmapMode' to any setting other than 'DontSerializeBitmaps'. Otherwise you need to skip data-members on your classes/structs that contain Image/Bitmap, or serialize them yourself using your own IFormatter<> implementation."); } if (mode == BitmapMode.SaveAsBmp) { return(ImageFormat.Bmp); } else if (mode == BitmapMode.SaveAsJpg) { return(ImageFormat.Jpeg); } else if (mode == BitmapMode.SaveAsPng) { return(ImageFormat.Png); } throw new ArgumentOutOfRangeException(); }
/// <summary> /// Copy a bitmap to the display. /// </summary> /// <remarks> /// Currently, this method only supports copying the bitmap over the contents /// of the display buffer. /// </remarks> /// <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 transfer</param> /// <param name="bitmapMode">How should the bitmap be transferred to the display?</param> public override void DrawBitmap(int x, int y, int width, int height, byte[] bitmap, 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++) { DrawPixel(x + (8 * abscissa) + pixel, y + ordinate, (b & mask) > 0); mask <<= 1; } } } }
public override void DrawBitmap(int x, int y, OneBppBitmap bitmap, BitmapMode bitmapMode) => throw new NotImplementedException();
/// <summary> /// Copy a bitmap to the display. /// </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.</param> /// <param name="height">Height of the bitmap.</param> /// <param name="bitmap">Bitmap to transfer</param> /// <param name="bitmapMode">How should the bitmap be transferred to the display?</param> public abstract void DrawBitmap(int x, int y, int width, int height, byte[] bitmap, BitmapMode bitmapMode);
/// <summary> /// Copy a 1bpp bitmap to the display. /// </summary> /// <param name="x">horizontal top left corner of the bitmap.</param> /// <param name="y">vertical top left corner of the bitmap.</param> /// <param name="bitmap">Bitmap to transfer</param> /// <param name="bitmapMode">How should the bitmap be transferred to the display?</param> public abstract void DrawBitmap(int x, int y, OneBppBitmap bitmap, BitmapMode bitmapMode);
public override void DrawBitmap(int x, int y, int width, int height, byte[] bitmap, BitmapMode bitmapMode) => throw new NotImplementedException();