* The function converted plain array into XImage object * Error = 0 - Success * Error = 28 - invalid signature */
| 353 | * Error = 28 - invalid signature |
| 354 | */ |
| 355 | EFI_STATUS XImage::FromPNG(const UINT8 * Data, UINTN Length) |
| 356 | { |
| 357 | // DBG("XImage len=%llu\n", Length); |
| 358 | if (Data == NULL) return EFI_INVALID_PARAMETER; |
| 359 | UINT8 * PixelPtr; // = (UINT8 *)&PixelData[0]; |
| 360 | unsigned Error = eglodepng_decode(&PixelPtr, &Width, &Height, Data, Length); |
| 361 | if (Error != 0 && Error != 28) { |
| 362 | return EFI_NOT_FOUND; |
| 363 | } |
| 364 | if ( !PixelPtr ) return EFI_UNSUPPORTED; // It's possible to get error 28 and PixelPtr == NULL |
| 365 | setSizeInPixels(Width, Height); |
| 366 | //now we have a new pointer and want to move data |
| 367 | INTN NewLength = Width * Height * sizeof(EFI_GRAPHICS_OUTPUT_BLT_PIXEL); |
| 368 | CopyMem(GetPixelPtr(0,0), PixelPtr, NewLength); |
| 369 | FreePool(PixelPtr); //allocated by lodepng |
| 370 | |
| 371 | FlipRB(); |
| 372 | return EFI_SUCCESS; |
| 373 | } |
| 374 | |
| 375 | /* |
| 376 | * The function creates new array Data and inform about it size to be saved |
no test coverage detected