vista和win7色差

发布于 2024-10-20 16:12:27 字数 1299 浏览 1 评论 0原文

有一个以图像形式显示在图形视口中的指示器。指示器可以是用户选择的任何颜色,因此我们使用调色板创建了单个图像,并使用以下代码将调色板中的特定颜色更改为用户选择的颜色。

    /// <summary>
    /// Copies the image and sets transparency and fill colour of the copy. The image is intended to be a simple filled shape such as a square
    /// with the inside all in one colour.
    /// </summary>
    /// <remarks>Assumes the fill colour to be changed is Red,
    /// black is the boundary colour and off white (RGB 233,233,233) is the colour to be made transparent</remarks>
    /// <param name="image"></param>
    /// <param name="fillColour"></param>
    /// <returns></returns>
    protected Bitmap CopyWithStyle(Bitmap image, Color fillColour)
    {
        ColorPalette selectionIndicatorPalette = image.Palette;

        int fillColourIndex = selectionIndicatorPalette.IndexOf(Color.Red);

        selectionIndicatorPalette.Entries[fillColourIndex] = fillColour;

        image.Palette = selectionIndicatorPalette;

        Bitmap tempImage = image;
        tempImage.MakeTransparent(transparentColour);
        return tempImage;
    }

老实说,我不确定这是否有点笨拙,是否有一些更聪明的方法,所以任何想法都会有帮助。然而,主要问题是,这在 Win7 上似乎工作正常,但在 Vista 和 XP 中颜色没有改变。有没有人见过这个。我发现一两篇文章表明它们之间的 ARGB 存在一些差异,但没有什么特别具体的。任何帮助都非常接受。

Have an indicator in the form of an image which is displayed in a graphics viewport. The indicator can be any colour the user selects so we created a single image with a pallette and change a specific color in the pallette to the one the user picks using the following code.

    /// <summary>
    /// Copies the image and sets transparency and fill colour of the copy. The image is intended to be a simple filled shape such as a square
    /// with the inside all in one colour.
    /// </summary>
    /// <remarks>Assumes the fill colour to be changed is Red,
    /// black is the boundary colour and off white (RGB 233,233,233) is the colour to be made transparent</remarks>
    /// <param name="image"></param>
    /// <param name="fillColour"></param>
    /// <returns></returns>
    protected Bitmap CopyWithStyle(Bitmap image, Color fillColour)
    {
        ColorPalette selectionIndicatorPalette = image.Palette;

        int fillColourIndex = selectionIndicatorPalette.IndexOf(Color.Red);

        selectionIndicatorPalette.Entries[fillColourIndex] = fillColour;

        image.Palette = selectionIndicatorPalette;

        Bitmap tempImage = image;
        tempImage.MakeTransparent(transparentColour);
        return tempImage;
    }

To be honest I'm not sure if this is a bit cludgy and there is some smarter approach or not, so any thoughts there would help. However the main issue is that this appears to work fine on Win7 but in vista and XP the color does not change. Has any one seen this before. I've found one or two articles that suggest there are some differences in ARGB between them but nothing particularly concrete. Any help greatfully accepted.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

秋凉 2024-10-27 16:12:27

大家好,我们已经将其确定为 MakeTransparent 调用。我们已更改为使用透明 GIF 来避免此调用。也许应该首先这样做,因为无论如何它更有效。

Hi All we have nailed it down to the MakeTransparent call. We have changed to using a transparent GIF to avoid this call. Should probably have done that in the first place as it's more efficient anyway.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文