Quantum GIS API Documentation  1.7.4
src/core/raster/qgslinearminmaxenhancement.cpp
Go to the documentation of this file.
00001 /* **************************************************************************
00002               qgslinearminmaxenhancement.cpp -  description
00003                        -------------------
00004 begin                : Fri Nov 16 2007
00005 copyright            : (C) 2007 by Peter J. Ersts
00006 email                : [email protected]
00007 
00008 ****************************************************************************/
00009 
00010 /* **************************************************************************
00011  *                                                                         *
00012  *   This program is free software; you can redistribute it and/or modify  *
00013  *   it under the terms of the GNU General Public License as published by  *
00014  *   the Free Software Foundation; either version 2 of the License, or     *
00015  *   (at your option) any later version.                                   *
00016  *                                                                         *
00017  ***************************************************************************/
00018 
00019 #include "qgslinearminmaxenhancement.h"
00020 
00021 QgsLinearMinMaxEnhancement::QgsLinearMinMaxEnhancement( QgsContrastEnhancement::QgsRasterDataType theQgsRasterDataType, double theMinimumValue, double theMaximumValue ) : QgsContrastEnhancementFunction( theQgsRasterDataType, theMinimumValue, theMaximumValue )
00022 {
00023 }
00024 
00025 int QgsLinearMinMaxEnhancement::enhance( double theValue )
00026 {
00027   int myStretchedValue = static_cast<int>((( theValue - mMinimumValue ) / ( mMinimumMaximumRange ) ) * 255.0 );
00028   if ( myStretchedValue < 0 )
00029   {
00030     return 0;
00031   }
00032   else if ( myStretchedValue > 255 )
00033   {
00034     return 255;
00035   }
00036 
00037   return myStretchedValue;
00038 }
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines