18 #ifndef QGSRASTERBLOCK_H 19 #define QGSRASTERBLOCK_H 21 #include "qgis_core.h" 71 void setValid(
bool valid ) { mValid = valid; }
119 return typeSize( mDataType );
146 bool hasNoData()
const;
153 void setNoDataValue(
double noDataValue );
161 void resetNoDataValue();
176 static QByteArray valueBytes(
Qgis::DataType dataType,
double value );
184 double value(
int row,
int column )
const;
191 double value(
qgssize index )
const;
198 QRgb color(
int row,
int column )
const;
204 QRgb color(
qgssize index )
const;
211 bool isNoData(
int row,
int column );
217 bool isNoData(
qgssize index );
225 bool setValue(
int row,
int column,
double value );
232 bool setValue(
qgssize index,
double value );
240 bool setColor(
int row,
int column, QRgb color );
247 bool setColor(
qgssize index, QRgb color );
254 bool setIsNoData(
int row,
int column );
260 bool setIsNoData(
qgssize index );
270 bool setIsNoDataExcept( QRect exceptRect );
280 void setIsData(
int row,
int column );
289 void setIsData(
qgssize index );
300 QByteArray data()
const;
311 void setData(
const QByteArray &data,
int offset = 0 );
320 char *bits(
int row,
int column )
SIP_SKIP;
342 static QString printValue(
double value );
352 static QString printValue(
float value )
SIP_SKIP;
363 QImage image()
const;
369 bool setImage(
const QImage *image );
383 void applyScaleOffset(
double scale,
double offset );
391 QString toString()
const;
410 int width()
const {
return mWidth; }
428 static bool isNoDataValue(
double value,
double noDataValue );
434 bool isNoDataValue(
double value )
const;
439 bool createNoDataBitmap();
467 bool mHasNoDataValue =
false;
472 static const QRgb NO_DATA_COLOR;
476 void *mData =
nullptr;
479 QImage *mImage =
nullptr;
484 char *mNoDataBitmap =
nullptr;
487 int mNoDataBitmapWidth = 0;
500 return std::numeric_limits<double>::quiet_NaN();
506 return static_cast< double >( (
static_cast< quint8 *
>( data ) )[index] );
509 return static_cast< double >( (
static_cast< quint16 *
>( data ) )[index] );
512 return static_cast< double >( (
static_cast< qint16 *
>( data ) )[index] );
515 return static_cast< double >( (
static_cast< quint32 *
>( data ) )[index] );
518 return static_cast< double >( (
static_cast< qint32 *
>( data ) )[index] );
521 return static_cast< double >( (
static_cast< float *
>( data ) )[index] );
524 return static_cast< double >( (
static_cast< double *
>( data ) )[index] );
527 QgsDebugMsg( QString(
"Data type %1 is not supported" ).arg( type ) );
531 return std::numeric_limits<double>::quiet_NaN();
541 (
static_cast< quint8 *
>( data ) )[index] =
static_cast< quint8
>( value );
544 (
static_cast< quint16 *
>( data ) )[index] =
static_cast< quint16
>( value );
547 (
static_cast< qint16 *
>( data ) )[index] =
static_cast< qint16
>( value );
550 (
static_cast< quint32 *
>( data ) )[index] =
static_cast< quint32
>( value );
553 (
static_cast< qint32 *
>( data ) )[index] =
static_cast< qint32
>( value );
556 (
static_cast< float *
>( data ) )[index] =
static_cast< float >( value );
559 (
static_cast< double *
>( data ) )[index] = value;
562 QgsDebugMsg( QString(
"Data type %1 is not supported" ).arg( type ) );
572 return std::numeric_limits<double>::quiet_NaN();
574 return readValue( mData, mDataType, index );
577 inline bool QgsRasterBlock::isNoDataValue(
double value )
const SIP_SKIP 579 return std::isnan( value ) ||
qgsDoubleNear( value, mNoDataValue );
A rectangle specified with double values.
Thirty two bit signed integer (qint32)
bool isValid() const
Returns true if the block is valid (correctly filled with data).
static double readValue(void *data, Qgis::DataType type, qgssize index)
Qgis::DataType dataType() const
Returns data type.
int height() const
Returns the height (number of rows) of the raster block.
Thirty two bit unsigned integer (quint32)
DataType
Raster data types.
Thirty two bit floating point (float)
Sixteen bit signed integer (qint16)
bool qgsDoubleNear(double a, double b, double epsilon=4 *DBL_EPSILON)
Compare two doubles (but allow some difference)
Sixty four bit floating point (double)
QgsError error() const
Get error.
Color, alpha, red, green, blue, 4 bytes the same as QImage::Format_ARGB32_Premultiplied.
void setError(const QgsError &error)
Set error.
Unknown or unspecified type.
static int typeSize(int dataType)
Sixteen bit unsigned integer (quint16)
unsigned long long qgssize
Qgssize is used instead of size_t, because size_t is stdlib type, unknown by SIP, and it would be har...
int width() const
Returns the width (number of columns) of the raster block.
void setValid(bool valid)
Mark block as valid or invalid.
static void writeValue(void *data, Qgis::DataType type, qgssize index, double value)
QList< QgsRasterRange > QgsRasterRangeList
QgsError is container for error messages (report).
double value(int row, int column) const
Read a single value if type of block is numeric.
bool hasNoDataValue() const
True if the block has no data value.
double noDataValue() const
Return no data value.
Eight bit unsigned integer (quint8)
Color, alpha, red, green, blue, 4 bytes the same as QImage::Format_ARGB32.