diff --git a/src/MMALSharp/Config/AnnotateImage.cs b/src/MMALSharp/Config/AnnotateImage.cs
index e38248a1..ac8a4e31 100644
--- a/src/MMALSharp/Config/AnnotateImage.cs
+++ b/src/MMALSharp/Config/AnnotateImage.cs
@@ -7,6 +7,24 @@
namespace MMALSharp.Config
{
+ public enum JustifyText
+ {
+ ///
+ /// Centre aligned.
+ ///
+ Centre,
+
+ ///
+ /// Left aligned.
+ ///
+ Left,
+
+ ///
+ /// Right aligned.
+ ///
+ Right
+ }
+
///
/// The type is for use with the image annotation functionality.
/// This will produce a textual overlay on image stills depending on the options enabled.
@@ -26,13 +44,13 @@ public class AnnotateImage
///
/// The of the text.
///
- public Color TextColour { get; set; } = Color.Empty;
+ public Color TextColour { get; set; }
///
- /// The of the background. Note: ShowBlackBackground should be enabled
+ /// The of the background. Note: AllowCustomBackgroundColour should be enabled
/// for this to work.
///
- public Color BgColour { get; set; } = Color.Empty;
+ public Color BgColour { get; set; }
///
/// Show shutter settings.
@@ -67,7 +85,7 @@ public class AnnotateImage
///
/// Allows custom background colour to be used.
///
- public bool ShowBlackBackground { get; set; }
+ public bool AllowCustomBackgroundColour { get; set; }
///
/// Show the current date.
@@ -80,9 +98,9 @@ public class AnnotateImage
public bool ShowTimeText { get; set; }
///
- /// Justify annotation text. 0 = centre, 1 = left, 2 = right.
+ /// Justify annotation text.
///
- public int Justify { get; set; }
+ public JustifyText Justify { get; set; }
///
/// X Offset from the justification edge.
@@ -93,5 +111,63 @@ public class AnnotateImage
/// Y Offset from the justification edge.
///
public int YOffset { get; set; }
+
+ ///
+ /// Creates a new instance of .
+ ///
+ /// The custom text to display.
+ /// The size of displayed text.
+ /// The colour of displayed text.
+ /// The colour of the background.
+ /// Shows shutter settings.
+ /// Shows gain settings.
+ /// Show lens settings.
+ /// Show CAF settings.
+ /// Show motion settings.
+ /// Show frame number.
+ /// Enable custom background colour.
+ /// Show date text.
+ /// Show time text.
+ /// Justify text.
+ /// Text X offset value.
+ /// Text Y offset value.
+ public AnnotateImage(string customText, int textSize, Color textColour, Color bgColour,
+ bool showShutterSettings, bool showGainSettings, bool showLensSettings,
+ bool showCafSettings, bool showMotionSettings, bool showFrameNumber, bool allowCustomBackground,
+ bool showDateText, bool showTimeText, JustifyText justify, int xOffset, int yOffset)
+ {
+ this.CustomText = customText;
+ this.TextSize = textSize;
+ this.TextColour = textColour;
+ this.BgColour = bgColour;
+ this.ShowShutterSettings = showShutterSettings;
+ this.ShowGainSettings = showGainSettings;
+ this.ShowLensSettings = showLensSettings;
+ this.ShowCafSettings = showCafSettings;
+ this.ShowMotionSettings = showMotionSettings;
+ this.ShowFrameNumber = showFrameNumber;
+ this.AllowCustomBackgroundColour = allowCustomBackground;
+ this.ShowDateText = showDateText;
+ this.ShowTimeText = showTimeText;
+ this.Justify = justify;
+ this.XOffset = xOffset;
+ this.YOffset = yOffset;
+ }
+
+ ///
+ /// Creates a new instance of with date and time enabled by default.
+ ///
+ /// The custom text to display.
+ /// The size of displayed text.
+ /// The colour of displayed text.
+ public AnnotateImage(string customText, int textSize, Color textColour)
+ {
+ this.CustomText = customText;
+ this.TextSize = textSize;
+ this.TextColour = textColour;
+
+ this.ShowDateText = true;
+ this.ShowTimeText = true;
+ }
}
}
diff --git a/src/MMALSharp/MMALCameraExtensions.cs b/src/MMALSharp/MMALCameraExtensions.cs
index 6545041b..ca99ba1c 100644
--- a/src/MMALSharp/MMALCameraExtensions.cs
+++ b/src/MMALSharp/MMALCameraExtensions.cs
@@ -283,7 +283,7 @@ internal static void SetAnnotateSettings(this MMALCameraComponent camera)
showFrame = 1;
}
- if (MMALCameraConfig.Annotate.ShowBlackBackground)
+ if (MMALCameraConfig.Annotate.AllowCustomBackgroundColour)
{
enableTextBackground = 1;
}
@@ -293,7 +293,7 @@ internal static void SetAnnotateSettings(this MMALCameraComponent camera)
if (MMALCameraConfig.Annotate.TextColour != Color.Empty)
{
customTextColor = 1;
-
+
var yuv = MMALColor.RGBToYUVBytes(MMALCameraConfig.Annotate.TextColour);
customTextY = yuv.Item1;
customTextU = yuv.Item2;
@@ -318,7 +318,7 @@ internal static void SetAnnotateSettings(this MMALCameraComponent camera)
1, showShutter, showAnalogGain, showLens,
showCaf, showMotion, showFrame, enableTextBackground,
customBackgroundColor, customBackgroundY, customBackgroundU, customBackgroundV, 0, customTextColor,
- customTextY, customTextU, customTextV, textSize, text, justify, xOffset, yOffset);
+ customTextY, customTextU, customTextV, textSize, text, (int)justify, xOffset, yOffset);
var ptrV4 = Marshal.AllocHGlobal(Marshal.SizeOf());
Marshal.StructureToPtr(strV4, ptrV4, false);