I have an array of Texture2D's, which gets populated by the
webcamtexture
.GetPixels32()
Color32[]
Math.Max
Color32[] previousColors = previousFrame.GetPixels32();
Color32[] currentColors = currentFrame.GetPixels32();
Color32[] outColors = new Color32[colors.Length];
int i = 0;
while (i < currentColors .Length)
{
outColors[i].b = Math.Max(previousColors[i].b, currentColors[i].b);
outColors[i].r = Math.Max(previousColors[i].r, currentColors[i].r);
outColors[i].g = Math.Max(previousColors[i].g, currentColors[i].g);
}
bufferedPics[frameIndex].SetPixels32(outColors);
bufferedPics[frameIndex].Apply();
Color32
has four channels: red, green, blue and alpha. By default, alpha is 0
(meaning transparent). You have to set alpha to 255 to let the image be opaque.
Color32[] previousColors = previousFrame.GetPixels32();
Color32[] currentColors = currentFrame.GetPixels32();
Color32[] outColors = new Color32[colors.Length];
int i = 0;
while (i < currentColors .Length)
{
outColors[i].b = Math.Max(previousColors[i].b, currentColors[i].b);
outColors[i].r = Math.Max(previousColors[i].r, currentColors[i].r);
outColors[i].g = Math.Max(previousColors[i].g, currentColors[i].g);
outColors[i].a = 255; // set the alpha channel to opaque
}
bufferedPics[frameIndex].SetPixels32(outColors);
bufferedPics[frameIndex].Apply();