WIP
DirectOutput framework for virtual pinball cabinets WIP
Go to:
Overview 
RGBAMatrixColorScaleBitmapEffect.cs
Go to the documentation of this file.
4 
5 namespace DirectOutput.FX.MatrixFX
6 {
17  {
18 
19  private RGBAColor _ActiveColor = new RGBAColor(0xff, 0xff, 0xff, 0xff);
20 
28  public RGBAColor ActiveColor
29  {
30  get { return _ActiveColor; }
31  set { _ActiveColor = value; }
32  }
33 
34  private RGBAColor _InactiveColor = new RGBAColor(0, 0, 0, 0);
35 
43  public RGBAColor InactiveColor
44  {
45  get { return _InactiveColor; }
46  set { _InactiveColor = value; }
47  }
48 
49 
50 
57  public override RGBAColor GetEffectValue(int TriggerValue, PixelData Pixel)
58  {
59 
60 
61  RGBAColor D = Pixel.GetRGBAColor();
62 
63  D.Alpha = (int)((float)Pixel.Alpha * TriggerValue / 255);
64 
65  return D;
66 
67  }
68 
69  public override void Init(Table.Table Table)
70  {
71  base.Init(Table);
72 
73  if (Pixels != null)
74  {
75  for (int Y = 0; Y <= Pixels.GetUpperBound(1); Y++)
76  {
77 
78  for (int X = 0; X <= Pixels.GetUpperBound(0); X++)
79  {
80  PixelData P = Pixels[X, Y];
81 
82  double Brightness = ((double)(P.Red + P.Green + P.Blue) / 3).Limit(0, 255);
83 
84  P.Red = (byte)(InactiveColor.Red + (int)((float)(ActiveColor.Red - InactiveColor.Red) * Brightness / 255)).Limit(0, 255);
85  P.Green = (byte)(InactiveColor.Green + (int)((float)(ActiveColor.Green - InactiveColor.Green) * Brightness / 255)).Limit(0, 255);
86  P.Blue = (byte)(InactiveColor.Blue + (int)((float)(ActiveColor.Blue - InactiveColor.Blue) * Brightness / 255)).Limit(0, 255);
87  P.Alpha = (byte)(InactiveColor.Alpha + (int)((float)(ActiveColor.Alpha - InactiveColor.Alpha) * Brightness / 255)).Limit(0, 255);
88  Pixels[X, Y] = P;
89 
90  }
91 
92  }
93 
94 
95  }
96 
97  }
98 
99 
100 
101  }
102 }
This class stores information on colors used for toys and effects (e.g. RGBLed).
Definition: RGBAColor.cs:14
The namespace DirectOutput.Cab.Toys contains all toy related classes.
Struct holding the data for a single pixel in a bitmap.
Definition: PixelData.cs:12
The namespace DirectOutput.Cab contains all cabinet related classes like the Cabinet class itself...
Definition: Cab.cs:16
int Alpha
Alpha value for the color.
Definition: RGBAColor.cs:64
Namespace for objects dealing with layers
The RGBAMatrixBitmapEffect displays a defined part of a bitmap in the given colors on a area of a RGB...
override RGBAColor GetEffectValue(int TriggerValue, PixelData Pixel)
Gets the value for a single element in the matrix.
The namespace DirectOutput.General contains classes for general use.
Outputs a defined part of a bitmap on a area of a matrix