[英]Distorted images when using ImageList on ToolStripButton
I want to put some images into a ToolStripButton
, and have the images change depending on the state of the button.我想将一些图像放入
ToolStripButton
,并根据按钮的状态更改图像。
So I've set the .ImageList
of the ToolStrip
to be my ImageList
and simply change the ToolStripButton.ImageIndex
to the appropriate value.所以我已经将
ToolStrip
的.ImageList
设置为我的ImageList
并简单地将ToolStripButton.ImageIndex
更改为适当的值。
However, the icons appear distorted in comparison to providing exactly the same picture directly to the ToolStripButton.Image
property.但是,与直接向
ToolStripButton.Image
属性提供完全相同的图片相比,图标显得扭曲。
In the picture below the image on the left hand side is the one from the ImageList
, the one on the right is being set through ToolStripButton.Image
.在下图中,左侧的图像是来自
ImageList
的图像,右侧的图像是通过ToolStripButton.Image
设置的。 As you can see, the one on the left has some small odd pixels, specially visible when the button is selected.如您所见,左侧的有一些小的奇数像素,在选择按钮时特别明显。
I've tried modifying the TransparencyColor
and ColorDepth
but that's not made any difference.我试过修改
TransparencyColor
和ColorDepth
但这没有任何区别。 Any clues as to what I'm missing?关于我失踪的任何线索?
尝试将AutoSize
设置为false
并将ImageScaling
设置为ToolStripItemImageScaling.None
。
You can put pictures in Resources and replace ImageList
with Dictionary
?你可以把图片放在 Resources 中,用
Dictionary
替换ImageList
吗? In this case, pictures will be equal to the original.在这种情况下,图片将与原始图片相同。
Dim dictPictures As New Dictionary(Of String, Bitmap)
Dim runTimeResourceSet As Object
Dim dictEntry As DictionaryEntry
runTimeResourceSet = My.Resources.ResourceManager.GetResourceSet(System.Globalization.CultureInfo.CurrentCulture, True, True)
For Each dictEntry In runTimeResourceSet
If (dictEntry.Value.GetType() Is GetType(Bitmap)) Then
If Not dictPictures.ContainsKey(dictEntry.Key & ".png") Then dictPictures.Add(dictEntry.Key & ".png", dictEntry.Value)
End If
Next
PS Code is in VB.NET
but you'll get the point. PS 代码在
VB.NET
但您会明白这一点。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.