2014-10-29 133 views
0

我正在玩我的listbox,但我意識到,因爲圖像質量突然下降。 listbox使用imagelist控件查看其圖標。這是我的設計器代碼中的listbox和我的imagelist屬性。Listview圖像質量變低

列表視圖:

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"); 

當前圖像質量

Current image quality

畫面圖像列表圖像

Real quality of the picture

+0

什麼imageList控件imageSize設置和什麼是原始圖片大小? – Reniuz 2014-10-29 08:14:15

+0

@Reniuz都是'64x64'。而我的列表框的'LargeImageList' ColorDepth被設置爲'Depth32Bit'。 – Disasterkid 2014-10-29 08:18:12

+0

你的文檔是不完美的,「真實質量」的圖像是JPEG,我不能告訴任何關於原始格式的東西。 「質量不好」的圖片尺寸不合適,我無法分辨這是造成質量損失的原因還是僅僅是製作截圖的副作用。你必須創建一個repro項目,這樣有人可以下載它,並知道它真的*看起來像什麼。 – 2014-10-29 08:27:22

回答

0

質量下降時,加載的圖像是PNG或ICO格式的真實質量是一個常見的問題。我也在WinForm C#應用程序中體驗過它。

圖像列表圖像被序列化爲Base64編碼圖像的形式的.resx文件,我相信在序列化圖像時存在一個錯誤,因爲當它們被序列化多次時,您肯定會看到質量下降可能會弄亂Alpha /透明度通道)。然後,當您從圖像列表中刪除圖像並再次添加它們時,它們看起來很好,直到圖像列表被序列化幾次,質量下降再次可見。

我解決了這個問題,只需避免在我的應用程序中使用圖像列表。使用圖像的數組或字典也可以解決質量下降問題。如果您仍想使用圖像列表,則可能的解決方案是在運行時創建並填充圖像列表,而不是使用設計器。