From 2b1649ef3fbd3801706be5d529daa523e16e49ea Mon Sep 17 00:00:00 2001 From: Nikita <102851041+HyperNiki@users.noreply.github.com> Date: Sat, 14 May 2022 10:29:24 +0300 Subject: implement the grayscale test --- UefiMonitorTest/UefiMonitorTestStrings.uni | 11 +++++ UefiMonitorTest/tests/Grayscale.c | 64 +++++++++++++++++++++++++++++- 2 files changed, 74 insertions(+), 1 deletion(-) diff --git a/UefiMonitorTest/UefiMonitorTestStrings.uni b/UefiMonitorTest/UefiMonitorTestStrings.uni index 3d99dab..60c519c 100644 --- a/UefiMonitorTest/UefiMonitorTestStrings.uni +++ b/UefiMonitorTest/UefiMonitorTestStrings.uni @@ -95,3 +95,14 @@ "\n" "Color%c: %s\n" "Steps%c: %d\n" + +// Test "Grayscale" + +#string STR_GRAYSCALE_TITLE #language en-US "GRAYSCALE" + +#string STR_GRAYSCALE_MSG #language en-US "Assess the uniformity of the image using various\n" + "grayscales. The brightness should be equally\n" + "distributed across the entire image, and the image\n" + "shouldn't have any colorful areas.\n" + "\n" + "Gray tone: %d\n" diff --git a/UefiMonitorTest/tests/Grayscale.c b/UefiMonitorTest/tests/Grayscale.c index eb1bf9a..7b41414 100644 --- a/UefiMonitorTest/tests/Grayscale.c +++ b/UefiMonitorTest/tests/Grayscale.c @@ -1,11 +1,33 @@ +#include +#include +#include + #include "Grayscale.h" +STATIC UINT32 CurrentGrayTone = 50; + VOID GrayscaleTestInit ( IN UMT_CONTEXT *Ctx ) { + GRAPHICS_PIXEL_COLOR ColorOutput = { 0x00 }; + GRAPHICS_CONTEXT *Graphics = Ctx->Graphics; + + ColorOutput.Red = (CurrentGrayTone * 255) / 100; + ColorOutput.Green = (CurrentGrayTone * 255) / 100; + ColorOutput.Blue = (CurrentGrayTone * 255) / 100; + PutRect (Graphics, + 0, + 0, + Graphics->Width, + Graphics->Height, + &ColorOutput); + + if (Ctx->ShowTip) { + GrayscaleTestTip (Ctx); + } } VOID @@ -21,14 +43,43 @@ GrayscaleTestTip ( IN UMT_CONTEXT *Ctx ) { + GRAPHICS_CONTEXT *Graphics; + + Graphics = Ctx->Graphics; + if (Ctx->ShowTip == FALSE) { + // Restore + GrayscaleTestInit (Ctx); + return; + } + + DrawRectWithBorder (Graphics, + 15, + Graphics->Height - 15 - 134, + 430, Graphics->Height - 15, + 3, + &gUmtColors[UMT_COLOR_WHITE].Color, + &gUmtColors[UMT_COLOR_NAVY].Color); + + DrawHiiStringF (Graphics, + 25, + Graphics->Height - 15 - 124, + &gUmtColors[UMT_COLOR_NAVY].Color, + STRING_TOKEN (STR_GRAYSCALE_TITLE), gUmtHiiHandle); + + DrawHiiStringF (Graphics, + 25, + Graphics->Height - 15 - 104, + &gUmtColors[UMT_COLOR_BLACK].Color, + STRING_TOKEN (STR_GRAYSCALE_MSG), gUmtHiiHandle, + CurrentGrayTone); } VOID GrayscaleTestChangeParam ( IN UMT_CONTEXT *Ctx, IN INT8 ParamStep - ) +) { } @@ -39,5 +90,16 @@ GrayscaleTestChangeValue ( IN INT8 ValueStep ) { + if (CurrentGrayTone == 5 && ValueStep < 0) { + return; + } else { + CurrentGrayTone += ValueStep * 5; + if (CurrentGrayTone > 95) + { + CurrentGrayTone = 95; + return; + } + } + GrayscaleTestInit (Ctx); } -- cgit v1.2.3-18-g5258