Skip to content

Commit 53500e7

Browse files
committed
Use byte raster bands for relief plugin to generate smaller output rasters
1 parent e6fe59b commit 53500e7

File tree

2 files changed

+12
-12
lines changed

2 files changed

+12
-12
lines changed

src/analysis/raster/qgsrelief.cpp

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -164,9 +164,9 @@ int QgsRelief::processRaster( QProgressDialog* p )
164164
float* scanLine2 = ( float * ) CPLMalloc( sizeof( float ) * xSize );
165165
float* scanLine3 = ( float * ) CPLMalloc( sizeof( float ) * xSize );
166166

167-
int* resultRedLine = ( int * ) CPLMalloc( sizeof( int ) * xSize );
168-
int* resultGreenLine = ( int * ) CPLMalloc( sizeof( int ) * xSize );
169-
int* resultBlueLine = ( int * ) CPLMalloc( sizeof( int ) * xSize );
167+
char* resultRedLine = ( char * ) CPLMalloc( sizeof( char ) * xSize );
168+
char* resultGreenLine = ( char * ) CPLMalloc( sizeof( char ) * xSize );
169+
char* resultBlueLine = ( char * ) CPLMalloc( sizeof( char ) * xSize );
170170

171171
if ( p )
172172
{
@@ -247,9 +247,9 @@ int QgsRelief::processRaster( QProgressDialog* p )
247247
}
248248
}
249249

250-
GDALRasterIO( outputRedBand, GF_Write, 0, i, xSize, 1, resultRedLine, xSize, 1, GDT_Int32, 0, 0 );
251-
GDALRasterIO( outputGreenBand, GF_Write, 0, i, xSize, 1, resultGreenLine, xSize, 1, GDT_Int32, 0, 0 );
252-
GDALRasterIO( outputBlueBand, GF_Write, 0, i, xSize, 1, resultBlueLine, xSize, 1, GDT_Int32, 0, 0 );
250+
GDALRasterIO( outputRedBand, GF_Write, 0, i, xSize, 1, resultRedLine, xSize, 1, GDT_Byte, 0, 0 );
251+
GDALRasterIO( outputGreenBand, GF_Write, 0, i, xSize, 1, resultGreenLine, xSize, 1, GDT_Byte, 0, 0 );
252+
GDALRasterIO( outputBlueBand, GF_Write, 0, i, xSize, 1, resultBlueLine, xSize, 1, GDT_Byte, 0, 0 );
253253
}
254254

255255
if ( p )
@@ -278,7 +278,7 @@ int QgsRelief::processRaster( QProgressDialog* p )
278278
}
279279

280280
bool QgsRelief::processNineCellWindow( float* x1, float* x2, float* x3, float* x4, float* x5, float* x6, float* x7, float* x8, float* x9,
281-
int* red, int* green, int* blue )
281+
char* red, char* green, char* blue )
282282
{
283283
//1. component: colour and hillshade from 300 degrees
284284
int r = 0;
@@ -363,9 +363,9 @@ bool QgsRelief::processNineCellWindow( float* x1, float* x2, float* x3, float* x
363363
b = b3 * 0.1 + b * 0.9;
364364
}
365365

366-
*red = r;
367-
*green = g;
368-
*blue = b;
366+
*red = ( char )r;
367+
*green = ( char )g;
368+
*blue = ( char )b;
369369
return true;
370370
}
371371

@@ -444,7 +444,7 @@ GDALDatasetH QgsRelief::openOutputFile( GDALDatasetH inputDataset, GDALDriverH o
444444
papszOptions = CSLSetNameValue( papszOptions, "COMPRESS", "PACKBITS" );
445445

446446
//create three band raster (reg, green, blue)
447-
GDALDatasetH outputDataset = GDALCreate( outputDriver, mOutputFile.toLocal8Bit().data(), xSize, ySize, 3, GDT_Int32, papszOptions );
447+
GDALDatasetH outputDataset = GDALCreate( outputDriver, mOutputFile.toLocal8Bit().data(), xSize, ySize, 3, GDT_Byte, papszOptions );
448448
if ( outputDataset == NULL )
449449
{
450450
return outputDataset;

src/analysis/raster/qgsrelief.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ class ANALYSIS_EXPORT QgsRelief
8989
QList< ReliefColor > mReliefColors;
9090

9191
bool processNineCellWindow( float* x1, float* x2, float* x3, float* x4, float* x5, float* x6, float* x7, float* x8, float* x9,
92-
int* red, int* green, int* blue );
92+
char* red, char* green, char* blue );
9393

9494
/**Opens the input file and returns the dataset handle and the number of pixels in x-/y- direction*/
9595
GDALDatasetH openInputFile( int& nCellsX, int& nCellsY );

0 commit comments

Comments
 (0)