Reenable and move iterative filtering into the zoom proper.

This commit is contained in:
Glenn Maynard
2002-11-21 00:48:15 +00:00
parent 6967db837b
commit 48eee90ab2
4 changed files with 39 additions and 49 deletions
+3 -24
View File
@@ -212,30 +212,9 @@ void RageBitmapTexture::Create()
ConvertSDLSurface(img, img->w, img->h, PixFmtMasks[mask][4],
PixFmtMasks[mask][0], PixFmtMasks[mask][1], PixFmtMasks[mask][2], PixFmtMasks[mask][3]);
SDL_Surface *dst = zoomSurface(img, m_iImageWidth, m_iImageHeight );
SDL_FreeSurface(img);
img = dst;
// Commented out to see how things look without iterative filtering. -Chris
// while (m_iImageWidth != m_iTextureWidth || m_iImageHeight != m_iTextureHeight) {
// float xscale = float(m_iTextureWidth)/m_iImageWidth;
// float yscale = float(m_iTextureHeight)/m_iImageHeight;
//
// /* Our filter is a simple linear filter, so it can't scale to
// * less than .5 very well. If we need to go lower than .5, do
// * it iteratively. */
// xscale = max(xscale, .5f);
// yscale = max(yscale, .5f);
//
// SDL_Surface *dst = zoomSurface(img, xscale, yscale);
//
// SDL_FreeSurface(img);
// img = dst;
//
// /* The new image size is the full texture size. */
// m_iImageWidth = int(m_iImageWidth * xscale + .0001);
// m_iImageHeight = int(m_iImageHeight * yscale + .0001);
// }
zoomSurface(img, m_iTextureWidth, m_iTextureHeight );
m_iImageWidth = m_iTextureWidth;
m_iImageHeight = m_iTextureHeight;
}
if( m_prefs.bDither )
+30 -12
View File
@@ -142,13 +142,11 @@ void zoomSurfaceRGBA(SDL_Surface * src, SDL_Surface * dst)
*/
SDL_Surface *zoomSurface(SDL_Surface * src, int dstwidth, int dstheight)
SDL_Surface *zoomSurface_ll(SDL_Surface *src, int dstwidth, int dstheight)
{
SDL_Surface *rz_dst;
/* Sanity check */
if (src == NULL)
return (NULL);
if (src == NULL) return NULL;
/* Alloc space to completely contain the zoomed surface */
/* Target surface is 32bit with source RGBA/ABGR ordering */
@@ -157,18 +155,38 @@ SDL_Surface *zoomSurface(SDL_Surface * src, int dstwidth, int dstheight)
src->format->Rmask, src->format->Gmask,
src->format->Bmask, src->format->Amask);
/*
* Lock source surface
*/
SDL_LockSurface(src);
/* Call the 32bit transformation routine to do the zooming (using alpha) */
zoomSurfaceRGBA(src, rz_dst);
/* Turn on source-alpha support */
SDL_SetAlpha(rz_dst, SDL_SRCALPHA, 255);
/* Unlock source surface */
SDL_UnlockSurface(src);
/* Return destination surface */
return (rz_dst);
return rz_dst;
}
void zoomSurface(SDL_Surface *&src, int dstwidth, int dstheight)
{
if (src == NULL) return;
while (src->w != dstwidth || src->h != dstheight) {
float xscale = float(dstwidth)/src->w;
float yscale = float(dstheight)/src->h;
/* Our filter is a simple linear filter, so it can't scale to
* less than .5 very well. If we need to go lower than .5, do
* it iteratively. */
xscale = max(xscale, .5f);
yscale = max(yscale, .5f);
int target_width = int(src->w*xscale + .5);
int target_height = int(src->h*yscale + .5);
SDL_Surface *dst = zoomSurface_ll(src, target_width, target_height);
SDL_FreeSurface(src);
src = dst;
}
}
+1 -1
View File
@@ -22,7 +22,7 @@
*/
SDL_Surface *zoomSurface(SDL_Surface * src, int dstwidth, int dstheight);
void zoomSurface(SDL_Surface *&src, int dstwidth, int dstheight);
#endif
+5 -12
View File
@@ -247,12 +247,11 @@ void SetIcon()
* this is here just in case it changes.) */
ConvertSDLSurface(srf, srf->w, srf->h,
32, 0xFF000000, 0x00FF0000, 0x0000FF00, 0x000000FF);
SDL_Surface *dst = zoomSurface(srf, 32, 32);
zoomSurface(srf, 32, 32);
SDL_SetAlpha( dst, SDL_SRCALPHA, SDL_ALPHA_OPAQUE );
SDL_WM_SetIcon(dst, NULL /* derive from alpha */);
SDL_SetAlpha( srf, SDL_SRCALPHA, SDL_ALPHA_OPAQUE );
SDL_WM_SetIcon(srf, NULL /* derive from alpha */);
SDL_FreeSurface(srf);
SDL_FreeSurface(dst);
}
//-----------------------------------------------------------------------------
@@ -308,7 +307,6 @@ int main(int argc, char* argv[])
SetIcon();
CreateLoadingWindow();
loading_window->Paint();
//
// Create game objects
@@ -356,7 +354,7 @@ int main(int argc, char* argv[])
HWND hwnd = info.window;
INPUTMAN = new RageInput( hwnd );
// SOUNDMAN = new RageSoundManager( hwnd );
// SOUNDMAN = new RageSoundManager();
// These things depend on the TextureManager, so do them after!
FONT = new FontManager;
@@ -475,10 +473,6 @@ void GameLoop()
}
}
DISPLAY->Clear();
DISPLAY->ResetMatrixStack();
/*
* Update
*/
@@ -501,7 +495,6 @@ void GameLoop()
SCREENMAN->Update( fDeltaTime );
NETWORK->Update( fDeltaTime );
static InputEventArray ieArray;
ieArray.clear(); // empty the array
INPUTFILTER->GetInputEvents( ieArray, fDeltaTime );
@@ -579,10 +572,10 @@ void GameLoop()
SCREENMAN->Input( DeviceI, type, GameI, MenuI, StyleI );
}
/*
* Render
*/
DISPLAY->Clear();
DISPLAY->ResetMatrixStack();
RageMatrix mat;