move data when create ximage from png

Signed-off-by: Sergey Isakov <isakov-sl@bk.ru>
This commit is contained in:
Sergey Isakov 2020-03-30 23:31:34 +03:00
parent fb901fa1a0
commit 35103e3126
2 changed files with 9 additions and 2 deletions

View File

@ -319,12 +319,19 @@ void XImage::FlipRB(bool WantAlpha)
*/
EFI_STATUS XImage::FromPNG(const UINT8 * Data, UINTN Length)
{
// DBG("XImage len=%llu\n", Length);
if (Data == NULL) return EFI_INVALID_PARAMETER;
UINT8 * PixelPtr = (UINT8 *)&PixelData[0];
UINT8 * PixelPtr; // = (UINT8 *)&PixelData[0];
unsigned Error = eglodepng_decode(&PixelPtr, &Width, &Height, Data, Length);
if (Error != 0 && Error != 28) {
return EFI_NOT_FOUND;
}
setSizeInPixels(Width, Height);
//now we have a new pointer and want to move data
INTN NewLength = Width * Height * sizeof(EFI_GRAPHICS_OUTPUT_BLT_PIXEL);
CopyMem(GetPixelPtr(0,0), PixelPtr, NewLength);
FreePool(PixelPtr); //allocated by lodepng
FlipRB(true);
return EFI_SUCCESS;
}

View File

@ -2273,7 +2273,7 @@ RefitMain (IN EFI_HANDLE ImageHandle,
#endif // ENABLE_SECURE_BOOT
MainMenu.TimeoutSeconds = GlobalConfig.Timeout >= 0 ? GlobalConfig.Timeout : 0;
ThemeX.FillByEmbedded();
//DBG("LoadDrivers() start\n");
LoadDrivers();
//DBG("LoadDrivers() end\n");