C#怎么把读取图片,把图片的rgb写进数组
展开全部
新建一个窗体,拉一个panel控件,size属性设成100,100,双击窗体修改事件。
具体代码:
private void Form1_Load(object sender, EventArgs e)
{
string path = "";//输入绝纳团对路洞兄橘径
string[][] a = new string[10][];
if (File.Exists(path))
{
StreamReader sr = new StreamReader(path);
for (int i = 0; i < 10; i++)
{
string strline = sr.ReadLine();
a[i] = strline.Split(',');
} //存入数组尘芹a
sr.Close();
}
Graphics g = this.panel1.CreateGraphics();
for (int j = 0; j < 100; j = j + 10)
{
for (int i = 0; i < 100; i = i + 10)
{
if (Convert.ToInt32(a[i][j]) == 0)
{
g.FillRectangle(Brushes.Black, i, j, 10, 10);
}
else
{
g.FillRectangle(Brushes.White, i, j, 10, 10);
}
}
}
}
具体代码:
private void Form1_Load(object sender, EventArgs e)
{
string path = "";//输入绝纳团对路洞兄橘径
string[][] a = new string[10][];
if (File.Exists(path))
{
StreamReader sr = new StreamReader(path);
for (int i = 0; i < 10; i++)
{
string strline = sr.ReadLine();
a[i] = strline.Split(',');
} //存入数组尘芹a
sr.Close();
}
Graphics g = this.panel1.CreateGraphics();
for (int j = 0; j < 100; j = j + 10)
{
for (int i = 0; i < 100; i = i + 10)
{
if (Convert.ToInt32(a[i][j]) == 0)
{
g.FillRectangle(Brushes.Black, i, j, 10, 10);
}
else
{
g.FillRectangle(Brushes.White, i, j, 10, 10);
}
}
}
}
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询