private void OnClick(object sender, EventArgs e)
        {
            if (sender == this.bShrink)
            {
                Rectangle rect = BitmapHelper.CalcShrink(this.BmpEditor.Bmp);
                this.numLeft.Value   = -rect.X;
                this.numTop.Value    = -rect.Y;
                this.numRight.Value  = -(this.BmpEditor.Bmp.Width - rect.Width - rect.X);
                this.numBottom.Value = -(this.BmpEditor.Bmp.Height - rect.Height - rect.Y);
            }
            if (sender == this.bApplyResize)
            {
                int left   = Convert.ToInt32(this.numLeft.Value);
                int top    = Convert.ToInt32(this.numTop.Value);
                int right  = Convert.ToInt32(this.numRight.Value);
                int bottom = Convert.ToInt32(this.numBottom.Value);

                this.BmpEditor.Bmp = BitmapHelper.Resize(this.BmpEditor.Bmp, left, top, right, bottom);
            }
            if (sender == this.bImport)
            {
                using (OpenFileDialog ofd = new OpenFileDialog())
                {
                    ofd.CheckFileExists = true;
                    ofd.CheckPathExists = true;
                    ofd.DefaultExt      = ".*";
                    ofd.Filter          = "Windows Bitmap (*.bmp)|*.bmp";
                    ofd.Title           = "Open image file";
                    if (ofd.ShowDialog() == DialogResult.OK)
                    {
                        string filename = ofd.FileName;
                        Bitmap bmp      = new Bitmap(filename);
                        using (FormColor2BW formC2BW = new FormColor2BW())
                        {
                            formC2BW.ImageOriginal = bmp;
                            if (formC2BW.ShowDialog() == DialogResult.OK)
                            {
                                this.BmpEditor.Bmp = formC2BW.ImageResult;
                            }
                        }
                    }
                }
            }
            if (sender == this.bExport)
            {
                using (SaveFileDialog sfd = new SaveFileDialog())
                {
                    sfd.AddExtension    = true;
                    sfd.CheckPathExists = true;
                    sfd.DefaultExt      = ".*";
                    sfd.Filter          = "Windows Bitmap (*.bmp)|*.bmp";
                    sfd.OverwritePrompt = true;
                    sfd.Title           = "Save image file...";
                    if (sfd.ShowDialog() == DialogResult.OK)
                    {
                        this.BmpEditor.Bmp.Save(sfd.FileName);
                    }
                }
            }
        }
        public static Bitmap GetCharacterBitmap(char c, Font font, FontWidthMode widthMode, int width, float edge)
        {
            bool setByDef = SavedContainer <Options> .Instance.SetBitsByDefault;

            Size   sz = TextRenderer.MeasureText(new string(c, 1), font);
            Bitmap bmp;

            if (widthMode == FontWidthMode.Monospaced)
            {
                bmp = new Bitmap(width, sz.Height);
            }
            else
            {
                bmp = new Bitmap(sz.Width, sz.Height);
            }
            Graphics gr = Graphics.FromImage(bmp);

            gr.FillRectangle((setByDef ? Brushes.White : Brushes.Black), 0, 0, bmp.Width, bmp.Height);
            gr.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.Low;
            gr.SmoothingMode     = System.Drawing.Drawing2D.SmoothingMode.None;
            gr.DrawString(new string(c, 1), font, (setByDef ? Brushes.Black : Brushes.White), 0, 0);
            bmp = GetMonochrome(bmp, edge);
            if (widthMode == FontWidthMode.Proportional)
            {
                Rectangle shrink = BitmapHelper.CalcShrink(bmp);
                int       left   = -shrink.X;
                int       top    = -shrink.Y;
                int       right  = -(bmp.Width - shrink.Width - shrink.X);
                int       bottom = -(bmp.Height - shrink.Height - shrink.Y);

                left++;
                right++;
                bmp = BitmapHelper.Resize(bmp, left, 0, right, 0);
            }
            return(bmp);
        }