Teksti kirjutamine pildile
30.04.2007 | GunnarPaar näidet pildile teksti kirjutamisest .Net vahenditega. Enne teksti kirjutamist tuleb pilt kas failist sisse laadida või siis mälus valmis luua.
Bitmap ImageHorizontalText(Bitmap bmp, string text, string font)
{
Graphics graph = Graphics.FromImage(bmp);
Brush brush = new SolidBrush(Color.Maroon);
graph.DrawString(text, new Font(font,14,FontStyle.Bold), brush, 1, 1);
graph.Dispose();
return bmp;
}
Bitmap ImageVerticalText(Bitmap bmp, string text, string font)
{
Graphics graph = Graphics.FromImage(bmp);
StringFormat format = new StringFormat();
format.FormatFlasg = StringFormatFlags.DirectionVertical;
Brush brush = new SolidBrush(Color.Maroon);
Font font = new Font(font, 14, FontStyle.Bold);
graph.DrawString(text, font, brush, 1, 1, format);
graph.Dispose();
return bmp;
}
{
Graphics graph = Graphics.FromImage(bmp);
Brush brush = new SolidBrush(Color.Maroon);
graph.DrawString(text, new Font(font,14,FontStyle.Bold), brush, 1, 1);
graph.Dispose();
return bmp;
}
Bitmap ImageVerticalText(Bitmap bmp, string text, string font)
{
Graphics graph = Graphics.FromImage(bmp);
StringFormat format = new StringFormat();
format.FormatFlasg = StringFormatFlags.DirectionVertical;
Brush brush = new SolidBrush(Color.Maroon);
Font font = new Font(font, 14, FontStyle.Bold);
graph.DrawString(text, font, brush, 1, 1, format);
graph.Dispose();
return bmp;
}
