Draw Cross on Bitmap - CSharp System.Drawing

CSharp examples for System.Drawing:Image Operation

Description

Draw Cross on Bitmap

Demo Code


using System.Text;
using System.Drawing;
using System.Collections.Generic;
using System;//from  ww w . j a  v a 2s.c o m

public class Main{

      public static void DrawCross(this Bitmap map, Color color, int x, int y)
      {
         map.DrawPoint(color, x, y);
         map.DrawPoint(color, x - 1, y);
         map.DrawPoint(color, x + 1, y);
         map.DrawPoint(color, x, y - 1);
         map.DrawPoint(color, x, y + 1);
      }

      public static void DrawPoint(this Bitmap map, Color color, int x, int y)
      {
         if (x < 0 || y < 0 || x >= map.Width || y >= map.Height) return;
        map.SetPixel(x, y, color);
      }
}

Related Tutorials