using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Windows.Forms; using System.Drawing.Imaging; using System.Drawing.Drawing2D; namespace WindowsFormsApplication1 { public partial class Form1 : Form { public Form1() { InitializeComponent(); } private void Form1_Load(object sender, EventArgs e) { string drawtext = "hogehogehogehoge"; string fontname = "メイリオ"; Font font = new Font(fontname, 100.0f); Bitmap bmp = new Bitmap(400, 240, PixelFormat.Format32bppArgb); using (Graphics g = Graphics.FromImage(bmp)) { //初期化 g.FillRectangle(Brushes.White, new Rectangle(0, 0, bmp.Width, bmp.Height)); SizeF size = g.MeasureString(drawtext, font); GraphicsPath gp = new GraphicsPath(); gp.AddString(drawtext, font.FontFamily,0,font.Size, new Point(0,0), StringFormat.GenericDefault); Matrix tm = new Matrix(); tm.Scale((((float)bmp.Width) / size.Width), (float)bmp.Height / size.Height); gp.Transform(tm); g.FillPath(Brushes.Red, gp); } pictureBox1.Image = bmp; } } }