18 #ifndef QGSRASTERBLOCK_H 19 #define QGSRASTERBLOCK_H 62 bool reset(
QGis::DataType theDataType,
int theWidth,
int theHeight );
71 bool reset(
QGis::DataType theDataType,
int theWidth,
int theHeight,
double theNoDataValue );
82 void setValid(
bool valid ) { mValid = valid; }
129 return typeSize( mDataType );
152 bool hasNoData()
const;
163 static QByteArray valueBytes(
QGis::DataType theDataType,
double theValue );
170 double value(
int row,
int column )
const;
182 QRgb color(
int row,
int column )
const;
187 QRgb color(
qgssize index )
const;
193 bool isNoData(
int row,
int column );
198 bool isNoData(
qgssize index );
205 bool setValue(
int row,
int column,
double value );
211 bool setValue(
qgssize index,
double value );
218 bool setColor(
int row,
int column, QRgb color );
224 bool setColor(
qgssize index, QRgb color );
230 bool setIsNoData(
int row,
int column );
235 bool setIsNoData(
qgssize index );
243 bool setIsNoDataExcept(
const QRect & theExceptRect );
252 void setIsData(
int row,
int column );
260 void setIsData(
qgssize index );
268 char * bits(
int row,
int column );
287 static QString printValue(
double value );
296 QImage image()
const;
301 bool setImage(
const QImage * image );
313 void applyScaleOffset(
double scale,
double offset );
330 static QRect subRect(
const QgsRectangle &theExtent,
int theWidth,
int theHeight,
const QgsRectangle &theSubExtent );
340 static bool isNoDataValue(
double value,
double noDataValue );
345 bool isNoDataValue(
double value )
const;
349 bool createNoDataBitmap();
376 bool mHasNoDataValue;
381 static const QRgb mNoDataColor;
396 int mNoDataBitmapWidth;
409 return std::numeric_limits<double>::quiet_NaN();
415 return (
double )(( quint8 * )data )[
index];
418 return (
double )(( quint16 * )data )[
index];
421 return (
double )(( qint16 * )data )[
index];
424 return (
double )(( quint32 * )data )[
index];
427 return (
double )(( qint32 * )data )[
index];
430 return (
double )((
float * )data )[
index];
433 return (
double )((
double * )data )[
index];
436 QgsDebugMsg( QString(
"Data type %1 is not supported" ).arg( type ) );
440 return std::numeric_limits<double>::quiet_NaN();
450 (( quint8 * )data )[
index] = ( quint8 ) value;
453 (( quint16 * )data )[
index] = ( quint16 ) value;
456 (( qint16 * )data )[
index] = ( qint16 ) value;
459 (( quint32 * )data )[
index] = ( quint32 ) value;
462 (( qint32 * )data )[
index] = ( qint32 ) value;
465 ((
float * )data )[
index] = ( float ) value;
468 ((
double * )data )[
index] = value;
471 QgsDebugMsg( QString(
"Data type %1 is not supported" ).arg( type ) );
481 return std::numeric_limits<double>::quiet_NaN();
483 return readValue( mData, mDataType, index );
486 inline bool QgsRasterBlock::isNoDataValue(
double value )
const 488 return qIsNaN( value ) ||
qgsDoubleNear( value, mNoDataValue );
A rectangle specified with double values.
bool isValid() const
Returns true if the block is valid (correctly filled with data).
void setError(const QgsError &theError)
Set error.
double noDataValue() const
Return no data value.
QGis::DataType dataType() const
Returns data type.
bool qgsDoubleNear(double a, double b, double epsilon=4 *DBL_EPSILON)
double value(int row, int column) const
Read a single value if type of block is numeric.
static int typeSize(int dataType)
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...
static void writeValue(void *data, QGis::DataType type, qgssize index, double value)
void setValid(bool valid)
Mark block as valid or invalid.
bool hasNoDataValue() const
True if the block has no data value.
QList< QgsRasterRange > QgsRasterRangeList
QgsError is container for error messages (report).
DataType
Raster data types.
static double readValue(void *data, QGis::DataType type, qgssize index)
QgsError error() const
Get error.