我是编码初学者并尝试解决简单问题:
我有一个包含三列的列表,并试图访问存储在列表中的值。它没有给我答案......任何想法?谢谢
private void btnImage1Load_Click(object sender, EventArgs e)
{
openFileDialog1.ShowDialog();
pictureBox1.ImageLocation = openFileDialog1.FileName;
}
public class ListThreeColumns
{
public int XCoord { get; set; }
public int YCoord { get; set; }
public Color Color { get; set; }
}
private List<ListThreeColumns> GetPixels()
{
Bitmap picture = new Bitmap(pictureBox1.Image);
List<ListThreeColumns> colorList = new List<ListThreeColumns>
{
};
for (int y = 0; y < picture.Height; y++)
{
for (int x = 0; x < picture.Width; x++)
{
colorList.Add(new ListThreeColumns { XCoord = x, YCoord = y, Color = picture.GetPixel(x, y) });
}
}
return colorList;
}
private void btnScanPixels_Click(object sender, EventArgs e)
{
List<ListThreeColumns> seznamBarev = GetPixels();
MessageBox.Show(seznamBarev[6].ToString());
}