diff --git a/SceneImage.cpp b/SceneImage.cpp index fbeee92..37b5043 100644 --- a/SceneImage.cpp +++ b/SceneImage.cpp @@ -128,26 +128,28 @@ Scene::GetImage( int nShowMode, Color colBackTop, Color colBackBottom, pDib = FreeImage_ConvertTo24Bits( pTmpDib) ; FreeImage_Unload( pTmpDib) ; - // Eseguo scalatura della bitmap - int nLeft ; int nTop ; - int nRight ; int nBottom ; - if ( dCoeffW / nN >= dCoeffH / nM) { - nLeft = 0 ; - nRight = nN * nWidth - 1 ; - int nDeltaH = nM * nHeight - nN * int( nDestHeight / dCoeffW) ; - nTop = nDeltaH / 2 ; - nBottom = nM * nHeight - nTop - 1 ; + // Se necessario, eseguo scalatura della bitmap + if ( nDestWidth != nN * nWidth || nDestHeight != nM * nHeight) { + int nLeft ; int nTop ; + int nRight ; int nBottom ; + if ( dCoeffW / nN >= dCoeffH / nM) { + nLeft = 0 ; + nRight = nN * nWidth - 1 ; + int nDeltaH = nM * nHeight - nN * int( nDestHeight / dCoeffW) ; + nTop = nDeltaH / 2 ; + nBottom = nM * nHeight - nTop - 1 ; + } + else { + nTop = 0 ; + nBottom = nM * nHeight - 1 ; + int nDeltaW = nN * nWidth - nM * int( nDestWidth / dCoeffH) ; + nLeft = nDeltaW / 2 ; + nRight = nN * nWidth - nLeft - 1 ; + } + FIBITMAP* pTmp2Dib = pDib ; + pDib = FreeImage_RescaleRect( pTmp2Dib, nDestWidth, nDestHeight, nLeft, nTop, nRight, nBottom, FILTER_CATMULLROM) ; + FreeImage_Unload( pTmp2Dib) ; } - else { - nTop = 0 ; - nBottom = nM * nHeight - 1 ; - int nDeltaW = nN * nWidth - nM * int( nDestWidth / dCoeffH) ; - nLeft = nDeltaW / 2 ; - nRight = nN * nWidth - nLeft - 1 ; - } - FIBITMAP* pTmp2Dib = pDib ; - pDib = FreeImage_RescaleRect( pTmp2Dib, nDestWidth, nDestHeight, nLeft, nTop, nRight, nBottom, FILTER_BSPLINE) ; - FreeImage_Unload( pTmp2Dib) ; // Salvataggio int nFlag = 0 ;