2012-08-01 74 views
2

我使用VB.net列表视图中的低质量缩略图VB.net

我使用ListView查看项目左侧的50 * x缩略图(.jpg)。

但是,而不是32位高品质的缩略图,ListView降低他们到8位或16位(不确定)。

下面的代码

Private Sub afterprocessed() 
    ListView1.Items.Clear() 
    Dim imlTemp As New ImageList 
    Dim dirFiles() As String = IO.Directory.GetFiles("backend\communicate\thumbnails") 
    Dim _imgList As New ImageList 
    Dim imgSize As New Size 
    imgSize.Width = 50 
    ListView1.SmallImageList = _imgList 
    Dim count As Integer = 0 
    Dim item As New ListViewItem 
    For Each dirFile As String In dirFiles 
     Dim imgFilename As String = IO.Path.GetFileNameWithoutExtension(dirFile) 
     Dim img As New System.Drawing.Bitmap(dirFile) 
     Dim imgImage As Image = Image.FromFile(dirFile) 
     'Dim imgHeight As Integer 
     'imgHeight = imgImage.Height 
     imgSize.Height = imgImage.Height 
     _imgList.ImageSize = imgSize 
     _imgList.Images.Add(img.Clone) 
     ListView1.Items.Add(imgFilename, count) 
     count += 1 
    Next 
End Sub 

,质量noticably低。与原始JPG相比

有什么建议吗?我非常感谢它:D

+0

你可以发布原始和低质量版本的屏幕截图吗? – 2012-08-01 11:29:23

回答

0

我有一个类似的问题一次,我发现它是由于使用ImageList.ImageSize方法,似乎使用一个不好的调整大小算法造成的。我解决了这个问题,确保在加载它之前,我使用的所有图像在磁盘上已经是正确的大小。但是,如果这不是您的选择,那么 之前将它们添加到ImageList应该不是太难。

+0

谢谢!我完全明白你的意思。但是,我应该改变列表视图*添加时不调整大小?再次感谢:D – arter97 2012-08-05 08:42:00

+0

这不是'ListView',而是'ImageList'这就是问题所在。在添加图像之前先获取图像大小*,这样就不必使用ImageSize方法。 – Antagony 2012-08-06 21:10:06

0

你需要这个。

this.ListView1.SmallImageList.ColorDepth = ColorDepth.Depth32Bit;