color matching

I am using textures to map land surfaces. I did this before and it worked fine. But now I am getting some strange results, see example below.

pixelColor= surfaceMap.GetPixel(1, 1);
if(pixelColor == Color.red) flag = 1;	
print(pixelColor + " - " + flag);

Output: RGBA(1.0, 0.0, 0.0, 1.0) - 0

How is this possible? The texture only has 1 color which is (1,0,0) as the output confirms. But why does the if-statement doesn´t return a match???

Try printing individual components. Color’s string representation only outputs one decimal digit; maybe the actual components something like 0.99.

Thanks Aras, you are right, the values are slightly off. I first tried this with a map I created and thought this would be the problem. Then I did a test with color red (255,0,0) in photoshop because I use this color in the same project in another script with a similar procedure and there it works fine. How is it possible that now the values are slightly off, I double checked photoshop and the RGB color code is 255, 0, 0?

Hmm, while writing this I was thinking that in the other texture I actually saved to bmp because the same psd file is used for 2 different textures. So I saved my red square to bmp and now it does return exactly 1,0,0. Not sure if the slightly off values of the psd import are supposed to happen?

Nevermind, it does work fine with psd when not using compression on import.

Maybe the protoshop file has some sort of color profile embedded?

Sorry Aras, I just edited my previous post. It seems compression is handled differently between psd and bmp.

It should not be any different. But of course if PSD has DXT5 compression and BMP has DXT1 compression (or something like that), then the compression is different.