EgtGraphics 1.8l2 :
- corretto caricamento texture da jpeg con ridimensionamento immediato.
This commit is contained in:
Binary file not shown.
+18
-7
@@ -77,9 +77,10 @@ TextureMgr::LoadTexture( const string& sName, const string& sFile,
|
||||
if ( sFile.empty())
|
||||
return LoadCalcTexture( sName, dMMxPix, dDimX, dDimY, nRepeat) ;
|
||||
|
||||
// leggo l'immagine dal file
|
||||
// leggo l'immagine dal file insieme con le dimensioni in pixel originali dell'immagine
|
||||
FIBITMAP* pDib = nullptr ;
|
||||
if ( ! ReadImage( sFile, pDib))
|
||||
int nOriWidth, nOriHeight ;
|
||||
if ( ! ReadImage( sFile, pDib, nOriWidth, nOriHeight))
|
||||
return false ;
|
||||
|
||||
// se necessario, converto l'immagine a 24 bit per pixel (BGR)
|
||||
@@ -90,10 +91,6 @@ TextureMgr::LoadTexture( const string& sName, const string& sFile,
|
||||
FreeImage_Unload( pTmpDib) ;
|
||||
}
|
||||
|
||||
// recupero le dimensioni in pixel originali dell'immagine
|
||||
int nOriWidth = FreeImage_GetWidth( pDib) ;
|
||||
int nOriHeight = FreeImage_GetHeight( pDib) ;
|
||||
|
||||
// se necessario e possibile, la riduco alle dimensioni caricabili da OpenGL corrente
|
||||
if ( ! TestImageWithOpenGL( pDib))
|
||||
return false ;
|
||||
@@ -338,7 +335,7 @@ TextureMgr::GetTextureData( const string& sName, unsigned int& nId, double& dDim
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
bool
|
||||
TextureMgr::ReadImage( const string& sFile, FIBITMAP*& pDib)
|
||||
TextureMgr::ReadImage( const string& sFile, FIBITMAP*& pDib, int& nFilePixX, int& nFilePixY)
|
||||
{
|
||||
// deduco il formato dell'immagine dalla sua segnatura o dalla estensione del file
|
||||
FREE_IMAGE_FORMAT nFif = FreeImage_GetFileTypeU( stringtoW( sFile), 0) ;
|
||||
@@ -368,6 +365,20 @@ TextureMgr::ReadImage( const string& sFile, FIBITMAP*& pDib)
|
||||
return false ;
|
||||
}
|
||||
|
||||
// recupero dimensioni dell'immagine nel file
|
||||
if ( nFif == FIF_JPEG) {
|
||||
FIBITMAP* pTmp = FreeImage_LoadU( nFif, stringtoW( sFile), FIF_LOAD_NOPIXELS) ;
|
||||
if ( pTmp == nullptr)
|
||||
return false ;
|
||||
nFilePixX = FreeImage_GetWidth( pTmp) ;
|
||||
nFilePixY = FreeImage_GetHeight( pTmp) ;
|
||||
FreeImage_Unload( pTmp) ;
|
||||
}
|
||||
else {
|
||||
nFilePixX = FreeImage_GetWidth( pDib) ;
|
||||
nFilePixY = FreeImage_GetHeight( pDib) ;
|
||||
}
|
||||
|
||||
return true ;
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -64,7 +64,7 @@ class TextureMgr
|
||||
private :
|
||||
bool LoadCalcTexture( const std::string& sName,
|
||||
double dMMxPix, double dDimX, double dDimY, int nRepeat) ;
|
||||
bool ReadImage( const std::string& sFile, FIBITMAP*& pDib) ;
|
||||
bool ReadImage( const std::string& sFile, FIBITMAP*& pDib, int& nFilePixX, int& nFilePixY) ;
|
||||
bool TestImageWithOpenGL( FIBITMAP*& pDib) ;
|
||||
|
||||
private :
|
||||
|
||||
Reference in New Issue
Block a user