Reenable and move iterative filtering into the zoom proper.
This commit is contained in:
@@ -212,30 +212,9 @@ void RageBitmapTexture::Create()
|
|||||||
ConvertSDLSurface(img, img->w, img->h, PixFmtMasks[mask][4],
|
ConvertSDLSurface(img, img->w, img->h, PixFmtMasks[mask][4],
|
||||||
PixFmtMasks[mask][0], PixFmtMasks[mask][1], PixFmtMasks[mask][2], PixFmtMasks[mask][3]);
|
PixFmtMasks[mask][0], PixFmtMasks[mask][1], PixFmtMasks[mask][2], PixFmtMasks[mask][3]);
|
||||||
|
|
||||||
SDL_Surface *dst = zoomSurface(img, m_iImageWidth, m_iImageHeight );
|
zoomSurface(img, m_iTextureWidth, m_iTextureHeight );
|
||||||
SDL_FreeSurface(img);
|
m_iImageWidth = m_iTextureWidth;
|
||||||
img = dst;
|
m_iImageHeight = m_iTextureHeight;
|
||||||
|
|
||||||
// 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);
|
|
||||||
// }
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if( m_prefs.bDither )
|
if( m_prefs.bDither )
|
||||||
|
|||||||
@@ -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;
|
SDL_Surface *rz_dst;
|
||||||
|
|
||||||
/* Sanity check */
|
if (src == NULL) return NULL;
|
||||||
if (src == NULL)
|
|
||||||
return (NULL);
|
|
||||||
|
|
||||||
/* Alloc space to completely contain the zoomed surface */
|
/* Alloc space to completely contain the zoomed surface */
|
||||||
/* Target surface is 32bit with source RGBA/ABGR ordering */
|
/* 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->Rmask, src->format->Gmask,
|
||||||
src->format->Bmask, src->format->Amask);
|
src->format->Bmask, src->format->Amask);
|
||||||
|
|
||||||
/*
|
|
||||||
* Lock source surface
|
|
||||||
*/
|
|
||||||
SDL_LockSurface(src);
|
SDL_LockSurface(src);
|
||||||
|
|
||||||
/* Call the 32bit transformation routine to do the zooming (using alpha) */
|
/* Call the 32bit transformation routine to do the zooming (using alpha) */
|
||||||
zoomSurfaceRGBA(src, rz_dst);
|
zoomSurfaceRGBA(src, rz_dst);
|
||||||
/* Turn on source-alpha support */
|
|
||||||
SDL_SetAlpha(rz_dst, SDL_SRCALPHA, 255);
|
|
||||||
/* Unlock source surface */
|
|
||||||
SDL_UnlockSurface(src);
|
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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -22,7 +22,7 @@
|
|||||||
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
SDL_Surface *zoomSurface(SDL_Surface * src, int dstwidth, int dstheight);
|
void zoomSurface(SDL_Surface *&src, int dstwidth, int dstheight);
|
||||||
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -247,12 +247,11 @@ void SetIcon()
|
|||||||
* this is here just in case it changes.) */
|
* this is here just in case it changes.) */
|
||||||
ConvertSDLSurface(srf, srf->w, srf->h,
|
ConvertSDLSurface(srf, srf->w, srf->h,
|
||||||
32, 0xFF000000, 0x00FF0000, 0x0000FF00, 0x000000FF);
|
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_SetAlpha( srf, SDL_SRCALPHA, SDL_ALPHA_OPAQUE );
|
||||||
SDL_WM_SetIcon(dst, NULL /* derive from alpha */);
|
SDL_WM_SetIcon(srf, NULL /* derive from alpha */);
|
||||||
SDL_FreeSurface(srf);
|
SDL_FreeSurface(srf);
|
||||||
SDL_FreeSurface(dst);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
@@ -308,7 +307,6 @@ int main(int argc, char* argv[])
|
|||||||
SetIcon();
|
SetIcon();
|
||||||
|
|
||||||
CreateLoadingWindow();
|
CreateLoadingWindow();
|
||||||
loading_window->Paint();
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// Create game objects
|
// Create game objects
|
||||||
@@ -356,7 +354,7 @@ int main(int argc, char* argv[])
|
|||||||
HWND hwnd = info.window;
|
HWND hwnd = info.window;
|
||||||
|
|
||||||
INPUTMAN = new RageInput( hwnd );
|
INPUTMAN = new RageInput( hwnd );
|
||||||
// SOUNDMAN = new RageSoundManager( hwnd );
|
// SOUNDMAN = new RageSoundManager();
|
||||||
|
|
||||||
// These things depend on the TextureManager, so do them after!
|
// These things depend on the TextureManager, so do them after!
|
||||||
FONT = new FontManager;
|
FONT = new FontManager;
|
||||||
@@ -475,10 +473,6 @@ void GameLoop()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
DISPLAY->Clear();
|
|
||||||
DISPLAY->ResetMatrixStack();
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Update
|
* Update
|
||||||
*/
|
*/
|
||||||
@@ -501,7 +495,6 @@ void GameLoop()
|
|||||||
SCREENMAN->Update( fDeltaTime );
|
SCREENMAN->Update( fDeltaTime );
|
||||||
NETWORK->Update( fDeltaTime );
|
NETWORK->Update( fDeltaTime );
|
||||||
|
|
||||||
|
|
||||||
static InputEventArray ieArray;
|
static InputEventArray ieArray;
|
||||||
ieArray.clear(); // empty the array
|
ieArray.clear(); // empty the array
|
||||||
INPUTFILTER->GetInputEvents( ieArray, fDeltaTime );
|
INPUTFILTER->GetInputEvents( ieArray, fDeltaTime );
|
||||||
@@ -579,10 +572,10 @@ void GameLoop()
|
|||||||
SCREENMAN->Input( DeviceI, type, GameI, MenuI, StyleI );
|
SCREENMAN->Input( DeviceI, type, GameI, MenuI, StyleI );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Render
|
* Render
|
||||||
*/
|
*/
|
||||||
|
DISPLAY->Clear();
|
||||||
DISPLAY->ResetMatrixStack();
|
DISPLAY->ResetMatrixStack();
|
||||||
|
|
||||||
RageMatrix mat;
|
RageMatrix mat;
|
||||||
|
|||||||
Reference in New Issue
Block a user