Override the "size" of a texture:
Foo [res 128x64].png This can be used to store a texture at a different resolution without having to change all of the metrics that reference it. The most obvious use is to lower the resolution of large images. A less obvious use is to raise the resolution of images. If an image is going to be zoomed, it may be useful to store the texture at a higher resolution than native. This can be done with metrics, but it's a pain to have to track down each metric that needs to be changed. This (should) also work with fonts (but that needs testing). Use this sparingly.
This commit is contained in:
@@ -105,6 +105,23 @@ int PixFmtMaskNo(GLenum fmt)
|
||||
}
|
||||
}
|
||||
|
||||
static void GetResolutionFromFileName( CString sPath, int &Width, int &Height )
|
||||
{
|
||||
/* Match:
|
||||
* Foo [res 512x128].png
|
||||
*
|
||||
* This leaves us room syntactically to do other things later, if we need to.
|
||||
* Be careful that this doesn't get mixed up with frame dimensions. */
|
||||
Regex re("\\[res ([0-9]+)x([0-9]+)\\]");
|
||||
|
||||
vector<CString> matches;
|
||||
if(!re.Compare(sPath, matches))
|
||||
return;
|
||||
|
||||
Width = atoi(matches[0].c_str());
|
||||
Height = atoi(matches[1].c_str());
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// RageBitmapTexture constructor
|
||||
//-----------------------------------------------------------------------------
|
||||
@@ -277,6 +294,8 @@ SDL_Surface *RageBitmapTexture::CreateImg(int &pixfmt)
|
||||
zoomSurface(img, m_iImageWidth, m_iImageHeight );
|
||||
}
|
||||
|
||||
/* See if the apparent "size" is being overridden. */
|
||||
GetResolutionFromFileName(m_ActualID.filename, m_iSourceWidth, m_iSourceHeight);
|
||||
return img;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user