1

有什么方法可以更快地加载和显示 100 (10x10) 图片框?所有图像的大小为 40x40 像素 (5KB)。我认为有比我的代码更好的方法,但我现在太大了新手。

PictureBox[,] tile = new PictureBox[10,10];

for (int j = 0; j < 10; j++)
{
    for (int i = 0; i < 10; i++)
    {
        tile[j, i] = new PictureBox();
        if (mapa[j,i] == 0) tile[j, i].ImageLocation = folder + @"\\Images\ground.bmp";
        if (mapa[j, i] == 1) tile[j, i].ImageLocation = folder + @"\\Images\\lava.bmp";
        if (mapa[j, i] == 2) tile[j, i].ImageLocation = folder + @"\\Images\\win.bmp";

        tile[j, i].Location = new Point(10 + (41 * j), 10 + (41 * i));
        tile[j, i].SizeMode = System.Windows.Forms.PictureBoxSizeMode.AutoSize;
        progressBar1.Increment(1); 
        this.Refresh();
    }
}
4

0 回答 0