public static Bitmap CreateImage(NotationObject notation, int strokeThickness) { Rectangle rect = notation.Rectangle; Bitmap bitmap = new Bitmap(rect.Width, rect.Height); Graphics graphics = Graphics.FromImage(bitmap); foreach (List <Vector2D> coordinates in notation.CoordinateSets) { //Draw line from x -> x + 1 for (int i = 0; i < coordinates.Count - 1; i++) { Vector2D start = new Vector2D(coordinates[i].X, coordinates[i].Y); Vector2D end = new Vector2D(coordinates[i + 1].X, coordinates[i + 1].Y); using (Pen pen = new Pen(Brushes.Black, strokeThickness)) { graphics.DrawLine(pen, start.X, start.Y, end.X, end.Y); } } } return(bitmap); }
public static Bitmap CreateImage(NotationObject notation, Rectangle rect, int strokeThickness) { //Determine the center of the notation rectangle relative to the rect argument int offsetX = rect.Width / 2 - notation.Rectangle.Width / 2; int offsetY = rect.Height / 2 - notation.Rectangle.Height / 2; Bitmap bitmap = new Bitmap(rect.Width, rect.Height); Graphics graphics = Graphics.FromImage(bitmap); foreach (List <Vector2D> coordinates in notation.CoordinateSets) { //Draw line from x -> x + 1 for (int i = 0; i < coordinates.Count - 1; i++) { Vector2D start = new Vector2D(coordinates[i].X, coordinates[i].Y); Vector2D end = new Vector2D(coordinates[i + 1].X, coordinates[i + 1].Y); using (Pen pen = new Pen(Brushes.Black, strokeThickness)) { graphics.DrawLine(pen, start.X + offsetX, start.Y + offsetY, end.X + offsetX, end.Y + offsetY); } } } return(bitmap); }
static void Main(string[] args) { List <string> folders = new List <string>(); List <NotationObject> notationObjects = new List <NotationObject>(); string[] directories = Directory.GetDirectories(INPUT_FOLDER_BASE); for (int i = 0; i < directories.Length; i++) { //Get files per directory string[] files = Directory.GetFiles(directories[i]); for (int j = 0; j < files.Length; j++) { NotationObject obj = Parser.Read(files[j]); notationObjects.Add(obj); } Console.WriteLine("Completed: " + ((float)i / (float)directories.Length) * 100 + "%"); } Rectangle rectangle = GetLargestRectangle(notationObjects); CreateImages(notationObjects, rectangle); }