mirror of
https://github.com/CloverHackyColor/CloverBootloader.git
synced 2024-11-29 12:35:53 +01:00
use signed height
Signed-off-by: Slice <sergey.slice@gmail.com>
This commit is contained in:
parent
52d0dcd2c6
commit
eb76853ba7
@ -172,7 +172,7 @@ DecodeImageData (//IN APPLE_IMAGE_CODEC_PROTOCOL* This,
|
|||||||
}
|
}
|
||||||
|
|
||||||
DBG("EFI_SUCCESS, RawImageDataSize=%d\n", *RawImageDataSize);
|
DBG("EFI_SUCCESS, RawImageDataSize=%d\n", *RawImageDataSize);
|
||||||
DBG("ImageBuffer=%p, ImageSize=%d\n", ImageBuffer, ImageSize);
|
DBG("ImageBuffer, ImageSize=%d\n", ImageSize);
|
||||||
DBG("Decoded: W=%d, H=%d\n", Image->Width, Image->Height);
|
DBG("Decoded: W=%d, H=%d\n", Image->Width, Image->Height);
|
||||||
for (Index=0; Index<10; Index++) {
|
for (Index=0; Index<10; Index++) {
|
||||||
DBG("P%d: r,g,b,a= %x, %x, %x, %x\n", Index, (*RawImageData)[Index].Red, (*RawImageData)[Index].Green, (*RawImageData)[Index].Blue, (*RawImageData)[Index].Reserved);
|
DBG("P%d: r,g,b,a= %x, %x, %x, %x\n", Index, (*RawImageData)[Index].Red, (*RawImageData)[Index].Green, (*RawImageData)[Index].Blue, (*RawImageData)[Index].Reserved);
|
||||||
|
@ -40,6 +40,7 @@
|
|||||||
|
|
||||||
#define DBG(...)
|
#define DBG(...)
|
||||||
|
|
||||||
|
|
||||||
// BMP structures
|
// BMP structures
|
||||||
|
|
||||||
//#pragma pack(1)
|
//#pragma pack(1)
|
||||||
@ -81,7 +82,7 @@ EG_IMAGE * egDecodeBMP(IN UINT8 *FileData, IN UINTN FileDataLength, IN BOOLEAN W
|
|||||||
EG_IMAGE *NewImage;
|
EG_IMAGE *NewImage;
|
||||||
BMP_IMAGE_HEADER *BmpHeader;
|
BMP_IMAGE_HEADER *BmpHeader;
|
||||||
BMP_COLOR_MAP *BmpColorMap;
|
BMP_COLOR_MAP *BmpColorMap;
|
||||||
UINT32 RealPixelHeight, RealPixelWidth;
|
INT32 RealPixelHeight, RealPixelWidth;
|
||||||
UINT8 *ImagePtr;
|
UINT8 *ImagePtr;
|
||||||
UINT8 *ImagePtrBase;
|
UINT8 *ImagePtrBase;
|
||||||
UINTN ImageLineOffset;
|
UINTN ImageLineOffset;
|
||||||
@ -132,7 +133,7 @@ EG_IMAGE * egDecodeBMP(IN UINT8 *FileData, IN UINTN FileDataLength, IN BOOLEAN W
|
|||||||
// convert image
|
// convert image
|
||||||
BmpColorMap = (BMP_COLOR_MAP *)(FileData + sizeof(BMP_IMAGE_HEADER));
|
BmpColorMap = (BMP_COLOR_MAP *)(FileData + sizeof(BMP_IMAGE_HEADER));
|
||||||
ImagePtrBase = FileData + BmpHeader->ImageOffset;
|
ImagePtrBase = FileData + BmpHeader->ImageOffset;
|
||||||
for (UINT32 y = 0; y < RealPixelHeight; y++) {
|
for (INT32 y = 0; y < RealPixelHeight; y++) {
|
||||||
ImagePtr = ImagePtrBase;
|
ImagePtr = ImagePtrBase;
|
||||||
ImagePtrBase += ImageLineOffset;
|
ImagePtrBase += ImageLineOffset;
|
||||||
// vertically mirror
|
// vertically mirror
|
||||||
@ -145,7 +146,7 @@ EG_IMAGE * egDecodeBMP(IN UINT8 *FileData, IN UINTN FileDataLength, IN BOOLEAN W
|
|||||||
switch (BmpHeader->BitPerPixel) {
|
switch (BmpHeader->BitPerPixel) {
|
||||||
|
|
||||||
case 1:
|
case 1:
|
||||||
for (UINT32 x = 0; x < RealPixelWidth; x++) {
|
for (INT32 x = 0; x < RealPixelWidth; x++) {
|
||||||
BitIndex = x & 0x07;
|
BitIndex = x & 0x07;
|
||||||
if (BitIndex == 0)
|
if (BitIndex == 0)
|
||||||
ImageValue = *ImagePtr++;
|
ImageValue = *ImagePtr++;
|
||||||
@ -161,8 +162,7 @@ EG_IMAGE * egDecodeBMP(IN UINT8 *FileData, IN UINTN FileDataLength, IN BOOLEAN W
|
|||||||
|
|
||||||
case 4:
|
case 4:
|
||||||
{
|
{
|
||||||
UINT32 x;
|
for (INT32 x = 0; x <= RealPixelWidth - 2; x += 2) {
|
||||||
for (x = 0; x <= RealPixelWidth - 2; x += 2) {
|
|
||||||
ImageValue = *ImagePtr++;
|
ImageValue = *ImagePtr++;
|
||||||
|
|
||||||
Index = ImageValue >> 4;
|
Index = ImageValue >> 4;
|
||||||
@ -179,7 +179,7 @@ EG_IMAGE * egDecodeBMP(IN UINT8 *FileData, IN UINTN FileDataLength, IN BOOLEAN W
|
|||||||
PixelPtr->Reserved = AlphaValue;
|
PixelPtr->Reserved = AlphaValue;
|
||||||
PixelPtr++;
|
PixelPtr++;
|
||||||
}
|
}
|
||||||
if (x < RealPixelWidth) {
|
if ((RealPixelWidth & 1) == 1) {
|
||||||
ImageValue = *ImagePtr++;
|
ImageValue = *ImagePtr++;
|
||||||
|
|
||||||
Index = ImageValue >> 4;
|
Index = ImageValue >> 4;
|
||||||
@ -192,7 +192,7 @@ EG_IMAGE * egDecodeBMP(IN UINT8 *FileData, IN UINTN FileDataLength, IN BOOLEAN W
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case 8:
|
case 8:
|
||||||
for (UINT32 x = 0; x < RealPixelWidth; x++) {
|
for (INT32 x = 0; x < RealPixelWidth; x++) {
|
||||||
Index = *ImagePtr++;
|
Index = *ImagePtr++;
|
||||||
PixelPtr->Blue = BmpColorMap[Index].Blue;
|
PixelPtr->Blue = BmpColorMap[Index].Blue;
|
||||||
PixelPtr->Green = BmpColorMap[Index].Green;
|
PixelPtr->Green = BmpColorMap[Index].Green;
|
||||||
@ -203,7 +203,7 @@ EG_IMAGE * egDecodeBMP(IN UINT8 *FileData, IN UINTN FileDataLength, IN BOOLEAN W
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case 24:
|
case 24:
|
||||||
for (UINT32 x = 0; x < RealPixelWidth; x++) {
|
for (INT32 x = 0; x < RealPixelWidth; x++) {
|
||||||
PixelPtr->Blue = *ImagePtr++;
|
PixelPtr->Blue = *ImagePtr++;
|
||||||
PixelPtr->Green = *ImagePtr++;
|
PixelPtr->Green = *ImagePtr++;
|
||||||
PixelPtr->Red = *ImagePtr++;
|
PixelPtr->Red = *ImagePtr++;
|
||||||
@ -212,13 +212,13 @@ EG_IMAGE * egDecodeBMP(IN UINT8 *FileData, IN UINTN FileDataLength, IN BOOLEAN W
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 32:
|
case 32:
|
||||||
for (UINT32 x = 0; x < RealPixelWidth; x++) {
|
for (INT32 x = 0; x < RealPixelWidth; x++) {
|
||||||
PixelPtr->Blue = *ImagePtr++;
|
PixelPtr->Blue = *ImagePtr++;
|
||||||
PixelPtr->Green = *ImagePtr++;
|
PixelPtr->Green = *ImagePtr++;
|
||||||
PixelPtr->Red = *ImagePtr++;
|
PixelPtr->Red = *ImagePtr++;
|
||||||
PixelPtr->Reserved = *ImagePtr++;
|
PixelPtr->Reserved = *ImagePtr++;
|
||||||
if (!WantAlpha)
|
// if (!WantAlpha)
|
||||||
PixelPtr->Reserved = 255 - PixelPtr->Reserved;
|
// PixelPtr->Reserved = 255 - PixelPtr->Reserved;
|
||||||
PixelPtr++;
|
PixelPtr++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -318,7 +318,7 @@ EFI_PART_TYPE_LEGACY_MBR_GUID {0x024DEE41, 0x33E7, 0x11D3, {0x9D, 0x69, 0x00, 0x
|
|||||||
// 00 00 08 00 00 00 00 00 | ........
|
// 00 00 08 00 00 00 00 00 | ........
|
||||||
// gAppleFpfConfigurationHobGuid = { 0xE3CC8EC6, 0x81C1, 0x4271, { 0xAC, 0xBC, 0xDB, 0x65, 0x08, 0x6E, 0x8D, 0xC8 }}
|
// gAppleFpfConfigurationHobGuid = { 0xE3CC8EC6, 0x81C1, 0x4271, { 0xAC, 0xBC, 0xDB, 0x65, 0x08, 0x6E, 0x8D, 0xC8 }}
|
||||||
// 59D76AE4-37E3-55A7-B460-EF13D46E6020 AppleEncryptedPartitionProtocolGuid
|
// 59D76AE4-37E3-55A7-B460-EF13D46E6020 AppleEncryptedPartitionProtocolGuid
|
||||||
|
// ->LocateProtocol(3496A19A-2E99-41BA-833E-0FDE2EBF2A55, 0, 0/0) = Not Found
|
||||||
/*
|
/*
|
||||||
#define APPLE_SECURE_BOOT_VARIABLE_GUID \
|
#define APPLE_SECURE_BOOT_VARIABLE_GUID \
|
||||||
{ 0x94B73556, 0x2197, 0x4702, \
|
{ 0x94B73556, 0x2197, 0x4702, \
|
||||||
|
@ -17,11 +17,12 @@
|
|||||||
#include <Protocol/AppleImageCodecProtocol.h>
|
#include <Protocol/AppleImageCodecProtocol.h>
|
||||||
|
|
||||||
#include "XImage.h"
|
#include "XImage.h"
|
||||||
|
#include "../Platform/Utils.h"
|
||||||
|
|
||||||
//#include "picopng.h"
|
//#include "picopng.h"
|
||||||
#include "lodepng.h"
|
#include "lodepng.h"
|
||||||
|
|
||||||
//#define DBG(...) AsciiPrint(__VA_ARGS__);
|
//#define DBG(...) DebugLog(1, __VA_ARGS__)
|
||||||
#define DBG(...)
|
#define DBG(...)
|
||||||
|
|
||||||
struct EFI_RES_ENTRY {
|
struct EFI_RES_ENTRY {
|
||||||
@ -105,7 +106,7 @@ RecognizeImageData (//IN APPLE_IMAGE_CODEC_PROTOCOL* This,
|
|||||||
}
|
}
|
||||||
|
|
||||||
DBG("EFI_SUCCESS\n");
|
DBG("EFI_SUCCESS\n");
|
||||||
DBG(" ImageSize=%d\n", ImageSize);
|
DBG(" ImageSize=%lld\n", ImageSize);
|
||||||
// DBG("Decoded: W=%d, H=%d\n", Image.GetWidth(), Image.GetHeight());
|
// DBG("Decoded: W=%d, H=%d\n", Image.GetWidth(), Image.GetHeight());
|
||||||
return EFI_SUCCESS;
|
return EFI_SUCCESS;
|
||||||
}
|
}
|
||||||
@ -132,7 +133,7 @@ GetImageDims (//IN APPLE_IMAGE_CODEC_PROTOCOL* This,
|
|||||||
*ImageHeight = (UINT32)Image.GetHeight();
|
*ImageHeight = (UINT32)Image.GetHeight();
|
||||||
|
|
||||||
DBG("EFI_SUCCESS, Width=%d, Height=%d\n", *ImageWidth, *ImageHeight);
|
DBG("EFI_SUCCESS, Width=%d, Height=%d\n", *ImageWidth, *ImageHeight);
|
||||||
DBG("ImageSize=%d\n", ImageSize);
|
DBG("ImageSize=%lld\n", ImageSize);
|
||||||
return EFI_SUCCESS;
|
return EFI_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -167,11 +168,11 @@ DecodeImageData (//IN APPLE_IMAGE_CODEC_PROTOCOL* This,
|
|||||||
}
|
}
|
||||||
|
|
||||||
DBG("EFI_SUCCESS, RawImageDataSize=%d\n", *RawImageDataSize);
|
DBG("EFI_SUCCESS, RawImageDataSize=%d\n", *RawImageDataSize);
|
||||||
// DBG("ImageBuffer=%p, ImageSize=%d\n", ImageBuffer, ImageSize);
|
DBG("ImageBuffer=%p, ImageSize=%lld\n", ImageBuffer, ImageSize);
|
||||||
// DBG("Decoded: W=%d, H=%d\n", Image->Width, Image->Height);
|
DBG("Decoded: W=%lld, H=%lld\n", Image.GetWidth(), Image.GetHeight());
|
||||||
// for (int Index=0; Index<10; Index++) {
|
for (int Index=0; Index<10; Index++) {
|
||||||
// DBG("P%d: r,g,b,a= %x, %x, %x, %x\n", Index, (*RawImageData)[Index].Red, (*RawImageData)[Index].Green, (*RawImageData)[Index].Blue, (*RawImageData)[Index].Reserved);
|
DBG("P%d: r,g,b,a= %x, %x, %x, %x\n", Index, (*RawImageData)[Index].Red, (*RawImageData)[Index].Green, (*RawImageData)[Index].Blue, (*RawImageData)[Index].Reserved);
|
||||||
// }
|
}
|
||||||
// egFreeImage(Image);
|
// egFreeImage(Image);
|
||||||
return EFI_SUCCESS;
|
return EFI_SUCCESS;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user