42 changes: 21 additions & 21 deletions src/core/raster/qgsrasterblock.h
Original file line number Diff line number Diff line change
Expand Up @@ -171,9 +171,9 @@ class CORE_EXPORT QgsRasterBlock

/** \brief Read a single value if type of block is numeric. If type is color,
* returned value is undefined.
* @param index data matrix index
* @param index data matrix index (long type in Python)
* @return value */
double value( size_t index ) const;
double value( qgssize index ) const;

/** \brief Read a single color
* @param row row index
Expand All @@ -182,9 +182,9 @@ class CORE_EXPORT QgsRasterBlock
QRgb color( int row, int column ) const;

/** \brief Read a single value
* @param index data matrix index
* @param index data matrix index (long type in Python)
* @return color */
QRgb color( size_t index ) const;
QRgb color( qgssize index ) const;

/** \brief Check if value at position is no data
* @param row row index
Expand All @@ -193,9 +193,9 @@ class CORE_EXPORT QgsRasterBlock
bool isNoData( int row, int column );

/** \brief Check if value at position is no data
* @param index data matrix index
* @param index data matrix index (long type in Python)
* @return true if value is no data */
bool isNoData( size_t index );
bool isNoData( qgssize index );

/** \brief Set value on position
* @param row row index
Expand All @@ -205,10 +205,10 @@ class CORE_EXPORT QgsRasterBlock
bool setValue( int row, int column, double value );

/** \brief Set value on index (indexed line by line)
* @param index data matrix index
* @param index data matrix index (long type in Python)
* @param value the value to be set
* @return true on success */
bool setValue( size_t index, double value );
bool setValue( qgssize index, double value );

/** \brief Set color on position
* @param row row index
Expand All @@ -218,10 +218,10 @@ class CORE_EXPORT QgsRasterBlock
bool setColor( int row, int column, QRgb color );

/** \brief Set color on index (indexed line by line)
* @param index data matrix index
* @param index data matrix index (long type in Python)
* @param color the color to be set, QRgb value
* @return true on success */
bool setColor( size_t index, QRgb color );
bool setColor( qgssize index, QRgb color );

/** \brief Set no data on pixel
* @param row row index
Expand All @@ -230,9 +230,9 @@ class CORE_EXPORT QgsRasterBlock
bool setIsNoData( int row, int column );

/** \brief Set no data on pixel
* @param index data matrix index
* @param index data matrix index (long type in Python)
* @return true on success */
bool setIsNoData( size_t index );
bool setIsNoData( qgssize index );

/** \brief Set the whole block to no data
* @return true on success */
Expand All @@ -251,11 +251,11 @@ class CORE_EXPORT QgsRasterBlock
char * bits( int row, int column );

/** \brief Get pointer to data
* @param index data matrix index
* @param index data matrix index (long type in Python)
* @return pointer to data
* @note not available in python bindings
*/
char * bits( size_t index );
char * bits( qgssize index );

/** \brief Get pointer to data
* @return pointer to data
Expand Down Expand Up @@ -284,10 +284,10 @@ class CORE_EXPORT QgsRasterBlock
bool setImage( const QImage * image );

// @note not available in python bindings
inline static double readValue( void *data, QGis::DataType type, size_t index );
inline static double readValue( void *data, QGis::DataType type, qgssize index );

// @note not available in python bindings
inline static void writeValue( void *data, QGis::DataType type, size_t index, double value );
inline static void writeValue( void *data, QGis::DataType type, qgssize index, double value );

void applyNoDataValues( const QgsRasterRangeList & rangeList );

Expand Down Expand Up @@ -334,7 +334,7 @@ class CORE_EXPORT QgsRasterBlock
* @param destDataType dest data type
* @param size block size (width * height)
* @return block of data in destDataType */
static void * convert( void *srcData, QGis::DataType srcDataType, QGis::DataType destDataType, size_t size );
static void * convert( void *srcData, QGis::DataType srcDataType, QGis::DataType destDataType, qgssize size );

// Valid
bool mValid;
Expand Down Expand Up @@ -373,13 +373,13 @@ class CORE_EXPORT QgsRasterBlock
int mNoDataBitmapWidth;

// total size in bytes of mNoDataBitmap
size_t mNoDataBitmapSize;
qgssize mNoDataBitmapSize;

// Error
QgsError mError;
};

