Quantum GIS API Documentation  1.8
src/core/raster/qgscliptominmaxenhancement.cpp
Go to the documentation of this file.
00001 /* **************************************************************************
00002               qgscliptominmaxenhancement.cpp -  description
00003                        -------------------
00004 begin                : Fri Nov 16 2007
00005 copyright            : (C) 2007 by Peter J. Ersts
00006 email                : ersts@amnh.org
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 "qgscliptominmaxenhancement.h"
00020 
00021 QgsClipToMinMaxEnhancement::QgsClipToMinMaxEnhancement( QgsContrastEnhancement::QgsRasterDataType theQgsRasterDataType, double theMinimumValue, double theMaximumValue ) : QgsContrastEnhancementFunction( theQgsRasterDataType, theMinimumValue, theMaximumValue )
00022 {
00023 }
00024 
00025 int QgsClipToMinMaxEnhancement::enhance( double theValue )
00026 {
00027   if ( theValue < mMinimumValue || theValue > mMaximumValue )
00028   {
00029     return -1;
00030   }
00031 
00032   if ( mQgsRasterDataType == QgsContrastEnhancement::QGS_Byte )
00033   {
00034     return static_cast<int>( theValue );
00035   }
00036   else
00037   {
00038     return static_cast<int>(((( theValue - QgsContrastEnhancement::minimumValuePossible( mQgsRasterDataType ) ) / ( QgsContrastEnhancement::maximumValuePossible( mQgsRasterDataType ) - QgsContrastEnhancement::minimumValuePossible( mQgsRasterDataType ) ) )*255.0 ) );
00039   }
00040 }
00041 
00042 bool QgsClipToMinMaxEnhancement::isValueInDisplayableRange( double theValue )
00043 {
00044   if ( theValue < mMinimumValue || theValue > mMaximumValue )
00045   {
00046     return false;
00047   }
00048 
00049   return true;
00050 }
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines