Pen StartCap: LineCap.Round


   

  using System;
  using System.Drawing;
  using System.Drawing.Drawing2D;
  using System.Collections;
  using System.ComponentModel;
  using System.Windows.Forms;
  using System.Data;

  public class Form1 : System.Windows.Forms.Form
  {
    public Form1()
    {
      InitializeComponent();
      SetStyle(ControlStyles.ResizeRedraw, true);
    }
    private void InitializeComponent()
    {
      this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
      this.ClientSize = new System.Drawing.Size(211, 104);
      this.Text = "";
      this.Paint += new System.Windows.Forms.PaintEventHandler(this.Form1_Paint);

    }

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

    private void Form1_Paint(object sender, System.Windows.Forms.PaintEventArgs e)
    {
            Graphics g = e.Graphics;
            Pen p = new Pen(Color.Brown, 15);
 
            p.StartCap = LineCap.Round  ;
            p.EndCap = LineCap.Round ;
            g.DrawLine(p,30, 30, Width-50, 30);
    }
  }



           
          


Pen StartCap: LineCap.ArrowAnchor


   


  using System;
  using System.Drawing;
  using System.Drawing.Drawing2D;
  using System.Collections;
  using System.ComponentModel;
  using System.Windows.Forms;
  using System.Data;

  public class Form1 : System.Windows.Forms.Form
  {
    public Form1()
    {
      InitializeComponent();
      SetStyle(ControlStyles.ResizeRedraw, true);
    }
    private void InitializeComponent()
    {
      this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
      this.ClientSize = new System.Drawing.Size(211, 104);
      this.Text = "";
      this.Paint += new System.Windows.Forms.PaintEventHandler(this.Form1_Paint);

    }

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

    private void Form1_Paint(object sender, System.Windows.Forms.PaintEventArgs e)
    {
            Graphics g = e.Graphics;
            Pen p = new Pen(Color.Brown, 15);
 
            p.StartCap = LineCap.ArrowAnchor ;
            p.EndCap = LineCap.ArrowAnchor ;
            g.DrawLine(p,30, 30, Width-50, 30);
   
    }
  }


           
          


All LineCap illustration


   


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

public class Form1 : Form
{

      public Form1() {
            InitializeComponent();
            
      }
    private void SimpleStyleRenderer_Paint(object sender, PaintEventArgs e)
    {
      Pen myPen = new Pen(Color.Blue, 10);
      int y = 20;

      foreach (LineCap cap in Enum.GetValues(typeof(LineCap)))
      {
        myPen.StartCap = cap;
        myPen.EndCap = cap;
        e.Graphics.DrawLine(myPen, 20, y, 100, y);
        e.Graphics.DrawString(cap.ToString(), new Font("Tahoma", 8), Brushes.Black, 120, y - 10);
        y += 30;
      }
    }


    private void InitializeComponent()
    {
      this.SuspendLayout();
      // 
      // SimpleStyleRenderer
      // 
      this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
      this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
      this.ClientSize = new System.Drawing.Size(384, 353);
      this.Name = "SimpleStyleRenderer";
      this.Text = "SimpleStyleRenderer";
      this.Paint += new System.Windows.Forms.PaintEventHandler(this.SimpleStyleRenderer_Paint);
      this.ResumeLayout(false);

    }
      [STAThread]
      static void Main()
      {
        Application.EnableVisualStyles();
        Application.Run(new Form1());
      }

}


           
          


Convert bmp image format to jpg, gif, png format images

   
 
class Program
{
    static void Main(string[] args)
    {
        // Load the image.
        System.Drawing.Image image1 = System.Drawing.Image.FromFile(@"C:	est.bmp");

        // Save the image in JPEG format.
        image1.Save(@"C:	est.jpg", System.Drawing.Imaging.ImageFormat.Jpeg);

        // Save the image in GIF format.
        image1.Save(@"C:	est.gif", System.Drawing.Imaging.ImageFormat.Gif);

        // Save the image in PNG format.
        image1.Save(@"C:	est.png", System.Drawing.Imaging.ImageFormat.Png);        
    }
}

   
     


