Color difference between vista and Win7
Posted
by
MSGrimpeur
on Stack Overflow
See other posts from Stack Overflow
or by MSGrimpeur
Published on 2011-03-04T08:30:25Z
Indexed on
2011/03/05
23:25 UTC
Read the original article
Hit count: 145
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.
© Stack Overflow or respective owner