detect square (diagonal) banners, and give a small margin of error
This commit is contained in:
@@ -10,6 +10,7 @@
|
||||
#include "RageUtil.h"
|
||||
#include "RageLog.h"
|
||||
#include "BannerCache.h"
|
||||
#include "CroppedSprite.h"
|
||||
#include "PrefsManager.h"
|
||||
#include "SDL_utils.h"
|
||||
#include "SDL_dither.h"
|
||||
@@ -304,7 +305,7 @@ void BannerCache::CacheBannerInternal( CString BannerPath )
|
||||
|
||||
bool WasRotatedBanner = false;
|
||||
|
||||
if( img->w == img->h )
|
||||
if( CroppedSprite::IsDiagonalBanner(img->w , img->h) )
|
||||
{
|
||||
/* Ack. It's a diagonal banner. Problem: if we resize a diagonal banner, we
|
||||
* get ugly checker patterns. We need to un-rotate it.
|
||||
|
||||
@@ -56,7 +56,7 @@ void CroppedSprite::CropToSize( float fWidth, float fHeight )
|
||||
float fOriginalX = GetX();
|
||||
float fOriginalY = GetY();
|
||||
|
||||
if( iSourceWidth == iSourceHeight ) // this is a SSR/DWI CroppedSprite
|
||||
if( IsDiagonalBanner(iSourceWidth, iSourceHeight) ) // this is a SSR/DWI CroppedSprite
|
||||
{
|
||||
float fCustomImageCoords[8] = {
|
||||
0.02f, 0.78f, // top left
|
||||
@@ -137,3 +137,10 @@ void CroppedSprite::CropToSize( float fWidth, float fHeight )
|
||||
// restore original XY
|
||||
SetXY( fOriginalX, fOriginalY );
|
||||
}
|
||||
|
||||
bool CroppedSprite::IsDiagonalBanner( int iWidth, int iHeight )
|
||||
{
|
||||
/* A diagonal banner is a square. Give a couple pixels of leeway. */
|
||||
return iWidth >= 100 && abs(iWidth - iHeight) < 2;
|
||||
}
|
||||
|
||||
|
||||
@@ -25,6 +25,8 @@ public:
|
||||
void SetCroppedSize( float fWidth, float fHeight );
|
||||
void SetWH(float fWidth, float fHeight);
|
||||
|
||||
static bool IsDiagonalBanner( int iWidth, int iHeight );
|
||||
|
||||
protected:
|
||||
void CropToSize( float fWidth, float fHeight );
|
||||
|
||||
|
||||
@@ -27,6 +27,7 @@
|
||||
#include "FontCharAliases.h"
|
||||
#include "TitleSubstitution.h"
|
||||
#include "BannerCache.h"
|
||||
#include "CroppedSprite.h"
|
||||
|
||||
#include "NotesLoaderSM.h"
|
||||
#include "NotesLoaderDWI.h"
|
||||
@@ -670,6 +671,13 @@ void Song::TidyUpData()
|
||||
m_sBackgroundFile = arrayImages[i];
|
||||
continue;
|
||||
}
|
||||
|
||||
if( CroppedSprite::IsDiagonalBanner(width, height) )
|
||||
{
|
||||
m_sBannerFile = arrayImages[i];
|
||||
continue;
|
||||
}
|
||||
|
||||
if( !HasBanner() && 100<=width && width<=320 && 50<=height && height<=240 )
|
||||
{
|
||||
m_sBannerFile = arrayImages[i];
|
||||
|
||||
Reference in New Issue
Block a user