vista和Win7之间的颜色差异
问题描述:
在图形视口中显示图像形式的指示器。该指标可以是用户选择的任何颜色,因此我们使用调色板创建了单个图像,并将调色板中的特定颜色更改为用户使用以下代码挑选的颜色。vista和Win7之间的颜色差异
/// <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;
}
说实话,我不知道这是一个有点cludgy并有一些聪明的办法还是不行,所以任何想法会有帮助。然而,主要问题是,这似乎在Win7上正常工作,但在Vista和XP中,颜色不会改变。有没有人见过这个。我发现有一两篇文章表明它们之间的ARGB存在一些差异,但没有什么特别具体的。任何帮助很好地接受。
答
嗨,我们已经把它定位到MakeTransparent调用。我们更改为使用透明的GIF来避免此呼叫。无论如何,它应该首先做到这一点,因为它效率更高。
我建议使用透明的PNG,而不是GIF,如果这是一个选项。 – 2011-03-06 02:03:45