2020-02-25 21:19:39 +01:00
|
|
|
/*
|
|
|
|
This class will replace EG_IMAGE structure and methods
|
|
|
|
*/
|
|
|
|
|
2020-02-28 21:28:33 +01:00
|
|
|
#if !defined(__XIMAGE_H__)
|
|
|
|
#define __XIMAGE_H__
|
2020-02-28 15:08:40 +01:00
|
|
|
|
2020-02-25 14:55:39 +01:00
|
|
|
#include <Platform.h>
|
2020-02-28 21:28:33 +01:00
|
|
|
//
|
|
|
|
//#include "../cpp_foundation/XToolsCommon.h"
|
|
|
|
//#include "../cpp_foundation/XArray.h"
|
|
|
|
//#include "lodepng.h"
|
|
|
|
//
|
|
|
|
//#include "nanosvg.h"
|
|
|
|
//#include "FloatLib.h"
|
|
|
|
|
2020-02-25 14:55:39 +01:00
|
|
|
|
2020-02-26 07:05:14 +01:00
|
|
|
#if 0 //ndef EFI_GRAPHICS_OUTPUT_BLT_PIXEL
|
2020-02-25 14:55:39 +01:00
|
|
|
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;
|
2020-02-26 14:59:10 +01:00
|
|
|
|
|
|
|
|
2020-02-25 14:55:39 +01:00
|
|
|
typedef union {
|
|
|
|
EFI_GRAPHICS_OUTPUT_BLT_PIXEL Pixel;
|
|
|
|
UINT32 Raw;
|
|
|
|
} EFI_GRAPHICS_OUTPUT_BLT_PIXEL_UNION;
|
2020-02-26 14:59:10 +01:00
|
|
|
#endif
|
2020-02-25 14:55:39 +01:00
|
|
|
|
|
|
|
typedef struct {
|
2020-02-25 21:19:39 +01:00
|
|
|
UINTN Xpos;
|
|
|
|
UINTN Ypos;
|
|
|
|
UINTN Width;
|
|
|
|
UINTN Height;
|
2020-02-25 14:55:39 +01:00
|
|
|
} EgRect;
|
2020-02-25 21:19:39 +01:00
|
|
|
|
|
|
|
class XImage
|
|
|
|
{
|
|
|
|
protected:
|
2020-02-25 14:55:39 +01:00
|
|
|
UINTN Width;
|
|
|
|
UINTN Height;
|
2020-02-25 22:28:36 +01:00
|
|
|
XArray<EFI_GRAPHICS_OUTPUT_BLT_PIXEL> PixelData;
|
2020-02-26 14:59:10 +01:00
|
|
|
|
2020-02-25 21:19:39 +01:00
|
|
|
public:
|
|
|
|
XImage();
|
2020-02-26 14:59:10 +01:00
|
|
|
XImage(UINTN W, UINTN H);
|
2020-03-02 13:00:24 +01:00
|
|
|
XImage(EG_IMAGE* egImage);
|
2020-02-26 14:59:10 +01:00
|
|
|
XImage(const XImage& Image, float scale);
|
2020-02-25 21:19:39 +01:00
|
|
|
~XImage();
|
|
|
|
|
|
|
|
protected:
|
2020-02-25 21:57:23 +01:00
|
|
|
UINTN GetSize() const; //in bytes
|
2020-02-25 21:19:39 +01:00
|
|
|
|
|
|
|
public:
|
|
|
|
|
2020-02-25 22:28:36 +01:00
|
|
|
const XArray<EFI_GRAPHICS_OUTPUT_BLT_PIXEL>& GetData() const;
|
|
|
|
|
|
|
|
const EFI_GRAPHICS_OUTPUT_BLT_PIXEL& GetPixel(UINTN x, UINTN y) const;
|
|
|
|
EFI_GRAPHICS_OUTPUT_BLT_PIXEL* GetPixelPtr(UINTN x, UINTN y);
|
2020-02-25 21:57:23 +01:00
|
|
|
UINTN GetWidth() const;
|
|
|
|
UINTN GetHeight() const;
|
2020-02-25 21:19:39 +01:00
|
|
|
|
2020-02-26 14:59:10 +01:00
|
|
|
void Fill(const EFI_GRAPHICS_OUTPUT_BLT_PIXEL& Color = { 0, 0, 0, 0 });
|
|
|
|
void FillArea(const EFI_GRAPHICS_OUTPUT_BLT_PIXEL& Color, const EgRect& Rect);
|
2020-03-02 13:00:24 +01:00
|
|
|
void CopyScaled(const XImage& Image, float scale);
|
2020-03-02 14:46:30 +01:00
|
|
|
void Compose(INTN PosX, INTN PosY, const XImage& TopImage, bool Lowest); //instead of compose we can Back.Draw(...) + Top.Draw(...)
|
2020-02-26 07:05:14 +01:00
|
|
|
void FlipRB(bool WantAlpha);
|
2020-03-02 13:00:24 +01:00
|
|
|
unsigned FromPNG(const UINT8 * Data, UINTN Lenght);
|
|
|
|
unsigned ToPNG(UINT8** Data, UINTN& OutSize);
|
2020-02-28 15:08:40 +01:00
|
|
|
unsigned FromSVG(const CHAR8 *SVGData, UINTN SVGDataLength, float scale);
|
2020-03-02 13:00:24 +01:00
|
|
|
void GetArea(const EG_RECT& Rect);
|
|
|
|
void GetArea(INTN x, INTN y, UINTN W, UINTN H);
|
2020-03-02 14:46:30 +01:00
|
|
|
void Draw(INTN x, INTN y, float scale);
|
2020-02-25 21:19:39 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif //__XSTRINGW_H__
|