本文主要是介绍BIOS实战之读取文件--BMP图片显示,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
本节直接贴主要的代码:
#include "DisplayBmpTest.h"EFI_STATUS
EFIAPI
ShellAppMain (IN UINTN Argc,IN CHAR16 **Argv)
{EFI_STATUS Status;EFI_GRAPHICS_OUTPUT_PROTOCOL *GraphicsOutput = NULL;UINT8 *DataBuffer;UINTN DataSize;EFI_GRAPHICS_OUTPUT_BLT_PIXEL *Blt = NULL;UINTN BltSize;UINTN Height;UINTN Width;Status = gBS->LocateProtocol (&gEfiGraphicsOutputProtocolGuid,NULL,(VOID **)&GraphicsOutput);if (EFI_ERROR (Status)) {GraphicsOutput = NULL;Print (L"locate protocol gEfiGraphicsOutputProtocolGuid is error!\n");return Status;}Status = ReadFile (Argv[1], &DataBuffer, &DataSize);if (EFI_ERROR (Status)) {Print (L"Read bmp file to buffer is error!\n");return Status;}Status = TranslateBmpToGopBlt ((VOID *)DataBuffer,DataSize,&Blt,&BltSize,&Height,&Width);if (EFI_ERROR (Status)) {if (Blt != NULL) {FreePool (Blt);}Print (L"TranslateBmpToGopBlt is error!\n");return Status;}Status = GraphicsOutput->Blt (GraphicsOutput,Blt,EfiBltBufferToVideo,0,0,0x0,0x0,Width,Height,Width * sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL));if (EFI_ERROR (Status)) {Print (L"GraphicsOutput Blt is error!\n");return Status;}if (Blt != NULL)FreePool (Blt);Status = gST->ConOut->EnableCursor(gST->ConOut,TRUE);return Status;
}
运行后,我们就能读取自己想要显示的图片,并进行显示:
这里存放了两个位置,一个根目录,一个自己创建的目录,都能正常显示,进行BIOS更新也是同样的道理,读取文件后,进行SPI FLASH的擦写,擦写要注意一点,最小擦写为4k,也就是0x1000。
这篇关于BIOS实战之读取文件--BMP图片显示的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!