예제 #1
0
        void DrawUnderline(FastBitmap dst, ref DrawTextArgs args, int x, int y, bool shadow)
        {
            int point = Utils.Floor(args.Font.Size), dstHeight = point, startX = x;
            // adjust coords to make drawn text match GDI fonts
            int xPadding = Utils.CeilDiv(point, 8);
            int yPadding = (AdjHeight(dstHeight) - dstHeight) / 2;

            // scale up bottom row of a cell to drawn text font
            int startYY = (8 - 1) * dstHeight / 8;

            for (int yy = startYY; yy < dstHeight; yy++)
            {
                int dstY = y + (yy + yPadding);
                if (dstY >= dst.Height)
                {
                    return;
                }
                int *dstRow = dst.GetRowPtr(dstY);

                PackedCol col  = Cols['f'];
                string    text = args.Text;

                for (int i = 0; i < text.Length; i++)
                {
                    char c = text[i];
                    if (c == '&' && ValidColCode(text, i + 1))
                    {
                        col = GetCol(text[i + 1]);
                        i++; continue;                         // Skip over the colour code.
                    }

                    byte cur      = Utils.UnicodeToCP437(c);
                    int  dstWidth = Width(point, cur);
                    col = shadow ? PackedCol.Black : col;
                    int argb = col.ToArgb();

                    for (int xx = 0; xx < dstWidth + xPadding; xx++)
                    {
                        if (x >= dst.Width)
                        {
                            break;
                        }
                        dstRow[x++] = argb;
                    }
                }
                x = startX;
            }
        }
예제 #2
0
        SolidBrush GetOrCreateBrush(PackedCol col)
        {
            int argb = col.ToArgb();

            for (int i = 0; i < brushes.Count; i++)
            {
                if (brushes[i].ARGB == argb)
                {
                    return(brushes[i].Brush);
                }
            }

            CachedBrush b; b.ARGB = argb; b.Brush = new SolidBrush(col);

            brushes.Add(b);
            return(b.Brush);
        }