C#怎么把图片放数组里 5
数组是PictureBox[]ps;Image[]ims;Image[]imd;intspeed=20;intcounter=0;privatevoidfightgame...
数组是
PictureBox[] ps;
Image[] ims;
Image[] imd;
int speed = 20;
int counter = 0;
private void fightgame_Load(object sender, EventArgs e)
{
ps = new PictureBox[12];
ims = new Image[3];
imd = new Image[3];
} 展开
PictureBox[] ps;
Image[] ims;
Image[] imd;
int speed = 20;
int counter = 0;
private void fightgame_Load(object sender, EventArgs e)
{
ps = new PictureBox[12];
ims = new Image[3];
imd = new Image[3];
} 展开
3个回答
展开全部
可以这样,image是个抽象类,不管用imge[]数组还是list<image> 都只是第一步,需要的是往数组里面存image;
List<Image> imgArr = new List<Image>();
imgArr.Add(Image.FromFile("a.jpg", false));
imgArr.Add(Image.FromFile("a.jpg", false));
imgArr.Add(Image.FromFile("a.jpg", false));
System.Collections.IEnumerator itor = imgArr.GetEnumerator();
while (itor.MoveNext())
{
Console.WriteLine(((Image)itor.Current).RawFormat);//输出图片的格式
}
List<Image> imgArr = new List<Image>();
imgArr.Add(Image.FromFile("a.jpg", false));
imgArr.Add(Image.FromFile("a.jpg", false));
imgArr.Add(Image.FromFile("a.jpg", false));
System.Collections.IEnumerator itor = imgArr.GetEnumerator();
while (itor.MoveNext())
{
Console.WriteLine(((Image)itor.Current).RawFormat);//输出图片的格式
}
展开全部
再加上:
PictureBox pb1 = new PictureBox();
pb1.Image = ims[0];
ps[0] = pb1;
PictureBox pb1 = new PictureBox();
pb1.Image = ims[0];
ps[0] = pb1;
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
建个list好了
list<image>
list<image>
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询