在运行时创建图像 - aForge?

时间:2013-12-18 01:36:45

标签: c# image

我需要在运行时创建一个空白图像。我已经尝试创建一个并创建一个,将其保存到磁盘然后访问它。我正在序列化它们的数组,所以我不能跳过一个。我也看过aForge,一些整洁的纹理方法,但我不熟悉他们的文档。我试图快速实现我在这里找到的一些东西..

    Bitmap bmp = new Bitmap(255, 255);
    using (Graphics gfx = Graphics.FromImage(bmp))
    using (SolidBrush brush = new SolidBrush(Color.FromArgb(0, 0, 0)))
    {
        gfx.FillRectangle(brush, 0, 0, 255, 255);
    }

    using (Bitmap bitmap = new Bitmap(255, 255))
    {
        using (Graphics graphics = Graphics.FromImage(bitmap))
        {
            SolidBrush brush = new SolidBrush(Color.FromArgb(0, 0, 0));
        }
        bitmap.Save(dirPath + "\\" + "_Error_Image.png");
    }

既没有成功。有没有人有一个简单的方法来实现这一目标?

1 个答案:

答案 0 :(得分:0)

你可能想要它吗?

Bitmap bitmap = new Bitmap(255, 255))

bitmap.Save(dirPath + "\\" + "_Error_Image.png");

如果你的意思是空白则不会这样做,如果你想将来参考Color.FromArgb(0, 0, 0, 0),你可以将颜色设置为透明 - 第一个参数是Alpha,其中0 =透明,255 =完全不透明。

相关问题