I’m currently using GetPixel() for scanning small image files for later use of the color array. I pick the contents of the array and make an average of the colors to kind of simulate what the pixelate or mosaic effect would do, but I would need to apply this on much larger pictures and that would take forever.
Is there a script I could adapt to correctly achieve the pixelation?
Thanks a lot.
You can use Texture2D.GetPixels32 to get all the pixels and then do your calculations directly on the pixel array. There will be a substantial performance improvement over repeated GetPixel() calls.
here’s what i finally used, after i updated Chrizonic’s code. thanks man
private Color GetAverageColor(List data) { float r = 0; float g = 0; float b = 0; int divider = data.Count;
for (int i = 0; i < divider; i++)
{
r += data*.r;*
g += data*.g;*
b += data*.b;*
}
return new Color(r / divider, g / divider, b / divider, 1);
}