mirror of
https://github.com/CloverHackyColor/CloverBootloader.git
synced 2024-11-27 12:15:19 +01:00
preliminary introduce image class
Signed-off-by: Sergey Isakov <isakov-sl@bk.ru>
This commit is contained in:
parent
0155a4bf8a
commit
a4952d32de
@ -88,11 +88,11 @@ public:
|
||||
|
||||
|
||||
void vSPrintf(const char* format, VA_LIST va);
|
||||
#ifndef _MSC_VER
|
||||
void SPrintf(const char* format, ...) __attribute__((__format__(__printf__, 2, 3)));
|
||||
#else
|
||||
void SPrintf(const char* format, ...);
|
||||
#endif // !__MSC_VER
|
||||
#ifndef _MSC_VER
|
||||
void SPrintf(const char* format, ...) __attribute__((__format__(__printf__, 2, 3)));
|
||||
#else
|
||||
void SPrintf(const char* format, ...);
|
||||
#endif // !__MSC_VER
|
||||
|
||||
|
||||
const XStringW &operator =(const XStringW &aString);
|
||||
@ -176,11 +176,11 @@ public:
|
||||
};
|
||||
|
||||
//extern const XStringW NullXStringW;
|
||||
#ifndef _MSC_VER
|
||||
XStringW SPrintf(const char* format, ...) __attribute__((__format__(__printf__, 1, 2)));
|
||||
#else
|
||||
XStringW SPrintf(const char* format, ...);
|
||||
#endif // !__MSC_VER
|
||||
#ifndef _MSC_VER
|
||||
XStringW SPrintf(const char* format, ...) __attribute__((__format__(__printf__, 1, 2)));
|
||||
#else
|
||||
XStringW SPrintf(const char* format, ...);
|
||||
#endif // !__MSC_VER
|
||||
|
||||
|
||||
XStringW SubString(const wchar_t *S, UINTN pos, UINTN count);
|
||||
|
@ -20,7 +20,9 @@ void* operator new (unsigned long count)
|
||||
return ptr;
|
||||
}
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#pragma warning(disable : 4577)
|
||||
#endif
|
||||
void operator delete ( void* ptr ) noexcept
|
||||
{
|
||||
return FreePool(ptr);
|
||||
|
76
rEFIt_UEFI/libeg/XImage.cpp
Normal file
76
rEFIt_UEFI/libeg/XImage.cpp
Normal file
@ -0,0 +1,76 @@
|
||||
#include "XImage.h"
|
||||
|
||||
XImage::XImage()
|
||||
{
|
||||
Width = 0;
|
||||
Height = 0;
|
||||
PixelData = nullptr;
|
||||
HasAlpha = true;
|
||||
}
|
||||
|
||||
XImage::XImage(UINTN W, UINTN H, bool A)
|
||||
{
|
||||
Width = W;
|
||||
Height = H;
|
||||
HasAlpha = A;
|
||||
PixelData = (EFI_GRAPHICS_OUTPUT_BLT_PIXEL*)Xalloc(GetSize());
|
||||
}
|
||||
|
||||
XImage::~XImage()
|
||||
{
|
||||
Xfree(PixelData);
|
||||
}
|
||||
|
||||
EFI_GRAPHICS_OUTPUT_BLT_PIXEL* XImage::GetData()
|
||||
{
|
||||
return PixelData;
|
||||
}
|
||||
|
||||
UINTN XImage::GetWidth()
|
||||
{
|
||||
return Width;
|
||||
}
|
||||
|
||||
UINTN XImage::GetHeight()
|
||||
{
|
||||
return Height;
|
||||
}
|
||||
|
||||
size_t XImage::GetSize()
|
||||
{
|
||||
return Width * Height * sizeof(EFI_GRAPHICS_OUTPUT_BLT_PIXEL);
|
||||
}
|
||||
|
||||
void XImage::Fill(EFI_GRAPHICS_OUTPUT_BLT_PIXEL Color)
|
||||
{
|
||||
for (int i = 0; i < Height; ++i)
|
||||
for (int j = 0; j < Width; ++j)
|
||||
*PixelData++ = Color;
|
||||
}
|
||||
|
||||
void XImage::FillArea(EFI_GRAPHICS_OUTPUT_BLT_PIXEL Color, const EgRect& Rect)
|
||||
{
|
||||
for (int y = Rect.Ypos; y < Rect.Height && y < Height; ++y) {
|
||||
EFI_GRAPHICS_OUTPUT_BLT_PIXEL* Ptr = PixelData + y * Width + Rect.Xpos;
|
||||
for (int x = Rect.Xpos; x < Rect.Width && x < Width; ++x)
|
||||
*PixelData++ = Color;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
void XImage::Compose(XImage& LowImage, XImage& TopImage, int PosX, int PosY, bool Lowest) //lowest image is opaque
|
||||
{
|
||||
UINT32 TopAlpha;
|
||||
UINT32 RevAlpha;
|
||||
EFI_GRAPHICS_OUTPUT_BLT_PIXEL *TopPtr, *CompPtr;
|
||||
|
||||
for (int y = PosY; y < LowImage.GetHeight() && (y - PosY) < TopImage.GetHeight(); y++) {
|
||||
TopPtr = TopImage.GetData();
|
||||
CompPtr = LowImage.GetData() + y * LowImage.GetWidth() + PosX;
|
||||
for (int x = PosX; x < LowImage.GetWidth() && (x - PosX) < TopImage.GetWidth(); x++) {
|
||||
TopAlpha = TopPtr->Reserved;
|
||||
RevAlpha = 255 - TopAlpha;
|
||||
}
|
||||
}
|
||||
}
|
57
rEFIt_UEFI/libeg/XImage.h
Normal file
57
rEFIt_UEFI/libeg/XImage.h
Normal file
@ -0,0 +1,57 @@
|
||||
/*
|
||||
This class will replace EG_IMAGE structure and methods
|
||||
*/
|
||||
|
||||
#if !defined(__XSTRINGW_H__)
|
||||
#define __XSTRINGW_H__
|
||||
|
||||
#include "XToolsCommon.h"
|
||||
#include <Platform.h>
|
||||
|
||||
/*
|
||||
typedef struct {
|
||||
UINT8 Blue;
|
||||
UINT8 Green;
|
||||
UINT8 Red;
|
||||
UINT8 Reserved; //this is Alpha. 0 means full transparent, 0xFF means opaque
|
||||
} EFI_GRAPHICS_OUTPUT_BLT_PIXEL;
|
||||
|
||||
typedef union {
|
||||
EFI_GRAPHICS_OUTPUT_BLT_PIXEL Pixel;
|
||||
UINT32 Raw;
|
||||
} EFI_GRAPHICS_OUTPUT_BLT_PIXEL_UNION;
|
||||
*/
|
||||
|
||||
typedef struct {
|
||||
int Xpos;
|
||||
int Ypos;
|
||||
int Width;
|
||||
int Height;
|
||||
} EgRect;
|
||||
|
||||
class XImage
|
||||
{
|
||||
protected:
|
||||
UINTN Width;
|
||||
UINTN Height;
|
||||
EFI_GRAPHICS_OUTPUT_BLT_PIXEL *PixelData;
|
||||
bool HasAlpha;
|
||||
public:
|
||||
XImage();
|
||||
XImage(UINTN W, UINTN H, bool HasAlpha);
|
||||
// XImage(UINTN W, UINTN H, bool HasAlpha, UINT32 Color); //egCreateFilledImage
|
||||
// XImage(VOID *Data);
|
||||
~XImage();
|
||||
|
||||
public:
|
||||
size_t GetSize(); //in bytes
|
||||
EFI_GRAPHICS_OUTPUT_BLT_PIXEL* GetData();
|
||||
UINTN GetWidth();
|
||||
UINTN GetHeight();
|
||||
|
||||
void Fill(EFI_GRAPHICS_OUTPUT_BLT_PIXEL Color = { 0, 0, 0, 0 });
|
||||
void FillArea(EFI_GRAPHICS_OUTPUT_BLT_PIXEL Color, const EgRect& Rect);
|
||||
void Compose(XImage& LowImage, XImage& TopImage, int PosX, int PosY, bool Lowest);
|
||||
};
|
||||
|
||||
#endif //__XSTRINGW_H__
|
Loading…
Reference in New Issue
Block a user