mirror of
https://github.com/CloverHackyColor/CloverBootloader.git
synced 2024-11-12 09:54:36 +01:00
created XImage::Compose
Signed-off-by: Sergey Isakov <isakov-sl@bk.ru>
This commit is contained in:
parent
282bc531d7
commit
a0b40c06dc
@ -26,51 +26,75 @@ EFI_GRAPHICS_OUTPUT_BLT_PIXEL* XImage::GetData()
|
||||
return PixelData;
|
||||
}
|
||||
|
||||
UINTN XImage::GetWidth()
|
||||
{
|
||||
return Width;
|
||||
}
|
||||
|
||||
UINTN XImage::GetHeight()
|
||||
{
|
||||
return Height;
|
||||
UINTN XImage::GetWidth()
|
||||
{
|
||||
return Width;
|
||||
}
|
||||
|
||||
size_t XImage::GetSize()
|
||||
UINTN XImage::GetHeight()
|
||||
{
|
||||
return Height;
|
||||
}
|
||||
|
||||
UINTN 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)
|
||||
for (UINTN i = 0; i < Height; ++i)
|
||||
for (UINTN 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) {
|
||||
for (UINTN 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;
|
||||
for (UINTN x = Rect.Xpos; x < Rect.Width && x < Width; ++x)
|
||||
*Ptr++ = Color;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
void XImage::Compose(XImage& LowImage, XImage& TopImage, int PosX, int PosY, bool Lowest) //lowest image is opaque
|
||||
void XImage::Compose(int PosX, int PosY, XImage& TopImage, 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;
|
||||
UINT32 TopAlpha;
|
||||
UINT32 RevAlpha;
|
||||
UINT32 FinalAlpha;
|
||||
UINT32 Temp;
|
||||
EFI_GRAPHICS_OUTPUT_BLT_PIXEL *TopPtr, *CompPtr;
|
||||
|
||||
for (UINTN y = PosY; y < Height && (y - PosY) < TopImage.GetHeight(); y++) {
|
||||
TopPtr = TopImage.GetData();
|
||||
CompPtr = PixelData + y * Width + PosX;
|
||||
for (UINTN x = PosX; x < Width && (x - PosX) < TopImage.GetWidth(); x++) {
|
||||
TopAlpha = TopPtr->Reserved;
|
||||
RevAlpha = 255 - TopAlpha;
|
||||
FinalAlpha = (255*255 - RevAlpha*(255 - CompPtr->Reserved)) / 255;
|
||||
|
||||
//final alpha =(1-(1-x)*(1-y)) =(255*255-(255-topA)*(255-compA))/255
|
||||
Temp = ((UINT8)CompPtr->Blue * RevAlpha) + ((UINT8)TopPtr->Blue * TopAlpha);
|
||||
CompPtr->Blue = (UINT8)(Temp / 255);
|
||||
|
||||
Temp = ((UINT8)CompPtr->Green * RevAlpha) + ((UINT8)TopPtr->Green * TopAlpha);
|
||||
CompPtr->Green = (UINT8)(Temp / 255);
|
||||
|
||||
Temp = ((UINT8)CompPtr->Red * RevAlpha) + ((UINT8)TopPtr->Red * TopAlpha);
|
||||
CompPtr->Red = (UINT8)(Temp / 255);
|
||||
|
||||
if (Lowest) {
|
||||
CompPtr->Reserved = (UINT8)(255);
|
||||
} else {
|
||||
CompPtr->Reserved = (UINT8)FinalAlpha;
|
||||
}
|
||||
|
||||
TopPtr++, CompPtr++;
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
/*
|
||||
This class will replace EG_IMAGE structure and methods
|
||||
*/
|
||||
|
||||
/*
|
||||
This class will replace EG_IMAGE structure and methods
|
||||
*/
|
||||
|
||||
#if !defined(__XSTRINGW_H__)
|
||||
#define __XSTRINGW_H__
|
||||
|
||||
@ -23,35 +23,38 @@ typedef union {
|
||||
*/
|
||||
|
||||
typedef struct {
|
||||
int Xpos;
|
||||
int Ypos;
|
||||
int Width;
|
||||
int Height;
|
||||
UINTN Xpos;
|
||||
UINTN Ypos;
|
||||
UINTN Width;
|
||||
UINTN Height;
|
||||
} EgRect;
|
||||
|
||||
class XImage
|
||||
{
|
||||
protected:
|
||||
|
||||
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();
|
||||
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();
|
||||
|
||||
protected:
|
||||
UINTN GetSize(); //in bytes
|
||||
|
||||
public:
|
||||
|
||||
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__
|
||||
|
||||
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(int PosX, int PosY, XImage& TopImage, bool Lowest);
|
||||
};
|
||||
|
||||
#endif //__XSTRINGW_H__
|
||||
|
@ -81,6 +81,8 @@
|
||||
libeg/VectorGraphics.cpp
|
||||
libeg/libeg.h
|
||||
libeg/libegint.h
|
||||
libeg/XImage.cpp
|
||||
libeg/XImage.h
|
||||
Platform/AcpiPatcher.cpp
|
||||
Platform/ati_reg.h
|
||||
Platform/AmlGenerator.cpp
|
||||
|
Loading…
Reference in New Issue
Block a user