mirror of
https://github.com/RetroDECK/ES-DE.git
synced 2025-01-17 22:55:38 +00:00
Added support for automatic rasterization sizes (leave width or height as 0).
This commit is contained in:
parent
cafa1b5b8d
commit
062a004e4a
|
@ -45,15 +45,25 @@ void SVGResource::initFromMemory(const char* file, size_t length)
|
|||
if(mLastWidth && mLastHeight)
|
||||
rasterizeAt(mLastWidth, mLastHeight);
|
||||
else
|
||||
rasterizeAt((int)round(mSVGImage->width), (int)round(mSVGImage->height));
|
||||
rasterizeAt((size_t)round(mSVGImage->width), (size_t)round(mSVGImage->height));
|
||||
}
|
||||
|
||||
void SVGResource::rasterizeAt(size_t width, size_t height)
|
||||
{
|
||||
if(!mSVGImage || width == 0 || height == 0)
|
||||
if(!mSVGImage || (width == 0 && height == 0))
|
||||
return;
|
||||
|
||||
if(width != (int)round(mSVGImage->width) && height != (int)round(mSVGImage->height))
|
||||
if(width == 0)
|
||||
{
|
||||
// auto scale width to keep aspect
|
||||
width = (size_t)round((height / mSVGImage->height) * mSVGImage->width);
|
||||
}else if(height == 0)
|
||||
{
|
||||
// auto scale height to keep aspect
|
||||
height = (size_t)round((width / mSVGImage->width) * mSVGImage->height);
|
||||
}
|
||||
|
||||
if(width != (size_t)round(mSVGImage->width) && height != (size_t)round(mSVGImage->height))
|
||||
{
|
||||
mLastWidth = width;
|
||||
mLastHeight = height;
|
||||
|
|
Loading…
Reference in a new issue