ListView 图像选择蒙版
我在 View = LargeIcons
中有一个 ListView。我添加了一个 PNG 图标(黑色,白色背景,32 位 ARGB)和两个使用 System.Drawing.Graphics 制作的图标(白色背景,Pixelformat 32bppArgb)。
当我选择列表中的图标时,PNG 被很好地屏蔽/突出显示,但是我以编程方式绘制的自定义图标在屏蔽/突出显示时具有可怕的伪影(屏幕截图中的最后两个)。
看看:
如何使我的图标与外部图形一样精细?
生成代码:
Bitmap bmp = new Bitmap(THUMB_WIDTH, THUMB_HEIGHT, formatThumbs);
using(Graphics g = Graphics.FromImage(bmp))
{
g.PixelOffsetMode = System.Drawing.Drawing2D.PixelOffsetMode.HighQuality;
g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighQuality;
g.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.HighQualityBicubic;
g.CompositingMode = System.Drawing.Drawing2D.CompositingMode.SourceCopy;
g.CompositingQuality = System.Drawing.Drawing2D.CompositingQuality.HighQuality;
g.TextRenderingHint = System.Drawing.Text.TextRenderingHint.AntiAliasGridFit;
g.Clear(Color.White);
g.DrawEllipse(penThumbLine, 1, 1, THUMB_WIDTH - 2, THUMB_HEIGHT - 2);
}
return bmp;
当我将 Clear
颜色更改为 Color.Transparent
时,选择条目/图标时不会突出显示。 ImageList
TransparentColor
是 Color.Transparent
。
I have a ListView in View = LargeIcons
. I added an icon which I have done as PNG (black with white background, 32bit ARGB) and two icons I have done with System.Drawing.Graphics
(white background, Pixelformat 32bppArgb).
When I selected the icons in the list, the PNG is masked/highlighted fine, but my custom icons drawn programatically have awful artefacts when masked/highlighted (last two ones in the screenshot).
Have a look:
How can I render my icons as fine as the external graphic?
Generation code:
Bitmap bmp = new Bitmap(THUMB_WIDTH, THUMB_HEIGHT, formatThumbs);
using(Graphics g = Graphics.FromImage(bmp))
{
g.PixelOffsetMode = System.Drawing.Drawing2D.PixelOffsetMode.HighQuality;
g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighQuality;
g.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.HighQualityBicubic;
g.CompositingMode = System.Drawing.Drawing2D.CompositingMode.SourceCopy;
g.CompositingQuality = System.Drawing.Drawing2D.CompositingQuality.HighQuality;
g.TextRenderingHint = System.Drawing.Text.TextRenderingHint.AntiAliasGridFit;
g.Clear(Color.White);
g.DrawEllipse(penThumbLine, 1, 1, THUMB_WIDTH - 2, THUMB_HEIGHT - 2);
}
return bmp;
When I change the Clear
color to Color.Transparent
there is no highlight visible when the entry/icon is selected. The ImageList
TransparentColor
is Color.Transparent
.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论