public static To1bpp ( string filename ) : byte[] | ||
filename | string | |
return | byte[] |
// for testing static public void Main(string[] args) { if (args.Length < 1) { System.Console.WriteLine("File name required"); } else if (!System.IO.File.Exists(args[0])) { System.Console.WriteLine("File does not exist: " + args[0]); } else { byte[] newbmp = BitmapConverter.To1bpp(args[0]); System.Console.WriteLine(newbmp); System.IO.File.WriteAllBytes("out.bmp", newbmp); } }
public void draw() { Graphics g = Graphics.FromImage(bmp); Brush whiteBrush = new SolidBrush(Color.White); bmp.SetResolution(IMAGE_HEIGHT / 2, IMAGE_WIDTH / 2); g.TranslateTransform(0f, IMAGE_HEIGHT); g.ScaleTransform(1f, -1f); g.FillRegion(whiteBrush, new Region(new Rectangle(0, 0, IMAGE_WIDTH, IMAGE_HEIGHT))); Brush blackBrush = new SolidBrush(Color.Black); Pen p = getPen(blackBrush); List <Point> line = new List <Point>(); foreach (Point point in points) { if (point.IsEmpty) { try { g.DrawLines(p, line.ToArray()); line.Clear(); } catch (Exception) { } } else { line.Add(point); } } bmp.Save(filename, System.Drawing.Imaging.ImageFormat.Bmp); var bpp = BitmapConverter.To1bpp(filename); File.WriteAllBytes(filename, bpp); }