Tag: imagelist

ImageList上的32位图像

我有以下图片: 我正在从资源中读取它,放入ImageList,然后从ImageList读取它以在我的控件表面上绘制。 但是当我这样做时,图像似乎松散了有关alpha通道的信息: 以下是所有相关的代码: Program.cs中 Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); MainForm.cs ilFilters = new ImageList() { ColorDepth = ColorDepth.Depth32Bit, ImageSize = new Size(16, 16) }; // (…) if (info.Icon != null) { if (info.Icon.Width == 16 && info.Icon.Height == 16) { ilFilters.Images.Add(info.Icon); index = ilFilters.Images.Count – 1; } } 我实际上在( info.Icon )和之后( ilFilters.Images[0] )将图像保存到图像列表中。 第一个版本是正确的,第二个 – 已损坏。 好像ImageList损坏了图像。 […]

处理ImageList

处理ImageList对象的适当方法是什么? 假设我有一个private ImageList imageList成员的类。 现在,在某些时刻,我执行以下代码: // Basically, lazy initialization. if (imageList == null) { imageList = new ImageList(); Image[] images = Provider.CreateImages(…); foreach (var image in images) { // Does the ‘ImageList’ perform implicit copying here // or does it aggregate a reference? imageList.Images.Add(image); // Do I need to do this? //image.Dispose(); } } return […]

如何使用C#为listview控件中的项添加边框?

我正在使用listview控件,我通过ImageList添加图像 if (dtPhoto.Rows.Count > 0) { foreach (DataRow dr in dtPhoto.Rows) { if (dr[“Photo”].ToString() != “”) { byte[] barrImg = (byte[])dr[“Photo”]; MemoryStream mStream = new MemoryStream(barrImg); imageList.Images.Add(Image.FromStream(mStream)); } } } imageList.ImageSize = new Size(75, 75); lvItem.LargeImageList = imageList; for (int i = 0; i < imageList.Images.Count; i++) { lvItem.Items.Add(dtPhoto.Rows[i]["Name"].ToString() + "\n" + "(" + dtPhoto.Rows[i]["Type"].ToString() […]

ImageList:处理原始图像会将其从列表中删除

ImageList应创建插入其中的所有图像的副本。 因此,在将原件添加到列表后处置原件应该是安全的。 为什么以下测试用例失败? Bitmap test = new Bitmap(128, 128); ImageList il = new ImageList(); il.Images.Add(test); Assert.AreEqual(1, il.Images.Count); // OK, image has been inserted test.Dispose(); // now let’s dispose the original try { var retrievalTest = il.Images[0]; } catch (ArgumentException) // … but this Exception happens! { } Assert.AreEqual(1, il.Images.Count); // and this will fail 这里似乎发生了这样的事情:当试图检索图像时,ImageList发现原件已被丢弃,并将其从ImageList中移除。 […]

如何使用imageList控件

我有一些图像,我手动添加到imageList Cotrol。 现在我需要从imageList中删除thart图像,具体取决于键索引并设置为面板背景。 我该怎么办