2 using System.Collections.Generic;
18 private int _BitmapFrameNumber = 0;
26 public int BitmapFrameNumber
28 get {
return _BitmapFrameNumber; }
29 set { _BitmapFrameNumber = value; }
32 private int _BitmapTop = 0;
42 get {
return _BitmapTop; }
43 set { _BitmapTop = value; }
46 private int _BitmapLeft = 0;
56 get {
return _BitmapLeft; }
57 set { _BitmapLeft = value; }
60 private int _BitmapWidth = -1;
68 public int BitmapWidth
70 get {
return _BitmapWidth; }
71 set { _BitmapWidth = value; }
74 private int _BitmapHeight = -1;
82 public int BitmapHeight
84 get {
return _BitmapHeight; }
85 set { _BitmapHeight = value; }
99 get {
return _DataExtractMode; }
100 set { _DataExtractMode = value; }
114 get {
return _BitmapFilePattern; }
115 set { _BitmapFilePattern = value; }
120 private void OutputBitmap(
int FadeValue)
122 if (FadeMode ==
FadeModeEnum.OnOff) FadeValue = (FadeValue < 1 ? 0 : 255);
125 for (
int y = 0; y < AreaHeight; y++)
127 int yd = y + AreaTop;
128 for (
int x = 0; x < AreaWidth; x++)
130 int xd = x + AreaLeft;
131 MatrixLayer[xd, yd] = GetEffectValue(FadeValue, Pixels[x, y]);
145 public abstract MatrixElementType GetEffectValue(
int TriggerValue,
PixelData Pixel);
151 public override void Trigger(Table.TableElementData TableElementData)
155 OutputBitmap(TableElementData.Value);
160 private bool InitOK =
false;
168 public override void Init(Table.Table Table)
175 if (BitmapFilePattern.IsValid)
177 FileInfo FI = BitmapFilePattern.GetFirstMatchingFile(Table.Pinball.GlobalConfig.GetReplaceValuesDictionary());
178 if (FI!=null && FI.Exists)
183 BM = Table.Bitmaps[FI.FullName];
187 Log.
Exception(
"MatrixBitmapEffectBase {0} cant initialize. Could not load file {1}.".Build(Name, FI.FullName), E);
191 if (BM.
Frames.ContainsKey(BitmapFrameNumber))
193 Log.
Debug(
"BitmapEffectBase. Grabbing image clip: W: {0}, H:{1}, BML: {2}, BMT: {3}, BMW: {4}, BMH: {5}".Build(
new object[] { AreaWidth, AreaHeight, BitmapLeft, BitmapTop, BitmapWidth, BitmapHeight }));
194 Pixels = BM.
Frames[BitmapFrameNumber].GetClip(AreaWidth, AreaHeight, BitmapLeft, BitmapTop, BitmapWidth, BitmapHeight, DataExtractMode).Pixels;
199 Log.
Warning(
"MatrixBitmapEffectBase {0} cant initialize. Frame {1} does not exist in source image {2}.".Build(Name, BitmapFrameNumber, FI.FullName));
205 Log.
Warning(
"MatrixBitmapEffectBase {0} cant initialize. No file matches the BitmapFilePattern {1} is invalid".Build(Name, BitmapFilePattern.ToString()));
210 Log.
Warning(
"MatrixBitmapEffectBase {0} cant initialize. The BitmapFilePattern {1} is invalid".Build(Name, BitmapFilePattern.ToString()));
214 InitOK = (Pixels != null && MatrixLayer != null);
override void Finish()
Finishes the effect and releases object references
Struct holding the data for a single pixel in a bitmap.
Base class for effects targeting a matrix of toys (e.g. addressable ledstrip)
static void Warning(string Message)
Writes a warning message to the log.
A simple logger used to record important events and exceptions.
override void Trigger(Table.TableElementData TableElementData)
Triggers the effect with the given data.
override void Init(Table.Table Table)
Initializes the effect. Resolves object references, extracts source image data.
static void Debug(string Message="")
Writes the specified debug message to the log file.
FadeModeEnum
Defines the fading behaviour.
FastBitmapDataExtractModeEnum
The enum defines how the pixels are extracted from the source image.
Dictionary< int, FastBitmap > Frames
The namespace DirectOutput.General contains classes for general use.
A file pattern class used to lookup files matching a specified pattern.
Outputs a defined part of a bitmap on a area of a matrix
static void Exception(string Message, Exception E=null)
Writes a exception message to the log.