我对显示在TabPage头上的图像的图像质量有问题。我的源图像是一个透明的16x16PNG。当我将它加载到TabPage头中时,质量是可怕的。到目前为止,我能想到的最好的方法是使用8位的png而不是32位的png。这很有帮助,但质量仍然没有我想要的那么好,也没有32位png那么好。有没有人有一个很好的方法来保持png的质量?
(左边是32位原作。)32位标签头在右边质量较低。)
(左边有8位原作)。8位标签头右边质量较低。)
(左边是32位原作。)8位标签头右边质量较低。)
我试图/希望它尽可能接近原来的32位png。
我使用以下代码:
using System.Drawing;
using System.Windows.Forms;
public class Form1
{
public void Form1()
{
InitializeComponent();
// initialize the imagelist
ImageList imageList1 = new ImageList();
imageList1.Images.Add("key1", Properties.Resources.Image1png);
imageList1.Images.Add("key2", Properties.Resources.Image2png);
//initialize the tab control
TabControl tabControl1 = new TabControl();
tabControl1.Dock = DockStyle.Fill;
tabControl1.ImageList = imageList1;
tabControl1.TabPages.Add("tabKey1", "TabText1", "key1");
tabControl1.TabPages.Add("tabKey2", "TabText2", "key2");
this.Controls.Add(tabControl1);
}
}
发布于 2015-02-04 05:46:41
不确定这是否回答了您的问题,但必须将其作为答案来包含快照。
您可以尝试如下:
或者只是在代码中修改它:
imageList1.ColorDepth = ColorDepth.Depth32Bit;
发布于 2016-10-17 09:42:45
在ImageList (与TabControl相关联)中,删除所有图像,并以相同的顺序再次添加它们。
这是唯一适合我的方法!
https://stackoverflow.com/questions/28313137
复制相似问题