Better to use unsigned char

This commit is contained in:
Marco Hugentobler 2012-01-18 17:08:23 +01:00
parent 53500e77c0
commit 7747d1fdea
2 changed files with 8 additions and 8 deletions

View File

@ -164,9 +164,9 @@ int QgsRelief::processRaster( QProgressDialog* p )
float* scanLine2 = ( float * ) CPLMalloc( sizeof( float ) * xSize ); float* scanLine2 = ( float * ) CPLMalloc( sizeof( float ) * xSize );
float* scanLine3 = ( float * ) CPLMalloc( sizeof( float ) * xSize ); float* scanLine3 = ( float * ) CPLMalloc( sizeof( float ) * xSize );
char* resultRedLine = ( char * ) CPLMalloc( sizeof( char ) * xSize ); unsigned char* resultRedLine = ( unsigned char * ) CPLMalloc( sizeof( unsigned char ) * xSize );
char* resultGreenLine = ( char * ) CPLMalloc( sizeof( char ) * xSize ); unsigned char* resultGreenLine = ( unsigned char * ) CPLMalloc( sizeof( unsigned char ) * xSize );
char* resultBlueLine = ( char * ) CPLMalloc( sizeof( char ) * xSize ); unsigned char* resultBlueLine = ( unsigned char * ) CPLMalloc( sizeof( unsigned char ) * xSize );
if ( p ) if ( p )
{ {
@ -278,7 +278,7 @@ int QgsRelief::processRaster( QProgressDialog* p )
} }
bool QgsRelief::processNineCellWindow( float* x1, float* x2, float* x3, float* x4, float* x5, float* x6, float* x7, float* x8, float* x9, bool QgsRelief::processNineCellWindow( float* x1, float* x2, float* x3, float* x4, float* x5, float* x6, float* x7, float* x8, float* x9,
char* red, char* green, char* blue ) unsigned char* red, unsigned char* green, unsigned char* blue )
{ {
//1. component: colour and hillshade from 300 degrees //1. component: colour and hillshade from 300 degrees
int r = 0; int r = 0;
@ -363,9 +363,9 @@ bool QgsRelief::processNineCellWindow( float* x1, float* x2, float* x3, float* x
b = b3 * 0.1 + b * 0.9; b = b3 * 0.1 + b * 0.9;
} }
*red = ( char )r; *red = ( unsigned char )r;
*green = ( char )g; *green = ( unsigned char )g;
*blue = ( char )b; *blue = ( unsigned char )b;
return true; return true;
} }

View File

@ -89,7 +89,7 @@ class ANALYSIS_EXPORT QgsRelief
QList< ReliefColor > mReliefColors; QList< ReliefColor > mReliefColors;
bool processNineCellWindow( float* x1, float* x2, float* x3, float* x4, float* x5, float* x6, float* x7, float* x8, float* x9, bool processNineCellWindow( float* x1, float* x2, float* x3, float* x4, float* x5, float* x6, float* x7, float* x8, float* x9,
char* red, char* green, char* blue ); unsigned char* red, unsigned char* green, unsigned char* blue );
/**Opens the input file and returns the dataset handle and the number of pixels in x-/y- direction*/ /**Opens the input file and returns the dataset handle and the number of pixels in x-/y- direction*/
GDALDatasetH openInputFile( int& nCellsX, int& nCellsY ); GDALDatasetH openInputFile( int& nCellsX, int& nCellsY );