new Bitmap(bitmap, size) : Bitmap : Graphics C# Source Code


Custom Search

C# Source Code » Graphics » Bitmap »

 

new Bitmap(bitmap, size)








    
 


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);
    }
}

 
    
   
  
   







HTML code for linking to this page:

Follow Navioo On Twitter

C# Source Code

 Navioo Graphics
» Bitmap