mirror of https://github.com/axmolengine/axmol.git
Fix #2256
This commit is contained in:
parent
e5073273b8
commit
775b752f85
|
@ -429,8 +429,8 @@ Data Device::getTextureDataForText(std::string_view text,
|
|||
{
|
||||
break;
|
||||
}
|
||||
height = (short)info.height;
|
||||
width = (short)info.width;
|
||||
height = static_cast<int>(info.height);
|
||||
width = static_cast<int>(info.width);
|
||||
ret.fastSet(info.data, width * height * 4);
|
||||
hasPremultipliedAlpha = true;
|
||||
} while (0);
|
||||
|
|
|
@ -450,8 +450,8 @@ Data Device::getTextureDataForText(std::string_view text,
|
|||
bi.bmiHeader.biSize = sizeof(bi.bmiHeader);
|
||||
AX_BREAK_IF(!GetDIBits(dc.getDC(), dc.getBitmap(), 0, 0, nullptr, (LPBITMAPINFO)&bi, DIB_RGB_COLORS));
|
||||
|
||||
width = (short)size.cx;
|
||||
height = (short)size.cy;
|
||||
width = static_cast<int>(size.cx);
|
||||
height = static_cast<int>(size.cy);
|
||||
|
||||
// copy pixel data
|
||||
bi.bmiHeader.biHeight = (bi.bmiHeader.biHeight > 0) ? -bi.bmiHeader.biHeight : bi.bmiHeader.biHeight;
|
||||
|
|
|
@ -549,7 +549,13 @@ bool Texture2D::initWithString(std::string_view text, const FontDefinition& text
|
|||
bool hasPremultipliedAlpha;
|
||||
Data outData = Device::getTextureDataForText(text, textDef, align, imageWidth, imageHeight, hasPremultipliedAlpha);
|
||||
if (outData.isNull())
|
||||
return false;
|
||||
|
||||
const auto maxTextureSize = backend::DriverBase::getInstance()->getMaxTextureSize();
|
||||
if (imageWidth > maxTextureSize || imageHeight > maxTextureSize)
|
||||
{
|
||||
AXLOGW("Texture2D::initWithString fail, the texture size:{}x{} too large, max texture size:{}", imageWidth,
|
||||
imageHeight, maxTextureSize);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue