detect square (diagonal) banners, and give a small margin of error

This commit is contained in:
Glenn Maynard
2003-06-16 18:26:24 +00:00
parent 568e27849e
commit 5e1cde48fb
4 changed files with 20 additions and 2 deletions
+8 -1
View File
@@ -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;
}