2 using System.Collections.Generic;
5 using DirectOutput.General;
7 using DirectOutput.General.BitmapHandling;
10 namespace DirectOutput.FX.MatrixFX
15 public abstract class MatrixBitmapEffectBase<MatrixElementType> : MatrixEffectBase<MatrixElementType>
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();
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 Pixels = BM.
Frames[BitmapFrameNumber].GetClip(AreaWidth, AreaHeight, BitmapLeft, BitmapTop, BitmapWidth, BitmapHeight, DataExtractMode).Pixels;
198 Log.
Warning(
"MatrixBitmapEffectBase {0} cant initialize. Frame {1} does not exist in source image {2}.".Build(Name, BitmapFrameNumber, FI.FullName));
204 Log.
Warning(
"MatrixBitmapEffectBase {0} cant initialize. No file matches the BitmapFilePattern {1} is invalid".Build(Name, BitmapFilePattern.ToString()));
209 Log.
Warning(
"MatrixBitmapEffectBase {0} cant initialize. The BitmapFilePattern {1} is invalid".Build(Name, BitmapFilePattern.ToString()));
213 InitOK = (Pixels != null && MatrixLayer != null);
220 public override void Finish()