using System; using System.Drawing; using System.Windows.Forms; class HelloWorldBitmap : Form { const float fResolution = 300; Bitmap bitmap = new Bitmap(1, 1); public static void Main() { Application.Run(new HelloWorldBitmap()); } public HelloWorldBitmap() { Text = "Hello, World!"; ResizeRedraw = true; bitmap.SetResolution(fResolution, fResolution); Graphics grfx = Graphics.FromImage(bitmap); Font font = new Font("Times New Roman", 72); Size size = grfx.MeasureString(Text, font).ToSize(); bitmap = new Bitmap(bitmap, size); bitmap.SetResolution(fResolution, fResolution); grfx = Graphics.FromImage(bitmap); grfx.Clear(Color.White); grfx.DrawString(Text, font, Brushes.Black, 0, 0); grfx.Dispose(); } protected override void OnPaint(PaintEventArgs pea) { pea.Graphics.DrawImage(bitmap, 0, 0); } }