我正在玩我的listbox
,但我意识到因为这些图像'质量突然下降。 listbox
使用imagelist
控件查看其图标。以下是我的设计器代码中的listbox
和imagelist
属性。
列表视图:
this.listviewFiles.Font = new System.Drawing.Font("Georgia", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.listviewFiles.LargeImageList = this.imageListFiles;
this.listviewFiles.Location = new System.Drawing.Point(3, 14);
this.listviewFiles.Name = "listviewFiles";
this.listviewFiles.Size = new System.Drawing.Size(761, 392);
this.listviewFiles.TabIndex = 4;
this.listviewFiles.UseCompatibleStateImageBehavior = false;
this.listviewFiles.SelectedIndexChanged += new System.EventHandler(this.listviewFiles_SelectedIndexChnaged);
this.listviewFiles.Click += new System.EventHandler(this.listviewFiles_Click);
的ImageList
this.imageListFiles.ImageStream = ((System.Windows.Forms.ImageListStreamer)(resources.GetObject("imageListFiles.ImageStream")));
this.imageListFiles.TransparentColor = System.Drawing.Color.Transparent;
this.imageListFiles.Images.SetKeyName(0, "csv.ico");
this.imageListFiles.Images.SetKeyName(1, "sql.ico");
当前图像质量
图片的真实质量
答案 0 :(得分:0)
当加载的图像是PNG或ICO格式时,图像列表图像的质量下降是一个常见问题。我也在WinForm C#应用程序中体验过它。
图像列表图像被序列化为表格的.resx文件,作为Base64编码图像,我相信序列化图像时会出现错误,因为当它们被序列化多次时,你肯定可以看到质量下降(可能是混淆alpha /透明度通道的东西)。然后,当您从图像列表中删除图像并再次添加它们时,它们看起来很好,直到图像列表被序列化几次,质量下降再次可见。
我通过简单地避免在我的应用程序中使用图像列表来解决问题。使用数组或图像字典同样可以解决质量下降问题。如果您仍想使用图像列表,则可能的解决方案是在运行时创建和填充图像列表,而不是使用设计器。
答案 1 :(得分:0)
你能试试吗
ImageList largeImageList = new ImageList();
largeImageList.ColorDepth = ColorDepth.Depth32Bit;
largeImageList.ImageSize = new Size(64, 64); //actual size of image
largeImageList.Images.Add(Properties.Resources.psd64);
ListView listView = new ListView();
listView.LargeImageList=largeImageList;
我认为这将永远解决您的问题:))