Re: Как с помощью GDI+ сделать вот такой текст?
От: DeV1L Беларусь  
Дата: 16.01.07 13:38
Оценка: 3 (1)
Здравствуйте, DeV1L, Вы писали:

DVL>Как с помощью GDI+ сделать вот такой текст?

DVL>

Матчасть приводить не буду. А ниже один из способов решения.

public static Bitmap CreateText(string text, Font font, Color textColor)
{
    Bitmap bmpOut;
    using (GraphicsPath path = new GraphicsPath())
    {
        // Добавляем строку к контуру.
        path.AddString(text, font.FontFamily, (int) font.Style, font.Size, new PointF(0, 0), new StringFormat());
        // Сдвигаем начальную точку в центр контура.
        RectangleF rectf = path.GetBounds();
        path.Transform(new Matrix(1, 0, 0, 1, -(rectf.Left + rectf.Right)/2, -(rectf.Top + rectf.Bottom)/2));
        // Изменяем контур.
        PointF[] aptf = path.PathPoints;
        for (int i = 0; i < aptf.Length; i++)
        {
            aptf[i].Y *= (float) (2 - Math.Cos(Math.PI*Math.Abs(aptf[i].X)/rectf.Width));
        }
        // Создаём Bitmap и заполняем его контуром.
        using (GraphicsPath pathOut = new GraphicsPath(aptf, path.PathTypes))
        {
            rectf = pathOut.GetBounds();
            bmpOut = new Bitmap((int)rectf.Width, (int)rectf.Height);
            using (Graphics gBmpOut = Graphics.FromImage(bmpOut))
            {
                gBmpOut.TranslateTransform(bmpOut.Width / 2, bmpOut.Height / 2);
                gBmpOut.FillPath(new SolidBrush(textColor), pathOut);
            }
        }
    }
    return bmpOut;
}
 
Подождите ...
Wait...
Пока на собственное сообщение не было ответов, его можно удалить.