From 558ef9e2752122f29cef11d2cb0d5668586f1421 Mon Sep 17 00:00:00 2001 From: Glenn Maynard Date: Mon, 5 May 2003 03:14:47 +0000 Subject: [PATCH] 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. --- stepmania/src/RageBitmapTexture.cpp | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/stepmania/src/RageBitmapTexture.cpp b/stepmania/src/RageBitmapTexture.cpp index a12063fc6c..39ba1db2d1 100644 --- a/stepmania/src/RageBitmapTexture.cpp +++ b/stepmania/src/RageBitmapTexture.cpp @@ -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 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; }