mirror of
https://github.com/CloverHackyColor/CloverBootloader.git
synced 2024-11-12 09:54:36 +01:00
few polish of png functions
Signed-off-by: Sergey Isakov <isakov-sl@bk.ru>
This commit is contained in:
parent
1946bf5838
commit
f4457dc741
@ -116,24 +116,32 @@ void XImage::FlipRB(bool WantAlpha)
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* The function converted plain array into XImage object
|
||||
*/
|
||||
unsigned XImage::FromPNG(const uint8_t * Data, UINTN Length, bool WantAlpha)
|
||||
{
|
||||
unsigned Error = 0;
|
||||
uint8_t * PixelPtr = (uint8_t *)&PixelData[0];
|
||||
Error = eglodepng_decode(&PixelPtr, &Width, &Height, Data, Length);
|
||||
unsigned Error = eglodepng_decode(&PixelPtr, &Width, &Height, Data, Length);
|
||||
|
||||
FlipRB(WantAlpha);
|
||||
return Error;
|
||||
}
|
||||
|
||||
/*
|
||||
* The function creates new array Data and inform about it size to be saved
|
||||
* as a file.
|
||||
* The caller is responsible to free the array.
|
||||
*/
|
||||
|
||||
unsigned XImage::ToPNG(uint8_t** Data, UINTN& OutSize)
|
||||
{
|
||||
size_t FileDataLength = 0;
|
||||
FlipRB(false);
|
||||
uint8_t * PixelPtr = (uint8_t *)&PixelData[0];
|
||||
unsigned lode_return = eglodepng_encode(Data, &FileDataLength, PixelPtr, Width, Height);
|
||||
unsigned Error = eglodepng_encode(Data, &FileDataLength, PixelPtr, Width, Height);
|
||||
OutSize = FileDataLength;
|
||||
return lode_return;
|
||||
return Error;
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user