Load JPG file and paint the image


   
 


  using System;
  using System.Drawing;
  using System.Drawing.Drawing2D;
  using System.Collections;
  using System.ComponentModel;
  using System.Windows.Forms;
  using System.Data;
  using System.Drawing.Imaging;

  public class Form1 : System.Windows.Forms.Form
  {
    public Form1()
    {
      InitializeComponent();
    }
    private void InitializeComponent()
    {
      this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
      this.ClientSize = new System.Drawing.Size(292, 273);
      this.Text = "";
      this.Resize += new System.EventHandler(this.Form1_Resize);
      this.Paint += new System.Windows.Forms.PaintEventHandler(this.Form1_Paint);

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

    private void Form1_Paint(object sender, System.Windows.Forms.PaintEventArgs e)
    {      
      Graphics g = e.Graphics;
      Bitmap bmp = new Bitmap("winter.jpg");
      g.DrawImage(bmp, 0, 0);
    }

    private void Form1_Resize(object sender, System.EventArgs e)
    {
      Invalidate();
    }
  }

           
         
     


Draw string with Interpolation Mode: High Quality Bicubic


   



  using System;
  using System.Drawing;
  using System.Drawing.Drawing2D;
  using System.Collections;
  using System.ComponentModel;
  using System.Windows.Forms;
  using System.Data;
  using System.Drawing.Imaging;

  public class Form1 : System.Windows.Forms.Form
  {
    public Form1()
    {
      InitializeComponent();
    }
    private void InitializeComponent()
    {
      this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
      this.ClientSize = new System.Drawing.Size(292, 273);
      this.Text = "";
      this.Resize += new System.EventHandler(this.Form1_Resize);
      this.Paint += new System.Windows.Forms.PaintEventHandler(this.Form1_Paint);

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

    private void Form1_Paint(object sender, System.Windows.Forms.PaintEventArgs e)
    {      
      Graphics g = e.Graphics;
      Bitmap bmp = new Bitmap("winter.jpg");
      g.FillRectangle(Brushes.White, this.ClientRectangle);

      int width = bmp.Width;
      int height = bmp.Height;

      // Resize the image using the highest quality interpolation mode
      g.InterpolationMode = InterpolationMode.HighQualityBicubic;
      g.DrawImage(
        bmp,
        new Rectangle(130, 10, 120, 120),   // source rectangle
        new Rectangle(0, 0, width, height), // destination rectangle
        GraphicsUnit.Pixel);

    }

    private void Form1_Resize(object sender, System.EventArgs e)
    {
      Invalidate();
    }
  }

           
          


Draw image with Interpolation Mode: Nearest Neighbor


   



  using System;
  using System.Drawing;
  using System.Drawing.Drawing2D;
  using System.Collections;
  using System.ComponentModel;
  using System.Windows.Forms;
  using System.Data;
  using System.Drawing.Imaging;

  public class Form1 : System.Windows.Forms.Form
  {
    public Form1()
    {
      InitializeComponent();
    }
    private void InitializeComponent()
    {
      this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
      this.ClientSize = new System.Drawing.Size(292, 273);
      this.Text = "";
      this.Resize += new System.EventHandler(this.Form1_Resize);
      this.Paint += new System.Windows.Forms.PaintEventHandler(this.Form1_Paint);

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

    private void Form1_Paint(object sender, System.Windows.Forms.PaintEventArgs e)
    {      
      Graphics g = e.Graphics;
      Bitmap bmp = new Bitmap("winter.jpg");
      g.FillRectangle(Brushes.White, this.ClientRectangle);

      int width = bmp.Width;
      int height = bmp.Height;

      // Resize the image using the lowest quality interpolation mode
      g.InterpolationMode = InterpolationMode.NearestNeighbor;
      g.DrawImage(
        bmp,
        new Rectangle(10, 10, 120, 120),    // source rectangle
        new Rectangle(0, 0, width, height), // destination rectangle
        GraphicsUnit.Pixel);

    }

    private void Form1_Resize(object sender, System.EventArgs e)
    {
      Invalidate();
    }
  }