imageList增加图片时出现内存不足,求帮助!
出错代码:
************** 异常文本 **************
System.OutOfMemoryException: 内存不足。
在 System.Drawing.Graphics.CheckErrorStatus(Int32 status)
在 System.Drawing.Graphics.DrawImage(Image image, Rectangle destRect, Int32 srcX, Int32 srcY, Int32 srcWidth, Int32 srcHeight, GraphicsUnit srcUnit, ImageAttributes imageAttrs, DrawImageAbort callback, IntPtr callbackData)
在 System.Drawing.Bitmap.MakeTransparent(Color transparentColor)
在 System.Windows.Forms.ImageList.CreateBitmap(Original original, Boolean& ownsBitmap)
在 System.Windows.Forms.ImageList.ImageCollection.Add(Original original, ImageInfo imageInfo)
在 System.Windows.Forms.ImageList.ImageCollection.Add(String key, Image image)
在 Equn.KDDPrint.frmDownload.kd_ViewCompleted(Object sender, ViewCompletedEventArgs e)
在 Equn.KDDPrint.KddService.kdd.OnViewOperationCompleted(Object arg)
在开发的机器上测试是正常的,测试好些台1G内存的电脑时出错。程序代码如下:
void kd_ViewCompleted(object sender, ViewCompletedEventArgs e)
{
//清除原有项目
listView1.Items.Clear();
imageList1.Images.Clear();
vTemplate[] vts = e.Result;
StartIndex = (PageIndex - 1) * 4 + 1;
EndIndex = StartIndex + vts.Length - 1;
this.Text = "共有 " + TemplateCount.ToString() + " 个模板,当前第" + StartIndex.ToString() + "到" + EndIndex.ToString() + "个"+" - 模板下载";
foreach (vTemplate vt in vts)
{
ListViewItem item = new ListViewItem();
item.Text = vt.title;
item.Tag = vt.id;
item.ToolTipText = vt.id.ToString() + "号模板:" + vt.title;
Image logo= StringToImage(vt.smallimg);
imageList1.Images.Add("img" + vt.id.ToString(), logo); //应该是这里出错了
&n