Texture2D.GetPixels to return a BYTE array (0-255)

Is there a way to get the array of pixels in a byte format instead of a clamped float format?

I mean,
Instead of 0.0, get a 0
Instead of 0.5, get a 128
Instead of 1.0, get a 255

This array should be settable too.

Thanks!

You can convert them yourself…multiply the values by 255 when reading, then divide by 255 when setting.

–Eric

Eric5h5,

Thanks for reply! Yes, I’m using that approach right now, but since the conversion involves multiplications and divisions, it’s always better if you have directly a settable byte buffer. That’s the reason I wanted to know if Unity supports this method.

function GetPixels (miplevel : int) : Color[ ]

Nope. :slight_smile: A Color is basically a Vector4. The good thing is, if/when we get something better than 8 bits per component (and personally, I’m kinda sick of the color banding you get with 24-bit), all Unity color stuff will continue to work without having to recode anything.

–Eric