Does anyone know why GetPixel might return this colour?

Hey there, can someone tell me what’s going on in this scenario?

When I use GetPixel on the coloured section of this picture:

25340-1.png

it returns this colour:

RGBA(0.906, 0.110, 0.137, 0.996)

and when I use GetPixel on the transparent section of the picture it returns this colour:

RGBA(0.906, 0.110, 0.137, 0.000)

Can anyone tell me why it wouldn’t just return: RGBA (0,0,0,0);

If it isn’t obvious from the pic and no one’s had this experience I’ll maybe post the code. I haven’t done it yet because the code’s all over the place at the moment.

Thanks very much!

Romano

Here’s code from my test:

var testTexture : Texture2D;
testTexture = sprite.m_manager.material.GetTexture("_MainTex");
var pngZero : Color = testTexture.GetPixel(0,0);

0,0 is a colorless area (deleted segment from photoshop and saved as png).

It returns all 0’s for me.

So, I cannot be creating this the same as you nor am I using the same import settings. I’ll list of some ideas and hopefully they help.

  1. Check if you are using MipMaps, they blend color values together depending on the settings you have set.

  2. Make sure you aren’t compressing your png from Photoshop (or gimp, paintshop etc). This, like mipmaps, will blend information.

  3. Make sure you aren’t letting your photoshop/gimp manage colors. I use photoshop myself, and what you would do on file creation is check the advanced settings and set the color profile to DO NOT MANAGE COLORS. Otherwise with files you’ve already created you’ll want to go to edit, then assign profile and set to not manage colors.

Hope that helps! More code always helps too :wink: I know yours is a mess but maybe a few more snippets will connect some neurons.

Good luck!

if you save PNG in photoshop it does not clean the transparent areas but only make them transparent, if you want to have black there, you must paint the area with black color first

edit: it’s cool feature btw, because you can use the same png with mask and without mask etc.