Exemplo n.º 1
0
        public CharBitmap NewChar(int Width)
        {
            CharBitmap cb = new CharBitmap(Width, height);

            chars.Add(cb);
            return(cb);
        }
Exemplo n.º 2
0
        private void listBoxFontChars_SelectedIndexChanged(object sender, EventArgs e)
        {
            Graphics gr = pictureBoxPreviewAll.CreateGraphics();

            gr.Clear(this.BackColor);
            int index = listBoxFontChars.SelectedIndex;

            if (index < 0 || index >= man.GetEmbeddedFont().Chars.Count)
            {
                return;
            }
            CharBitmap cbm = man.GetEmbeddedFont().Chars[index];

            int width  = (int)gr.VisibleClipBounds.Width;
            int height = (int)gr.VisibleClipBounds.Height;

            int pixWidth  = width / cbm.GetWidth();
            int pixHeight = height / cbm.GetHeight();

            int pixSize = Math.Min(pixWidth, pixHeight);

            int pixWidthOffset  = (width - pixSize * cbm.GetWidth()) / 2;
            int pixHeightOffset = (height - pixSize * cbm.GetHeight()) / 2;

            int   pixCount   = 0;
            Color byteColor1 = Color.Green;
            Color byteColor2 = Color.Blue;
            Color byteColor  = byteColor1;
            int   gridWidth  = 4;

            CharBitmap.Padding padding = cbm.GetPadding();
            for (int Y = padding.Top; Y < cbm.GetHeight() - padding.Bottom; Y++)
            {
                for (int X = padding.Left; X < cbm.GetWidth() - padding.Right; X++)
                {
                    Color      pixColor = cbm.IsForegroundColor(X, Y) ? Color.Black : Color.White;
                    SolidBrush brush    = new SolidBrush(pixColor);
                    gr.FillRectangle(brush, pixWidthOffset + X * pixSize, pixHeightOffset + Y * pixSize, pixSize - gridWidth, pixSize - gridWidth);
                    Pen pen = new Pen(byteColor, gridWidth);
                    gr.DrawRectangle(pen, pixWidthOffset + X * pixSize, pixHeightOffset + Y * pixSize, pixSize - gridWidth, pixSize - gridWidth);
                    pen = new Pen(this.BackColor, 1);
                    gr.DrawRectangle(pen, pixWidthOffset + X * pixSize - gridWidth / 2, pixHeightOffset + Y * pixSize - gridWidth / 2, pixSize, pixSize);
                    pixCount++;

                    if (0 == pixCount % 8)
                    {
                        if (byteColor1 == byteColor)
                        {
                            byteColor = byteColor2;
                        }
                        else
                        {
                            byteColor = byteColor1;
                        }
                    }
                }
            }

            textBoxCodePreview.Text = cbm.GetSource(padding);
        }
Exemplo n.º 3
0
        private void createBitmaps()
        {
            int height = this.font.Height + 1;

            this.embeddedFont = new EmbeddedFont(height);
            for (char c = ' '; c < 0x7F; c++)
            {
                Color[,] bm = createBitmap(c);
                CharBitmap cbm = embeddedFont.NewChar(bm.GetLength(0));
                cbm.SetChar(c);
                for (int x = 0; x < cbm.GetWidth(); x++)
                {
                    for (int y = 0; y < cbm.GetHeight(); y++)
                    {
                        if (bm[x, y].ToArgb() == Color.Black.ToArgb())
                        {
                            cbm.SetForegroundColor(x, y);
                        }
                        else
                        {
                            cbm.SetBackgroundColor(x, y);
                        }
                    }
                }
            }
        }
Exemplo n.º 4
0
 public CharBitmap NewChar(int Width)
 {
     CharBitmap cb = new CharBitmap(Width, height);
       chars.Add(cb);
       return cb;
 }