Skip to content

Instantly share code, notes, and snippets.

@ralhamami
Created April 23, 2017 03:23
Show Gist options
  • Save ralhamami/6c93fa4b0396fd3db0ed8b431a0b40cd to your computer and use it in GitHub Desktop.
Save ralhamami/6c93fa4b0396fd3db0ed8b431a0b40cd to your computer and use it in GitHub Desktop.
List<Point> points = new List<Point>();
List<int> tempX = new List<int>();
List<int> tempY = new List<int>();
using (StreamReader reader = new StreamReader("Your_Source_File.SIG"))
{
while (!reader.EndOfStream)
{
Regex reg = new Regex(@"^\d+\s\d+$");
string checkLine = reader.ReadLine();
if (reg.IsMatch(checkLine))
{
string[] temp = checkLine.Split(' ');
tempX.Add(Convert.ToInt32(temp[0]));
tempY.Add(Convert.ToInt32(temp[1]));
}
}
}
int leftmost = tempX.Min();
int rightmost = tempX.Max() - leftmost;
int topmost = tempY.Min();
int bottommost = tempY.Max() - topmost;
for (int i = 0; i < tempY.Count; i++)
{
points.Add(new Point(tempX[i] - leftmost, tempY[i] - topmost));
}
Pen blackPen = new Pen(Brushes.Black, 1);
Bitmap bmp = new Bitmap(rightmost, bottommost);
Graphics g = Graphics.FromImage(bmp);
for (int i = 1; i < points.Count; i++)
{
g.DrawLine(blackPen, points[i - 1], points[i]);
//g.FillRectangle(Brushes.Black, points[i].X,points[i].Y,1,1);
}
Directory.CreateDirectory("Signatures");
bmp.Save("Signatures\\" + Path.GetFileNameWithoutExtension("Your_Source_File.SIG") + ".png");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment