public ICanvas CreateIntermediate(string name, int w, int h) { if (name == null) throw new ArgumentNullException("name", "Cannot use a null name for a canvas"); ICanvas canvas = new BasicCanvas(CanvasMode.ReadWrite, name, w, h); CreateVariable(canvas.Name, new CanvasValue() {Canvas = canvas}); return canvas; }
public ICanvas CreateOutput(string name, int w, int h) { if (name == null) throw new ArgumentNullException("name", "Cannot use a null name for a canvas"); ICanvas canvas = new BasicCanvas(CanvasMode.WriteOnly, name, w, h); CreateVariable(canvas.Name, new CanvasValue() {Canvas = canvas}); _outputs.Add(canvas); return canvas; }
public ICanvas LoadCanvas(string name) { string path = null; if (!names.TryGetValue(name, out path)) return null; Bitmap bitmap = new Bitmap(path); ICanvas canvas = new BasicCanvas(CanvasMode.ReadOnly, name, bitmap.Width, bitmap.Height); for (int y = 0; y < canvas.Height; ++y) { for (int x = 0; x < canvas.Width; ++x) { System.Drawing.Color color = bitmap.GetPixel(x, y); canvas.ForceWrite(x, y, new Color(color.R / 255f, color.G / 255f, color.B / 255f, color.A / 255f)); } } return canvas; }