inline double QgsRasterBlock::readValue( void *data, QGis::DataType type, size_t index )
inline double QgsRasterBlock::readValue( void *data, QGis::DataType type, qgssize index )
{
if ( !data )
{
Expand Down Expand Up @@ -417,7 +417,7 @@ inline double QgsRasterBlock::readValue( void *data, QGis::DataType type, size_t
return std::numeric_limits<double>::quiet_NaN();
}

inline void QgsRasterBlock::writeValue( void *data, QGis::DataType type, size_t index, double value )
inline void QgsRasterBlock::writeValue( void *data, QGis::DataType type, qgssize index, double value )
{
if ( !data ) return;

Expand Down Expand Up @@ -450,7 +450,7 @@ inline void QgsRasterBlock::writeValue( void *data, QGis::DataType type, size_t
}
}

inline double QgsRasterBlock::value( size_t index ) const
inline double QgsRasterBlock::value( qgssize index ) const
{
if ( !mData )
{
Expand Down
6 changes: 3 additions & 3 deletions src/core/raster/qgsrasterdataprovider.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -182,8 +182,8 @@ QgsRasterBlock * QgsRasterDataProvider::block( int theBandNo, QgsRectangle cons
return block;
}

size_t tmpIndex = tmpRow * tmpWidth + tmpCol;
size_t index = row * theWidth + col;
qgssize tmpIndex = tmpRow * tmpWidth + tmpCol;
qgssize index = row * theWidth + col;

char *tmpBits = tmpBlock->bits( tmpIndex );
char *bits = block->bits( index );
Expand Down Expand Up @@ -237,7 +237,7 @@ QStringList QgsRasterDataProvider::cStringList2Q_( char ** stringList )
QStringList strings;

// presume null terminated string list
for ( size_t i = 0; stringList[i]; ++i )
for ( qgssize i = 0; stringList[i]; ++i )
{
strings.append( stringList[i] );
}
Expand Down
4 changes: 2 additions & 2 deletions src/core/raster/qgsrasterfilewriter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -513,13 +513,13 @@ QgsRasterFileWriter::WriterError QgsRasterFileWriter::writeImageRaster( QgsRaste
}

//fill into red/green/blue/alpha channels
size_t nPixels = ( size_t )iterCols * iterRows;
qgssize nPixels = ( qgssize )iterCols * iterRows;
// TODO: should be char not int? we are then copying 1 byte
int red = 0;
int green = 0;
int blue = 0;
int alpha = 255;
for ( size_t i = 0; i < nPixels; ++i )
for ( qgssize i = 0; i < nPixels; ++i )
{
QRgb c = inputBlock->color( i );
alpha = qAlpha( c );
Expand Down
4 changes: 2 additions & 2 deletions src/core/raster/qgsrasterinterface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ QgsRasterBandStats QgsRasterInterface::bandStatistics( int theBandNo,
QgsRasterBlock* blk = block( theBandNo, myPartExtent, myBlockWidth, myBlockHeight );

// Collect the histogram counts.
for ( size_t i = 0; i < (( size_t ) myBlockHeight ) * myBlockWidth; i++ )
for ( qgssize i = 0; i < (( qgssize ) myBlockHeight ) * myBlockWidth; i++ )
{
if ( blk->isNoData( i ) ) continue; // NULL

Expand Down Expand Up @@ -458,7 +458,7 @@ QgsRasterHistogram QgsRasterInterface::histogram( int theBandNo,
QgsRasterBlock* blk = block( theBandNo, myPartExtent, myBlockWidth, myBlockHeight );

// Collect the histogram counts.
for ( size_t i = 0; i < (( size_t ) myBlockHeight ) * myBlockWidth; i++ )
for ( qgssize i = 0; i < (( qgssize ) myBlockHeight ) * myBlockWidth; i++ )
{
if ( blk->isNoData( i ) )
{
Expand Down
6 changes: 3 additions & 3 deletions src/core/raster/qgsrasterprojector.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -746,7 +746,7 @@ QgsRasterBlock * QgsRasterProjector::block( int bandNo, QgsRectangle const & ex
return new QgsRasterBlock();
}

size_t pixelSize = QgsRasterBlock::typeSize( mInput->dataType( bandNo ) );
qgssize pixelSize = QgsRasterBlock::typeSize( mInput->dataType( bandNo ) );

QgsRasterBlock *outputBlock;
if ( inputBlock->hasNoDataValue() )
Expand Down Expand Up @@ -781,7 +781,7 @@ QgsRasterBlock * QgsRasterProjector::block( int bandNo, QgsRectangle const & ex
for ( int j = 0; j < width; ++j )
{
srcRowCol( i, j, &srcRow, &srcCol );
size_t srcIndex = ( size_t )srcRow * mSrcCols + srcCol;
qgssize srcIndex = ( qgssize )srcRow * mSrcCols + srcCol;
QgsDebugMsgLevel( QString( "row = %1 col = %2 srcRow = %3 srcCol = %4" ).arg( i ).arg( j ).arg( srcRow ).arg( srcCol ), 5 );

// isNoData() may be slow so we check doNoData first
Expand All @@ -791,7 +791,7 @@ QgsRasterBlock * QgsRasterProjector::block( int bandNo, QgsRectangle const & ex
continue ;
}

size_t destIndex = ( size_t )i * width + j;
qgssize destIndex = ( qgssize )i * width + j;
char *srcBits = inputBlock->bits( srcIndex );
char *destBits = outputBlock->bits( destIndex );
if ( !srcBits )
Expand Down
2 changes: 1 addition & 1 deletion src/core/raster/qgssinglebandcolordatarenderer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ QgsRasterBlock* QgsSingleBandColorDataRenderer::block( int bandNo, QgsRectangle
return outputBlock;
}

for ( size_t i = 0; i < ( size_t )width*height; i++ )
for ( qgssize i = 0; i < ( qgssize )width*height; i++ )
{
QRgb pixelColor;
double alpha = 255.0;
Expand Down
2 changes: 1 addition & 1 deletion src/core/raster/qgssinglebandgrayrenderer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ QgsRasterBlock* QgsSingleBandGrayRenderer::block( int bandNo, QgsRectangle cons
}

QRgb myDefaultColor = NODATA_COLOR;
for ( size_t i = 0; i < ( size_t )width*height; i++ )
for ( qgssize i = 0; i < ( qgssize )width*height; i++ )
{
if ( inputBlock->isNoData( i ) )
{
Expand Down
2 changes: 1 addition & 1 deletion src/core/raster/qgssinglebandpseudocolorrenderer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ QgsRasterBlock* QgsSingleBandPseudoColorRenderer::block( int bandNo, QgsRectangl

QRgb myDefaultColor = NODATA_COLOR;

for ( size_t i = 0; i < ( size_t )width*height; i++ )
for ( qgssize i = 0; i < ( qgssize )width*height; i++ )
{
if ( inputBlock->isNoData( i ) )
{
Expand Down