mirror of
https://github.com/CloverHackyColor/CloverBootloader.git
synced 2024-11-23 11:35:19 +01:00
created XImage::Compose
Signed-off-by: Sergey Isakov <isakov-sl@bk.ru>
This commit is contained in:
parent
282bc531d7
commit
a0b40c06dc
@ -36,41 +36,65 @@ UINTN XImage::GetHeight()
|
|||||||
return Height;
|
return Height;
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t XImage::GetSize()
|
UINTN XImage::GetSize()
|
||||||
{
|
{
|
||||||
return Width * Height * sizeof(EFI_GRAPHICS_OUTPUT_BLT_PIXEL);
|
return Width * Height * sizeof(EFI_GRAPHICS_OUTPUT_BLT_PIXEL);
|
||||||
}
|
}
|
||||||
|
|
||||||
void XImage::Fill(EFI_GRAPHICS_OUTPUT_BLT_PIXEL Color)
|
void XImage::Fill(EFI_GRAPHICS_OUTPUT_BLT_PIXEL Color)
|
||||||
{
|
{
|
||||||
for (int i = 0; i < Height; ++i)
|
for (UINTN i = 0; i < Height; ++i)
|
||||||
for (int j = 0; j < Width; ++j)
|
for (UINTN j = 0; j < Width; ++j)
|
||||||
*PixelData++ = Color;
|
*PixelData++ = Color;
|
||||||
}
|
}
|
||||||
|
|
||||||
void XImage::FillArea(EFI_GRAPHICS_OUTPUT_BLT_PIXEL Color, const EgRect& Rect)
|
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;
|
EFI_GRAPHICS_OUTPUT_BLT_PIXEL* Ptr = PixelData + y * Width + Rect.Xpos;
|
||||||
for (int x = Rect.Xpos; x < Rect.Width && x < Width; ++x)
|
for (UINTN x = Rect.Xpos; x < Rect.Width && x < Width; ++x)
|
||||||
*PixelData++ = Color;
|
*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 TopAlpha;
|
||||||
UINT32 RevAlpha;
|
UINT32 RevAlpha;
|
||||||
|
UINT32 FinalAlpha;
|
||||||
|
UINT32 Temp;
|
||||||
EFI_GRAPHICS_OUTPUT_BLT_PIXEL *TopPtr, *CompPtr;
|
EFI_GRAPHICS_OUTPUT_BLT_PIXEL *TopPtr, *CompPtr;
|
||||||
|
|
||||||
for (int y = PosY; y < LowImage.GetHeight() && (y - PosY) < TopImage.GetHeight(); y++) {
|
for (UINTN y = PosY; y < Height && (y - PosY) < TopImage.GetHeight(); y++) {
|
||||||
TopPtr = TopImage.GetData();
|
TopPtr = TopImage.GetData();
|
||||||
CompPtr = LowImage.GetData() + y * LowImage.GetWidth() + PosX;
|
CompPtr = PixelData + y * Width + PosX;
|
||||||
for (int x = PosX; x < LowImage.GetWidth() && (x - PosX) < TopImage.GetWidth(); x++) {
|
for (UINTN x = PosX; x < Width && (x - PosX) < TopImage.GetWidth(); x++) {
|
||||||
TopAlpha = TopPtr->Reserved;
|
TopAlpha = TopPtr->Reserved;
|
||||||
RevAlpha = 255 - TopAlpha;
|
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++;
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -23,10 +23,10 @@ typedef union {
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
int Xpos;
|
UINTN Xpos;
|
||||||
int Ypos;
|
UINTN Ypos;
|
||||||
int Width;
|
UINTN Width;
|
||||||
int Height;
|
UINTN Height;
|
||||||
} EgRect;
|
} EgRect;
|
||||||
|
|
||||||
class XImage
|
class XImage
|
||||||
@ -43,15 +43,18 @@ public:
|
|||||||
// XImage(VOID *Data);
|
// XImage(VOID *Data);
|
||||||
~XImage();
|
~XImage();
|
||||||
|
|
||||||
|
protected:
|
||||||
|
UINTN GetSize(); //in bytes
|
||||||
|
|
||||||
public:
|
public:
|
||||||
size_t GetSize(); //in bytes
|
|
||||||
EFI_GRAPHICS_OUTPUT_BLT_PIXEL* GetData();
|
EFI_GRAPHICS_OUTPUT_BLT_PIXEL* GetData();
|
||||||
UINTN GetWidth();
|
UINTN GetWidth();
|
||||||
UINTN GetHeight();
|
UINTN GetHeight();
|
||||||
|
|
||||||
void Fill(EFI_GRAPHICS_OUTPUT_BLT_PIXEL Color = { 0, 0, 0, 0 });
|
void Fill(EFI_GRAPHICS_OUTPUT_BLT_PIXEL Color = { 0, 0, 0, 0 });
|
||||||
void FillArea(EFI_GRAPHICS_OUTPUT_BLT_PIXEL Color, const EgRect& Rect);
|
void FillArea(EFI_GRAPHICS_OUTPUT_BLT_PIXEL Color, const EgRect& Rect);
|
||||||
void Compose(XImage& LowImage, XImage& TopImage, int PosX, int PosY, bool Lowest);
|
void Compose(int PosX, int PosY, XImage& TopImage, bool Lowest);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif //__XSTRINGW_H__
|
#endif //__XSTRINGW_H__
|
@ -81,6 +81,8 @@
|
|||||||
libeg/VectorGraphics.cpp
|
libeg/VectorGraphics.cpp
|
||||||
libeg/libeg.h
|
libeg/libeg.h
|
||||||
libeg/libegint.h
|
libeg/libegint.h
|
||||||
|
libeg/XImage.cpp
|
||||||
|
libeg/XImage.h
|
||||||
Platform/AcpiPatcher.cpp
|
Platform/AcpiPatcher.cpp
|
||||||
Platform/ati_reg.h
|
Platform/ati_reg.h
|
||||||
Platform/AmlGenerator.cpp
|
Platform/AmlGenerator.cpp
|
||||||
|
Loading…
Reference in New Issue
Block a user