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;
}
老实说,我不确定这是否有点笨拙,是否有一些更聪明的方法,所以任何想法都会有帮助。然而,主要问题是,这在 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
大家好,我们已经将其确定为 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.