X-Git-Url: https://code.delx.au/refind/blobdiff_plain/4c9f41e161bd197922912efbcf4cc676077d5c00..bda402d8bb74587c5a813c94a0c8626e0e4f18fe:/libeg/load_bmp.c diff --git a/libeg/load_bmp.c b/libeg/load_bmp.c index 9d29af6..a836e6e 100644 --- a/libeg/load_bmp.c +++ b/libeg/load_bmp.c @@ -86,7 +86,7 @@ EG_IMAGE * egDecodeBMP(IN UINT8 *FileData, IN UINTN FileDataLength, IN UINTN Ico UINT8 ImageValue = 0, AlphaValue; EG_PIXEL *PixelPtr; UINTN Index, BitIndex; - + // read and check header if (FileDataLength < sizeof(BMP_IMAGE_HEADER) || FileData == NULL) return NULL; @@ -98,7 +98,7 @@ EG_IMAGE * egDecodeBMP(IN UINT8 *FileData, IN UINTN FileDataLength, IN UINTN Ico if (BmpHeader->BitPerPixel != 1 && BmpHeader->BitPerPixel != 4 && BmpHeader->BitPerPixel != 8 && BmpHeader->BitPerPixel != 24) return NULL; - + // calculate parameters ImageLineOffset = BmpHeader->PixelWidth; if (BmpHeader->BitPerPixel == 24) @@ -112,13 +112,13 @@ EG_IMAGE * egDecodeBMP(IN UINT8 *FileData, IN UINTN FileDataLength, IN UINTN Ico // check bounds if (BmpHeader->ImageOffset + ImageLineOffset * BmpHeader->PixelHeight > FileDataLength) return NULL; - + // allocate image structure and buffer NewImage = egCreateImage(BmpHeader->PixelWidth, BmpHeader->PixelHeight, WantAlpha); if (NewImage == NULL) return NULL; AlphaValue = WantAlpha ? 255 : 0; - + // convert image BmpColorMap = (BMP_COLOR_MAP *)(FileData + sizeof(BMP_IMAGE_HEADER)); ImagePtrBase = FileData + BmpHeader->ImageOffset;