创建图像并设置其颜色 [英] Create image and set its color
本文介绍了创建图像并设置其颜色的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何创建图像并设置其颜色?
How do I create an image and set its color?
推荐答案
我会提供与您要求的一样多的答案.
C#创建图像 [ ^ ]
C#图片颜色 [ ^ ]
I''ll put in as much answering as you did asking.
C# create image[^]
C# image color[^]
这是一种简单但效率低下的方法:
Here''s an easy but rather inefficient approach:
Bitmap bitmap = new Bitmap(100, 100);
for (int i = 0; i < 100; i++)
{
for (int j = 0; j < 100; j++)
{
bitmap.SetPixel(i, j, Color.Blue);
}
}
public static Bitmap CreateBitmap(int width, int height, Color color)
{
Bitmap b = new Bitmap(width, -height);
using (Graphics g = Graphics.FromImage(b))
{
g.Clear(color);
}
return b;
}
这篇关于创建图像并设置其颜色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文