作者derekjitter (小王子)
看板C_Sharp
標題Re: [問題] 連續播圖片記憶體不足
時間Sat May 15 12:25:59 2010
按照evirtues大大講的 在外面new四個bitmap物件
然後不要用到 System.Drawing.Image.FromHbitmap()
就解決了XD
如下:
// 在外面new四個Bitmap
Bitmap a = new Bitmap (Resource1.pitcher0);
Bitmap b = new Bitmap (Resource1.pitcher3);
Bitmap c = new Bitmap (Resource1.pitcher4);
Bitmap d = new Bitmap (Resource1.pitcher5);
private void timer1_Tick(object sender, EventArgs e)
{
switch (n % 4)
{
case 0:
pictureBox1.Image = (Image)a;
n += 1;
break;
case 1:
pictureBox1.Image = (Image)b;
n += 1;
break;
case 2:
pictureBox1.Image = (Image)c;
n += 1;
break;
case 3:
pictureBox1.Image = (Image)d;
n = 0;
break;
}
}
謝謝大家XDD
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 140.112.18.210
1F:→ remmurds:怎麼不考慮使用ImageList呢? 05/15 13:34
2F:→ evirtues:switch中直接用pictureBox1.Image = Resource1.pitcherX 05/15 21:56
3F:→ evirtues:應該不需要新增四個bitmap物件 05/15 21:56
4F:→ optimist9266:資源檔回傳的型別直接就是Bitmap了... 05/15 22:46