private void DrawMotionHistory(Bitmap image)
{
Color greenColor = Color.FromArgb(128, 0, 255, 0);
Color yellowColor = Color.FromArgb(128, 255, 255, 0);
Color redColor = Color.FromArgb(128, 255, 0, 0);
BitmapData bitmapData = image.LockBits(new Rectangle(0, 0, image.Width, image.Height),
ImageLockMode.ReadWrite, image.PixelFormat);
int t1 = (int)(motionAlarmLevel * 500);
int t2 = (int)(0.075 * 500);
for (int i = 1, n = motionHistory.Count; i <= n; i++)
{
int motionBarLength = (int)(motionHistory[n - i] * 500);
if (motionBarLength == 0)
continue;
if (motionBarLength > 50)
motionBarLength = 50;
Drawing.Line(bitmapData,
new IntPoint(image.Width - i, image.Height - 1),
new IntPoint(image.Width - i, image.Height - 1 - motionBarLength),
greenColor);
if (motionBarLength > t1)
{
Drawing.Line(bitmapData,
new IntPoint(image.Width - i, image.Height - 1 - t1),
new IntPoint(image.Width - i, image.Height - 1 - motionBarLength),
yellowColor);
}
if (motionBarLength > t2)
{
Drawing.Line(bitmapData,
new IntPoint(image.Width - i, image.Height - 1 - t2),
new IntPoint(image.Width - i, image.Height - 1 - motionBarLength),
redColor);
}
}
image.UnlockBits(bitmapData);
}