Handle NULL in ctor.

This commit is contained in:
jief 2020-03-04 23:39:48 +03:00
parent d549733729
commit 5ddb6c1d79
2 changed files with 13 additions and 5 deletions

View File

@ -30,10 +30,18 @@ XImage::XImage(UINTN W, UINTN H)
XImage::XImage(EG_IMAGE* egImage)
{
Width = egImage->Width;
Height = egImage->Height;
PixelData.CheckSize(GetWidth()*GetHeight());
CopyMem(&PixelData[0], egImage->PixelData, PixelData.size());
if ( egImage) {
Width = egImage->Width;
Height = egImage->Height;
}else{
Width = 0;
Height = 0;
}
PixelData.CheckSize(GetWidth()*GetHeight()); // change the allocated size, but not the size.
PixelData.setLength(GetWidth()*GetHeight()); // change the size, ie the number of element in the array
if ( GetWidth()*GetHeight() > 0 ) {
CopyMem(&PixelData[0], egImage->PixelData, PixelData.size());
}
}
UINT8 Smooth(const UINT8* p, int a01, int a10, int a21, int a12, int dx, int dy, float scale)

View File

@ -68,7 +68,7 @@ public:
UINTN GetWidth() const;
UINTN GetHeight() const;
void setEmpty() { PixelData.setEmpty(); }
void setEmpty() { Width=0; Height=0; PixelData.setEmpty(); }
bool isEmpty() const { return PixelData.size() == 0; }