Draw on an Bitmap : Bitmap : Graphics C# Source Code


Custom Search

C# Source Code » Graphics » Bitmap »

 

Draw on an Bitmap








    
 

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

public class Form1 : Form {

    protected override void OnPaint(PaintEventArgs e) {
    Bitmap bmp = new Bitmap(100, 100);
    Graphics gImage = Graphics.FromImage(bmp);
    gImage.FillRectangle(Brushes.Red, 0, 0, bmp.Width, bmp.Height);
    gImage.DrawRectangle(Pens.Black, 10, 10, bmp.Width - 20, bmp.Height - 20);

    Graphics gScreen = e.Graphics;
    gScreen.FillRectangle(Brushes.White, this.ClientRectangle);
    gScreen.DrawImage(bmp, new Rectangle(10, 10, bmp.Width, bmp.Height));

    }
    public static void Main() {
        Application.Run(new Form1());
    }
}

 
    
   
  
   







HTML code for linking to this page:

Follow Navioo On Twitter

C# Source Code

 Navioo Graphics
» Bitmap