Ejemplo n.º 1
0
            /// <summary>
            /// Character Digitizer
            ///   Creates the Byte stream for this character
            /// </summary>
            /// <param name="c">Character to digitize</param>
            /// <param name="fo">The FontOptimzer serving the bitmaps</param>
            /// <param name="target">Width target setting</param>
            /// <returns>The size of the created character</returns>
            public override Size CreateChar(Char c, FontOptimizer fo, FontOptimizer.WidthTarget target)
            {
                m_c = c;

                Bitmap fontImage = fo.GetMapForChar(c, target);

                // GET and ADD BITS...
                // from Top to bottom - then from left to right
                m_bytesPerCol = (fontImage.Height + 7) / 8; // get height in bytes

                for (int b = 0; b < m_bytesPerCol; b++)
                {
                    // per byte row
                    for (int x = 0; x < fontImage.Width; x++)
                    {
                        // left -> right

                        Byte col = 0;
                        Byte bit = 1; // paint bit moves from LSB to MSB in the y -loop

                        for (int y = b * 8; y < (b + 1) * 8; y++)
                        {
                            if (y < fontImage.Height)
                            {
                                // top -> down ??
                                Color pix = fontImage.GetPixel(x, y);
                                if (pix.R > FontOptimizer.BLANKTX) // red on black painting
                                {
                                    col |= bit;
                                }
                                bit <<= 1;
                            }
                            else
                            {
                                // catch overrun - but shift in (supposed bug in original must be retained...)
                                col <<= 1; // shift in
                            }
                        } // for y
                        this.Add(col);
                    } // for x
                }     // for b

                Size nS = fontImage.Size;

                fontImage.Dispose( );
                return(nS);
            }