使用 TabControl ImageList 的 TabPage header 中的低质量图像
Low quality image in TabPage header using TabControl ImageList
我在 TabPage header 上显示的图像质量有问题。我的源图像是具有透明度的 16x16 png。当我将它加载到 TabPage header 时,质量很糟糕。到目前为止,我能想到的最好办法是使用 8 位 png 而不是 32 位 png。这有很大帮助,但质量仍然不如我想要的那么好,而且仍然不如 32 位 png。有没有人有保持 png 质量的好方法?
(左侧为 32 位原件。右侧为 32 位选项卡 header 质量较低。)
(左侧为 8 位原件。右侧为 8 位标签 header 较低质量。)
(左侧为 32 位原件。右侧为 8 位标签 header 较低质量。)
我 trying/hoping 让它看起来尽可能接近原始的 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);
}
}
不确定这是否回答了您的问题,但必须 post 它作为包含快照的答案。
您可以尝试以下操作:
- Select图片列表;
- 配置颜色深度属性,并将其从"Depth8bit"设置为"Depth32bit"
或者直接在代码中修改:
imageList1.ColorDepth = ColorDepth.Depth32Bit;
在 ImageList(与 TabControl 关联)中,删除所有图像并以相同的顺序重新添加它们。
这是对我唯一有效的方法!
我在 TabPage header 上显示的图像质量有问题。我的源图像是具有透明度的 16x16 png。当我将它加载到 TabPage header 时,质量很糟糕。到目前为止,我能想到的最好办法是使用 8 位 png 而不是 32 位 png。这有很大帮助,但质量仍然不如我想要的那么好,而且仍然不如 32 位 png。有没有人有保持 png 质量的好方法?
(左侧为 32 位原件。右侧为 32 位选项卡 header 质量较低。)
(左侧为 8 位原件。右侧为 8 位标签 header 较低质量。)
(左侧为 32 位原件。右侧为 8 位标签 header 较低质量。)
我 trying/hoping 让它看起来尽可能接近原始的 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);
}
}
不确定这是否回答了您的问题,但必须 post 它作为包含快照的答案。
您可以尝试以下操作:
- Select图片列表;
- 配置颜色深度属性,并将其从"Depth8bit"设置为"Depth32bit"
或者直接在代码中修改:
imageList1.ColorDepth = ColorDepth.Depth32Bit;
在 ImageList(与 TabControl 关联)中,删除所有图像并以相同的顺序重新添加它们。
这是对我唯一有效的方法!