protected void Output()
{
lock (this.lockObject)
{
var bitmap = (Bitmap)this.currentData[DataElements.PixelBitmap];
float brightness = (float)(double)this.currentData[DataElements.Brightness];
float whiteout = (float)Executor.Current.Whiteout.Value;
float blackout = (float)Executor.Current.Blackout.Value;
//TODO: Optimize
this.brightnessMatrix.Matrix00 = 1;
this.brightnessMatrix.Matrix11 = 1;
this.brightnessMatrix.Matrix22 = 1;
this.brightnessMatrix.Matrix40 = whiteout;
this.brightnessMatrix.Matrix41 = whiteout;
this.brightnessMatrix.Matrix42 = whiteout;
using (var imageAttributes = new ImageAttributes())
{
imageAttributes.SetColorMatrix(this.brightnessMatrix, ColorMatrixFlag.Default, ColorAdjustType.Bitmap);
this.output.DrawImage(
bitmap,
this.outputRectangle,
0,
0,
bitmap.Width,
bitmap.Height,
GraphicsUnit.Pixel,
imageAttributes);
}
this.brightnessMatrix.Matrix40 = 0;
this.brightnessMatrix.Matrix41 = 0;
this.brightnessMatrix.Matrix42 = 0;
this.brightnessMatrix.Matrix00 = brightness - blackout;
this.brightnessMatrix.Matrix11 = brightness - blackout;
this.brightnessMatrix.Matrix22 = brightness - blackout;
using (var imageAttributes = new ImageAttributes())
{
imageAttributes.SetColorMatrix(this.brightnessMatrix, ColorMatrixFlag.Default, ColorAdjustType.Bitmap);
this.output.DrawImage(
this.outputBitmap,
this.outputRectangle,
0,
0,
bitmap.Width,
bitmap.Height,
GraphicsUnit.Pixel,
imageAttributes);
}
foreach (var pixelDevice in this.devices)
{
pixelDevice.DrawImage(this.outputBitmap);
}
this.imageChanged.OnNext(this.outputBitmap);
}
}