WIP
DirectOutput framework for virtual pinball cabinets WIP
Go to:
Overview 
RGBAMatrixColorScaleBitmapAnimationEffect.cs
Go to the documentation of this file.
1 using System;
2 using System.Collections.Generic;
3 using System.Linq;
4 using System.Text;
9 
10 namespace DirectOutput.FX.MatrixFX
11 {
12 
23  {
24  private RGBAColor _ActiveColor = new RGBAColor(0xff, 0xff, 0xff, 0xff);
25 
33  public RGBAColor ActiveColor
34  {
35  get { return _ActiveColor; }
36  set { _ActiveColor = value; }
37  }
38 
39  private RGBAColor _InactiveColor = new RGBAColor(0, 0, 0, 0);
40 
48  public RGBAColor InactiveColor
49  {
50  get { return _InactiveColor; }
51  set { _InactiveColor = value; }
52  }
53 
54 
55 
56 
63  protected override RGBAColor GetEffectValue(int TriggerValue, PixelData Pixel)
64  {
65  RGBAColor D = Pixel.GetRGBAColor();
66 
67  D.Alpha = (int)((float)Pixel.Alpha * TriggerValue / 255);
68 
69  return D;
70 
71  }
72 
73 
74 
80  public override void Init(Table.Table Table)
81  {
82  base.Init(Table);
83 
84  if (Pixels != null)
85  {
86  foreach (PixelData[,] Frame in Pixels)
87  {
88 
89 
90  for (int Y = 0; Y <= Frame.GetUpperBound(1); Y++)
91  {
92 
93  for (int X = 0; X <= Frame.GetUpperBound(0); X++)
94  {
95  PixelData P = Frame[X, Y];
96 
97  double Brightness = ((double)(P.Red + P.Green + P.Blue) / 3).Limit(0, 255);
98 
99  P.Red = (byte)(InactiveColor.Red + (int)((float)(ActiveColor.Red - InactiveColor.Red) * Brightness / 255)).Limit(0, 255);
100  P.Green = (byte)(InactiveColor.Green + (int)((float)(ActiveColor.Green - InactiveColor.Green) * Brightness / 255)).Limit(0, 255);
101  P.Blue = (byte)(InactiveColor.Blue + (int)((float)(ActiveColor.Blue - InactiveColor.Blue) * Brightness / 255)).Limit(0, 255);
102  P.Alpha = (byte)(InactiveColor.Alpha + (int)((float)(ActiveColor.Alpha - InactiveColor.Alpha) * Brightness / 255)).Limit(0, 255);
103  Frame[X, Y] = P;
104 
105  }
106 
107  }
108  }
109 
110  }
111 
112  }
113 
114  }
115 }
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
Animation steps though frames of the source image (this mainly for animated gifs).
This displays a defined part of a bitmap as a animation in the given colors on a area of a RGBAtoy Ma...
override RGBAColor GetEffectValue(int TriggerValue, PixelData Pixel)
Gets the value for a single element in the matrix.
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
override void Init(Table.Table Table)
Initializes the effect. Resolves object references, extracts source image data.
The namespace DirectOutput.General contains classes for general use.