Make a screenshot
| 533 | // Make a screenshot |
| 534 | // |
| 535 | EFI_STATUS egScreenShot(VOID) |
| 536 | { |
| 537 | EFI_STATUS Status = EFI_NOT_READY; |
| 538 | //take screen |
| 539 | XImage Screen(egScreenWidth, egScreenHeight); |
| 540 | MsgLog("Make screenshot W=%llu H=%llu\n", egScreenWidth, egScreenHeight); |
| 541 | Screen.GetArea(0, 0, egScreenWidth, egScreenHeight); |
| 542 | //convert to PNG |
| 543 | UINT8 *FileData = NULL; |
| 544 | UINTN FileDataLength = 0U; |
| 545 | Status = Screen.ToPNG(&FileData, FileDataLength); |
| 546 | if (EFI_ERROR(Status)) { |
| 547 | if (FileData != NULL) { |
| 548 | FreePool(FileData); |
| 549 | } |
| 550 | return Status; |
| 551 | } |
| 552 | if (!FileData) { |
| 553 | return EFI_NOT_READY; |
| 554 | } |
| 555 | //save file with a first unoccupied name |
| 556 | for (UINTN Index = 0; Index < 60; Index++) { |
| 557 | XStringW Name = SWPrintf("EFI\\CLOVER\\misc\\screenshot%lld.png", Index); |
| 558 | if (!FileExists(SelfRootDir, Name.wc_str())) { |
| 559 | Status = egSaveFile(SelfRootDir, Name.wc_str(), FileData, FileDataLength); |
| 560 | if (EFI_ERROR(Status)) |
| 561 | Status = egSaveFile(NULL, Name.wc_str(), FileData, FileDataLength); |
| 562 | |
| 563 | if (!EFI_ERROR(Status)) { |
| 564 | break; |
| 565 | } |
| 566 | } |
| 567 | } |
| 568 | FreePool(FileData); |
| 569 | return Status; |
| 570 | } |
| 571 | |
| 572 | // |
| 573 | // Sets mode via GOP protocol, and reconnects simple text out drivers |
no test coverage detected