#include "refit_call_wrapper.h"
#include <efiUgaDraw.h>
-/* #include <efiGraphicsOutput.h> */
#include <efiConsoleControl.h>
// Console defines and variables
Image->HasAlpha = FALSE;
egSetPlane(PLPTR(Image, a), 0, Image->Width * Image->Height);
}
-
+
if (GraphicsOutput != NULL) {
refit_call10_wrapper(GraphicsOutput->Blt, GraphicsOutput, (EFI_GRAPHICS_OUTPUT_BLT_PIXEL *)Image->PixelData, EfiBltBufferToVideo,
0, 0, ScreenPosX, ScreenPosY, Image->Width, Image->Height, 0);
{
if (!egHasGraphics)
return;
-
+
egRestrictImageArea(Image, AreaPosX, AreaPosY, &AreaWidth, &AreaHeight);
if (AreaWidth == 0)
return;
-
+
if (Image->HasAlpha) {
Image->HasAlpha = FALSE;
egSetPlane(PLPTR(Image, a), 0, Image->Width * Image->Height);
}
-
+
if (GraphicsOutput != NULL) {
refit_call10_wrapper(GraphicsOutput->Blt, GraphicsOutput, (EFI_GRAPHICS_OUTPUT_BLT_PIXEL *)Image->PixelData, EfiBltBufferToVideo,
AreaPosX, AreaPosY, ScreenPosX, ScreenPosY, AreaWidth, AreaHeight, Image->Width * 4);
}
}
+// Display a message in the center of the screen, surrounded by a box of the
+// specified color. For the moment, uses graphics calls only. (It still works
+// in text mode on GOP/UEFI systems, but not on UGA/EFI 1.x systems.)
+VOID egDisplayMessage(IN CHAR16 *Text, EG_PIXEL *BGColor) {
+ UINTN BoxWidth, BoxHeight;
+ EG_IMAGE *Box;
+
+ if ((Text != NULL) && (BGColor != NULL)) {
+ BoxWidth = (StrLen(Text) + 2) * FONT_CELL_WIDTH;
+ if (BoxWidth > egScreenWidth)
+ BoxWidth = egScreenWidth;
+ BoxHeight = 2 * FONT_CELL_HEIGHT;
+ Box = egCreateFilledImage(BoxWidth, BoxHeight, FALSE, BGColor);
+ egRenderText(Text, Box, FONT_CELL_WIDTH, FONT_CELL_HEIGHT / 2);
+ egDrawImage(Box, (egScreenWidth - BoxWidth) / 2, (egScreenHeight - BoxHeight) / 2);
+ } // if non-NULL inputs
+} // VOID egDisplayMessage()
+
//
// Make a screenshot
//
UINT8 *FileData;
UINTN FileDataLength;
UINTN Index;
-
+
if (!egHasGraphics)
return;
-
+
// allocate a buffer for the whole screen
Image = egCreateImage(egScreenWidth, egScreenHeight, FALSE);
if (Image == NULL) {
Print(L"Error egCreateImage returned NULL\n");
goto bailout_wait;
}
-
+
// get full screen image
if (GraphicsOutput != NULL) {
refit_call10_wrapper(GraphicsOutput->Blt, GraphicsOutput, (EFI_GRAPHICS_OUTPUT_BLT_PIXEL *)Image->PixelData, EfiBltVideoToBltBuffer,
refit_call10_wrapper(UgaDraw->Blt, UgaDraw, (EFI_UGA_PIXEL *)Image->PixelData, EfiUgaVideoToBltBuffer,
0, 0, 0, 0, Image->Width, Image->Height, 0);
}
-
+
// encode as BMP
egEncodeBMP(Image, &FileData, &FileDataLength);
egFreeImage(Image);
Print(L"Error egEncodeBMP returned NULL\n");
goto bailout_wait;
}
-
+
// save to file on the ESP
Status = egSaveFile(NULL, L"screenshot.bmp", FileData, FileDataLength);
FreePool(FileData);
Print(L"Error egSaveFile: %x\n", Status);
goto bailout_wait;
}
-
+
return;
-
+
// DEBUG: switch to text mode
bailout_wait:
egSetGraphicsModeEnabled(FALSE);