public static ImageBuffer Add(params ImageBuffer[] buffers) { ImageBuffer output = buffers[0].CloneFormat(); for (int k = 0; k < output.Bytes.Length; k += 4) { for (int i = 0; i < buffers.Count(); i++) { output.Bytes[k + 0] = ByteConversion.Max(output.Bytes[k + 0] + buffers[i].Bytes[k + 0]); output.Bytes[k + 1] = ByteConversion.Max(output.Bytes[k + 1] + buffers[i].Bytes[k + 1]); output.Bytes[k + 2] = ByteConversion.Max(output.Bytes[k + 2] + buffers[i].Bytes[k + 2]); output.Bytes[k + 3] = 255; } } return(output); }
public static void AverageOut(this byte[] buffer, int p1, int p2) { int d = Math.Abs(buffer[p1] - buffer[p2]); if (d < 15 && d > 0) { byte value = ByteConversion.Max((buffer[p1] + buffer[p2]) / 2); buffer[p1 + 0] = value; // blue buffer[p1 + 1] = value; // green buffer[p1 + 2] = value; // red buffer[p1 + 3] = 255; // transparency buffer[p2 + 0] = value; // blue buffer[p2 + 1] = value; // green buffer[p2 + 2] = value; // red buffer[p2 + 3] = 255; // transparency } }