X-Git-Url: https://code.delx.au/refind/blobdiff_plain/e22f7ac1eccb5958dd960e157d0f35606f7db26e..63072e911e51d8960638fb086fc8ff0fe62ebc9d:/libeg/load_bmp.c diff --git a/libeg/load_bmp.c b/libeg/load_bmp.c index d0092e5..a836e6e 100644 --- a/libeg/load_bmp.c +++ b/libeg/load_bmp.c @@ -38,6 +38,7 @@ // BMP structures +#ifdef __MAKEWITH_GNUEFI #pragma pack(1) typedef struct { @@ -67,6 +68,7 @@ typedef struct { } BMP_IMAGE_HEADER; #pragma pack() +#endif // // Load BMP image @@ -84,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; @@ -96,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) @@ -110,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;