+// Finds the average brightness of the input Image.
+// NOTE: Passing an Image that covers the whole screen can strain the
+// capacity of a UINTN on a 32-bit system with a very large display.
+// Using UINT64 instead is unworkable, since the code won't compile
+// on a 32-bit system. As the intended use for this function is to handle
+// a single text string's background, this shouldn't be a problem, but it
+// may need addressing if it's applied more broadly....
+static UINT8 AverageBrightness(EG_IMAGE *Image) {
+ UINTN i;
+ UINTN Sum = 0;
+
+ if (Image != NULL) {
+ for (i = 0; i < (Image->Width * Image->Height); i++) {
+ Sum += (Image->PixelData[i].r + Image->PixelData[i].g + Image->PixelData[i].b);
+ }
+ } // if
+ return (UINT8) (Sum / (Image->Width * Image->Height * 3));
+} // UINT8 AverageBrightness()
+
+// Display text against the screen's background image. Special case: If Text is NULL
+// or 0-length, clear the line. Does NOT indent the text or reposition it relative
+// to the specified XPos and YPos values.
+static VOID DrawTextWithTransparency(IN CHAR16 *Text, IN UINTN XPos, IN UINTN YPos)