Ejemplo n.º 1
0
        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;
        }
Ejemplo n.º 2
0
        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;
        }
Ejemplo n.º 3
0
        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;
        }