diff --git a/alg/gdalcutline.cpp b/alg/gdalcutline.cpp index 258a6691c3fc..2ba8a4fdac2c 100644 --- a/alg/gdalcutline.cpp +++ b/alg/gdalcutline.cpp @@ -338,9 +338,9 @@ CPLErr GDALWarpCutlineMaskerEx(void *pMaskFuncArg, int /* nBandCount */, GByte *pabyPolyMask = static_cast(CPLCalloc(nXSize, nYSize)); auto poMEMDS = - MEMDataset::Create("warp_temp", nXSize, nYSize, 0, GDT_Byte, nullptr); + MEMDataset::Create("warp_temp", nXSize, nYSize, 0, GDT_UInt8, nullptr); GDALRasterBandH hMEMBand = - MEMCreateRasterBandEx(poMEMDS, 1, pabyPolyMask, GDT_Byte, 0, 0, false); + MEMCreateRasterBandEx(poMEMDS, 1, pabyPolyMask, GDT_UInt8, 0, 0, false); poMEMDS->AddMEMBand(hMEMBand); GDALDatasetH hMemDS = GDALDataset::ToHandle(poMEMDS); diff --git a/alg/gdaldither.cpp b/alg/gdaldither.cpp index 9e1a5e48b6ef..0907750b48c6 100644 --- a/alg/gdaldither.cpp +++ b/alg/gdaldither.cpp @@ -352,13 +352,13 @@ int GDALDitherRGB2PCTInternal( /* -------------------------------------------------------------------- */ CPLErr err1 = GDALRasterIO(hRed, GF_Read, 0, iScanline, nXSize, 1, - pabyRed, nXSize, 1, GDT_Byte, 0, 0); + pabyRed, nXSize, 1, GDT_UInt8, 0, 0); if (err1 == CE_None) err1 = GDALRasterIO(hGreen, GF_Read, 0, iScanline, nXSize, 1, - pabyGreen, nXSize, 1, GDT_Byte, 0, 0); + pabyGreen, nXSize, 1, GDT_UInt8, 0, 0); if (err1 == CE_None) err1 = GDALRasterIO(hBlue, GF_Read, 0, iScanline, nXSize, 1, - pabyBlue, nXSize, 1, GDT_Byte, 0, 0); + pabyBlue, nXSize, 1, GDT_UInt8, 0, 0); if (err1 != CE_None) { CPLFree(pabyRed); @@ -559,7 +559,7 @@ int GDALDitherRGB2PCTInternal( /* -------------------------------------------------------------------- */ err = GDALRasterIO(hTarget, GF_Write, 0, iScanline, nXSize, 1, - pabyIndex, nXSize, 1, GDT_Byte, 0, 0); + pabyIndex, nXSize, 1, GDT_UInt8, 0, 0); if (err != CE_None) break; } diff --git a/alg/gdalmediancut.cpp b/alg/gdalmediancut.cpp index cb9415e92473..5336a8977fe0 100644 --- a/alg/gdalmediancut.cpp +++ b/alg/gdalmediancut.cpp @@ -445,13 +445,13 @@ int GDALComputeMedianCutPCTInternal( } err = GDALRasterIO(hRed, GF_Read, 0, iLine, nXSize, 1, pabyRedLine, - nXSize, 1, GDT_Byte, 0, 0); + nXSize, 1, GDT_UInt8, 0, 0); if (err == CE_None) err = GDALRasterIO(hGreen, GF_Read, 0, iLine, nXSize, 1, - pabyGreenLine, nXSize, 1, GDT_Byte, 0, 0); + pabyGreenLine, nXSize, 1, GDT_UInt8, 0, 0); if (err == CE_None) err = GDALRasterIO(hBlue, GF_Read, 0, iLine, nXSize, 1, - pabyBlueLine, nXSize, 1, GDT_Byte, 0, 0); + pabyBlueLine, nXSize, 1, GDT_UInt8, 0, 0); if (err != CE_None) goto end_and_cleanup; diff --git a/alg/gdalpansharpen.cpp b/alg/gdalpansharpen.cpp index b08a2cefbd65..cb9c211c8a58 100644 --- a/alg/gdalpansharpen.cpp +++ b/alg/gdalpansharpen.cpp @@ -359,7 +359,7 @@ GDALPansharpenOperation::Initialize(const GDALPansharpenOptions *psOptionsIn) if (psOptionsIn->nBitDepth) { if (psOptionsIn->nBitDepth < 0 || psOptionsIn->nBitDepth > 31 || - (eWorkDataType == GDT_Byte && psOptionsIn->nBitDepth > 8) || + (eWorkDataType == GDT_UInt8 && psOptionsIn->nBitDepth > 8) || (eWorkDataType == GDT_UInt16 && psOptionsIn->nBitDepth > 16)) { CPLError(CE_Failure, CPLE_AppDefined, @@ -374,7 +374,7 @@ GDALPansharpenOperation::Initialize(const GDALPansharpenOptions *psOptionsIn) if (psOptions->nBitDepth == GDALGetDataTypeSizeBits(eWorkDataType)) psOptions->nBitDepth = 0; if (psOptions->nBitDepth && - !(eWorkDataType == GDT_Byte || eWorkDataType == GDT_UInt16 || + !(eWorkDataType == GDT_UInt8 || eWorkDataType == GDT_UInt16 || eWorkDataType == GDT_UInt32 || eWorkDataType == GDT_UInt64)) { CPLError(CE_Warning, CPLE_AppDefined, @@ -953,7 +953,7 @@ CPLErr GDALPansharpenOperation::WeightedBrovey( { switch (eBufDataType) { - case GDT_Byte: + case GDT_UInt8: WeightedBrovey(pPanBuffer, pUpsampledSpectralBuffer, static_cast(pDataBuf), nValues, nBandValues, nMaxValue); @@ -1039,7 +1039,7 @@ CPLErr GDALPansharpenOperation::WeightedBrovey( { switch (eBufDataType) { - case GDT_Byte: + case GDT_UInt8: WeightedBrovey3( pPanBuffer, pUpsampledSpectralBuffer, static_cast(pDataBuf), nValues, nBandValues, 0); @@ -1171,7 +1171,7 @@ CPLErr GDALPansharpenOperation::ProcessRegion(int nXOff, int nYOff, int nXSize, GDALRasterBand::FromHandle(psOptions->hPanchroBand); GDALDataType eWorkDataType = poPanchroBand->GetRasterDataType(); #ifdef LIMIT_TYPES - if (eWorkDataType != GDT_Byte && eWorkDataType != GDT_UInt16) + if (eWorkDataType != GDT_UInt8 && eWorkDataType != GDT_UInt16) eWorkDataType = GDT_Float64; #endif const int nDataTypeSize = GDALGetDataTypeSizeBytes(eWorkDataType); @@ -1495,7 +1495,7 @@ CPLErr GDALPansharpenOperation::ProcessRegion(int nXOff, int nYOff, int nXSize, nBandBitDepth = atoi(pszNBITS); if (nBandBitDepth < nBitDepth) { - if (eWorkDataType == GDT_Byte && nBitDepth >= 0 && + if (eWorkDataType == GDT_UInt8 && nBitDepth >= 0 && nBitDepth <= 8) { ClampValues( @@ -1535,7 +1535,7 @@ CPLErr GDALPansharpenOperation::ProcessRegion(int nXOff, int nYOff, int nXSize, void *pDataBufOri = pDataBuf; // CFloat64 is the query type used by gdallocationinfo... #ifdef LIMIT_TYPES - if (eBufDataType != GDT_Byte && eBufDataType != GDT_UInt16) + if (eBufDataType != GDT_UInt8 && eBufDataType != GDT_UInt16) #else if (eBufDataType == GDT_CFloat64) #endif @@ -1735,7 +1735,7 @@ CPLErr GDALPansharpenOperation::PansharpenChunk( switch (eWorkDataType) { - case GDT_Byte: + case GDT_UInt8: eErr = WeightedBrovey( static_cast(pPanBuffer), static_cast(pUpsampledSpectralBuffer), pDataBuf, diff --git a/alg/gdalproximity.cpp b/alg/gdalproximity.cpp index ab638c45aaac..7c41129e3863 100644 --- a/alg/gdalproximity.cpp +++ b/alg/gdalproximity.cpp @@ -252,7 +252,7 @@ CPLErr CPL_STDCALL GDALComputeProximity(GDALRasterBandH hSrcBand, GInt32 *panSrcScanline = nullptr; bool bTempFileAlreadyDeleted = false; - if (eProxType == GDT_Byte || eProxType == GDT_UInt16 || + if (eProxType == GDT_UInt8 || eProxType == GDT_UInt16 || eProxType == GDT_UInt32) { GDALDriverH hDriver = GDALGetDriverByName("GTiff"); diff --git a/alg/gdalrasterize.cpp b/alg/gdalrasterize.cpp index 52523f5045e2..a11421163ac9 100644 --- a/alg/gdalrasterize.cpp +++ b/alg/gdalrasterize.cpp @@ -216,7 +216,7 @@ static void gvBurnScanline(GDALRasterizeInfo *psInfo, int nY, int nXStart, switch (psInfo->eType) { - case GDT_Byte: + case GDT_UInt8: gvBurnScanlineBasic(psInfo, nY, nXStart, nXEnd, dfVariant); break; case GDT_Int8: @@ -350,7 +350,7 @@ static void gvBurnPoint(GDALRasterizeInfo *psInfo, int nY, int nX, switch (psInfo->eType) { - case GDT_Byte: + case GDT_UInt8: gvBurnPointBasic(psInfo, nY, nX, dfVariant); break; case GDT_Int8: @@ -937,7 +937,7 @@ static CPLErr GDALRasterizeGeometriesInternal( * int nBufXSize = 1024; * int nBufYSize = 1024; * int nBandCount = 1; - * GDALDataType eType = GDT_Byte; + * GDALDataType eType = GDT_UInt8; * int nDataTypeSize = GDALGetDataTypeSizeBytes(eType); * * void* pData = CPLCalloc( nBufXSize*nBufYSize*nBandCount, nDataTypeSize ); @@ -1263,7 +1263,7 @@ static CPLErr GDALRasterizeGeometriesInternal( const int nYBlocks = DIV_ROUND_UP(poBand->GetYSize(), nYBlockSize); const GDALDataType eType = - poBand->GetRasterDataType() == GDT_Byte ? GDT_Byte : GDT_Float64; + poBand->GetRasterDataType() == GDT_UInt8 ? GDT_UInt8 : GDT_Float64; const int nPixelSize = nBandCount * GDALGetDataTypeSizeBytes(eType); diff --git a/alg/gdalsievefilter.cpp b/alg/gdalsievefilter.cpp index 1abbad62266e..77149dd2db3a 100644 --- a/alg/gdalsievefilter.cpp +++ b/alg/gdalsievefilter.cpp @@ -61,7 +61,7 @@ static CPLErr GPMaskImageData(GDALRasterBandH hMaskBand, GByte *pabyMaskLine, { const CPLErr eErr = GDALRasterIO(hMaskBand, GF_Read, 0, iY, nXSize, 1, - pabyMaskLine, nXSize, 1, GDT_Byte, 0, 0); + pabyMaskLine, nXSize, 1, GDT_UInt8, 0, 0); if (eErr == CE_None) { for (int i = 0; i < nXSize; i++) diff --git a/alg/gdalsimplewarp.cpp b/alg/gdalsimplewarp.cpp index f35ad7ac82f1..10148d4c6e13 100644 --- a/alg/gdalsimplewarp.cpp +++ b/alg/gdalsimplewarp.cpp @@ -281,7 +281,7 @@ int CPL_STDCALL GDALSimpleImageWarp(GDALDatasetH hSrcDS, GDALDatasetH hDstDS, if (GDALRasterIO(GDALGetRasterBand(hSrcDS, panBandList[iBand]), GF_Read, 0, 0, nSrcXSize, nSrcYSize, apabySrcDataUniquePtr[iBand].get(), nSrcXSize, - nSrcYSize, GDT_Byte, 0, 0) != CE_None) + nSrcYSize, GDT_UInt8, 0, 0) != CE_None) { CPLError(CE_Failure, CPLE_FileIO, "GDALSimpleImageWarp GDALRasterIO failure %s", @@ -369,7 +369,7 @@ int CPL_STDCALL GDALSimpleImageWarp(GDALDatasetH hSrcDS, GDALDatasetH hDstDS, if (GDALRasterIO(GDALGetRasterBand(hDstDS, iBand + 1), GF_Read, 0, iDstY, nDstXSize, 1, apabyDstLine[iBand].get(), nDstXSize, 1, - GDT_Byte, 0, 0) != CE_None) + GDT_UInt8, 0, 0) != CE_None) { return FALSE; } @@ -423,7 +423,7 @@ int CPL_STDCALL GDALSimpleImageWarp(GDALDatasetH hSrcDS, GDALDatasetH hDstDS, { if (GDALRasterIO(GDALGetRasterBand(hDstDS, iBand + 1), GF_Write, 0, iDstY, nDstXSize, 1, apabyDstLine[iBand].get(), - nDstXSize, 1, GDT_Byte, 0, 0) != CE_None) + nDstXSize, 1, GDT_UInt8, 0, 0) != CE_None) { return FALSE; } diff --git a/alg/gdalwarper.cpp b/alg/gdalwarper.cpp index 32b0cb57373f..c00e923dc12b 100644 --- a/alg/gdalwarper.cpp +++ b/alg/gdalwarper.cpp @@ -366,7 +366,7 @@ CPLErr GDALWarpNoDataMasker(void *pMaskFuncArg, int nBandCount, switch (eType) { - case GDT_Byte: + case GDT_UInt8: return GDALWarpNoDataMaskerT(padfNoData, nPixels, *ppImageData, // Already a GByte *. panValidityMask, pbOutAllValid); @@ -540,7 +540,7 @@ CPLErr GDALWarpSrcAlphaMasker(void *pMaskFuncArg, int /* nBandCount */, GDALDataType eDT = GDALGetRasterDataType(hAlphaBand); // Make sure that pafMask is at least 8-byte aligned, which should // normally be always the case if being a ptr returned by malloc(). - if ((eDT == GDT_Byte || eDT == GDT_UInt16) && CPL_IS_ALIGNED(pafMask, 8)) + if ((eDT == GDT_UInt8 || eDT == GDT_UInt16) && CPL_IS_ALIGNED(pafMask, 8)) { // Read data. eErr = GDALRasterIOEx( @@ -554,7 +554,7 @@ CPLErr GDALWarpSrcAlphaMasker(void *pMaskFuncArg, int /* nBandCount */, // Make sure we have the correct alignment before doing SSE // On Linux x86_64, the alignment should be always correct due // the alignment of malloc() being 16 byte. - const GUInt32 mask = (eDT == GDT_Byte) ? 0xff : 0xffff; + const GUInt32 mask = (eDT == GDT_UInt8) ? 0xff : 0xffff; if (!CPL_IS_ALIGNED(pafMask, 16)) { pafMask[iPixel] = @@ -752,7 +752,7 @@ CPLErr GDALWarpSrcMaskMasker(void *pMaskFuncArg, int /* nBandCount */, /* Read the mask band. */ /* -------------------------------------------------------------------- */ CPLErr eErr = GDALRasterIO(hMaskBand, GF_Read, nXOff, nYOff, nXSize, nYSize, - pabySrcMask, nXSize, nYSize, GDT_Byte, 0, 0); + pabySrcMask, nXSize, nYSize, GDT_UInt8, 0, 0); if (eErr != CE_None) { @@ -840,7 +840,7 @@ CPLErr GDALWarpDstAlphaMasker(void *pMaskFuncArg, int nBandCount, const GDALDataType eDT = GDALGetRasterDataType(hAlphaBand); // Make sure that pafMask is at least 8-byte aligned, which should // normally be always the case if being a ptr returned by malloc(). - if ((eDT == GDT_Byte || eDT == GDT_UInt16) && + if ((eDT == GDT_UInt8 || eDT == GDT_UInt16) && CPL_IS_ALIGNED(pafMask, 8)) { // Read data. @@ -855,7 +855,7 @@ CPLErr GDALWarpDstAlphaMasker(void *pMaskFuncArg, int nBandCount, // Make sure we have the correct alignment before doing SSE // On Linux x86_64, the alignment should be always correct due // the alignment of malloc() being 16 byte. - const GUInt32 mask = (eDT == GDT_Byte) ? 0xff : 0xffff; + const GUInt32 mask = (eDT == GDT_UInt8) ? 0xff : 0xffff; if (!CPL_IS_ALIGNED(pafMask, 16)) { pafMask[iPixel] = @@ -958,7 +958,7 @@ CPLErr GDALWarpDstAlphaMasker(void *pMaskFuncArg, int nBandCount, const float cst_alpha_max = static_cast(CPLAtof(CSLFetchNameValueDef( psWO->papszWarpOptions, "DST_ALPHA_MAX", "255"))) + - ((eDT == GDT_Byte || eDT == GDT_Int16 || eDT == GDT_UInt16 || + ((eDT == GDT_UInt8 || eDT == GDT_Int16 || eDT == GDT_UInt16 || eDT == GDT_Int32 || eDT == GDT_UInt32) ? 0.1f : 0.0f); @@ -968,7 +968,7 @@ CPLErr GDALWarpDstAlphaMasker(void *pMaskFuncArg, int nBandCount, #if (defined(__x86_64) || defined(_M_X64)) // Make sure that pafMask is at least 8-byte aligned, which should // normally be always the case if being a ptr returned by malloc() - if ((eDT == GDT_Byte || eDT == GDT_Int16 || eDT == GDT_UInt16) && + if ((eDT == GDT_UInt8 || eDT == GDT_Int16 || eDT == GDT_UInt16) && CPL_IS_ALIGNED(pafMask, 8)) { // Make sure we have the correct alignment before doing SSE @@ -1756,7 +1756,7 @@ void CPL_STDCALL GDALWarpResolveWorkingDataType(GDALWarpOptions *psOptions) return; } - psOptions->eWorkingDataType = GDT_Byte; + psOptions->eWorkingDataType = GDT_UInt8; // If none of the provided input nodata values can be represented in the // data type of the corresponding source band, ignore them. diff --git a/alg/gdalwarpkernel.cpp b/alg/gdalwarpkernel.cpp index 727cd6dd13fc..b117ad3d6b2b 100644 --- a/alg/gdalwarpkernel.cpp +++ b/alg/gdalwarpkernel.cpp @@ -585,7 +585,7 @@ static CPLErr GWKRun(GDALWarpKernel *poWK, const char *pszFuncName, * any data type (working internally in double precision complex), all three * resampling types, and any or all of the validity/density masks. At the * other end would be highly optimized algorithms for common cases like - * nearest neighbour resampling on GDT_Byte data with no masks. + * nearest neighbour resampling on GDT_UInt8 data with no masks. * * The full set of optimized versions have not been decided but we should * expect to have at least: @@ -634,7 +634,7 @@ static CPLErr GWKRun(GDALWarpKernel *poWK, const char *pszFuncName, * * The datatype of pixels in the source image (papabySrcimage) and * destination image (papabyDstImage) buffers. Note that operations on - * some data types (such as GDT_Byte) may be much better optimized than other + * some data types (such as GDT_UInt8) may be much better optimized than other * less common cases. * * This field is required. It may not be GDT_Unknown. @@ -1206,23 +1206,23 @@ CPLErr GDALWarpKernel::PerformWarp() papanBandSrcValid == nullptr && panUnifiedSrcValid == nullptr && pafUnifiedSrcDensity == nullptr && panDstValid == nullptr; - if (eWorkingDataType == GDT_Byte && eResample == GRA_NearestNeighbour && + if (eWorkingDataType == GDT_UInt8 && eResample == GRA_NearestNeighbour && bNoMasksOrDstDensityOnly) return GWKNearestNoMasksOrDstDensityOnlyByte(this); - if (eWorkingDataType == GDT_Byte && eResample == GRA_Bilinear && + if (eWorkingDataType == GDT_UInt8 && eResample == GRA_Bilinear && bNoMasksOrDstDensityOnly) return GWKBilinearNoMasksOrDstDensityOnlyByte(this); - if (eWorkingDataType == GDT_Byte && eResample == GRA_Cubic && + if (eWorkingDataType == GDT_UInt8 && eResample == GRA_Cubic && bNoMasksOrDstDensityOnly) return GWKCubicNoMasksOrDstDensityOnlyByte(this); - if (eWorkingDataType == GDT_Byte && eResample == GRA_CubicSpline && + if (eWorkingDataType == GDT_UInt8 && eResample == GRA_CubicSpline && bNoMasksOrDstDensityOnly) return GWKCubicSplineNoMasksOrDstDensityOnlyByte(this); - if (eWorkingDataType == GDT_Byte && eResample == GRA_NearestNeighbour) + if (eWorkingDataType == GDT_UInt8 && eResample == GRA_NearestNeighbour) return GWKNearestByte(this); if ((eWorkingDataType == GDT_Int16 || eWorkingDataType == GDT_UInt16) && @@ -1661,7 +1661,7 @@ static bool GWKSetPixelValue(const GDALWarpKernel *poWK, int iBand, // TODO(schwehr): Factor out this repreated type of set. switch (poWK->eWorkingDataType) { - case GDT_Byte: + case GDT_UInt8: dfDstReal = pabyDst[iDstOffset]; dfDstImag = 0.0; break; @@ -1777,7 +1777,7 @@ static bool GWKSetPixelValue(const GDALWarpKernel *poWK, int iBand, switch (poWK->eWorkingDataType) { - case GDT_Byte: + case GDT_UInt8: ClampRoundAndAvoidNoData(poWK, iBand, iDstOffset, dfReal); break; @@ -1936,7 +1936,7 @@ static bool GWKSetPixelValueReal(const GDALWarpKernel *poWK, int iBand, switch (poWK->eWorkingDataType) { - case GDT_Byte: + case GDT_UInt8: dfDstReal = pabyDst[iDstOffset]; break; @@ -2011,7 +2011,7 @@ static bool GWKSetPixelValueReal(const GDALWarpKernel *poWK, int iBand, switch (poWK->eWorkingDataType) { - case GDT_Byte: + case GDT_UInt8: ClampRoundAndAvoidNoData(poWK, iBand, iDstOffset, dfReal); break; @@ -2100,7 +2100,7 @@ static bool GWKGetPixelValue(const GDALWarpKernel *poWK, int iBand, // TODO(schwehr): Fix casting. switch (poWK->eWorkingDataType) { - case GDT_Byte: + case GDT_UInt8: *pdfReal = pabySrc[iSrcOffset]; *pdfImag = 0.0; break; @@ -2221,7 +2221,7 @@ static bool GWKGetPixelValueReal(const GDALWarpKernel *poWK, int iBand, switch (poWK->eWorkingDataType) { - case GDT_Byte: + case GDT_UInt8: *pdfReal = pabySrc[iSrcOffset]; break; @@ -2362,7 +2362,7 @@ static bool GWKGetPixelRow(const GDALWarpKernel *poWK, int iBand, // Fetch data. switch (poWK->eWorkingDataType) { - case GDT_Byte: + case GDT_UInt8: { GByte *pSrc = reinterpret_cast(poWK->papabySrcImage[iBand]); @@ -4245,7 +4245,7 @@ static bool GWKResampleOptimizedLanczos(const GDALWarpKernel *poWK, int iBand, // Loop over pixel rows in the kernel. - if (poWK->eWorkingDataType == GDT_Byte && !poWK->panUnifiedSrcValid && + if (poWK->eWorkingDataType == GDT_UInt8 && !poWK->panUnifiedSrcValid && !poWK->papanBandSrcValid && !poWK->pafUnifiedSrcDensity && !padfRowDensity) { @@ -5708,7 +5708,7 @@ static void GWKRealCaseThread(void *pData) { if (bSrcMaskIsDensity) { - if (poWK->eWorkingDataType == GDT_Byte) + if (poWK->eWorkingDataType == GDT_UInt8) { GWKCubicResampleSrcMaskIsDensity4SampleRealT( poWK, iBand, padfX[iDstX] - poWK->nSrcXOff, @@ -7265,7 +7265,7 @@ static void GWKAverageOrModeThread(void *pData) switch (poWK->eWorkingDataType) { - case GDT_Byte: + case GDT_UInt8: nBins = 256; break; diff --git a/alg/gdalwarpoperation.cpp b/alg/gdalwarpoperation.cpp index 49c605039801..a5b0b45bb80c 100644 --- a/alg/gdalwarpoperation.cpp +++ b/alg/gdalwarpoperation.cpp @@ -859,7 +859,7 @@ CPLErr GDALWarpOperation::InitializeDestinationBuffer(void *pDstBuffer, GByte *pBandData = static_cast(pDstBuffer) + iBand * nBandSize; - if (psOptions->eWorkingDataType == GDT_Byte) + if (psOptions->eWorkingDataType == GDT_UInt8) { memset(pBandData, std::max( diff --git a/alg/polygonize.cpp b/alg/polygonize.cpp index 71f0c1cc9218..a925687b421c 100644 --- a/alg/polygonize.cpp +++ b/alg/polygonize.cpp @@ -52,7 +52,7 @@ static CPLErr GPMaskImageData(GDALRasterBandH hMaskBand, GByte *pabyMaskLine, { const CPLErr eErr = GDALRasterIO(hMaskBand, GF_Read, 0, iY, nXSize, 1, - pabyMaskLine, nXSize, 1, GDT_Byte, 0, 0); + pabyMaskLine, nXSize, 1, GDT_UInt8, 0, 0); if (eErr != CE_None) return eErr; diff --git a/alg/rasterfill.cpp b/alg/rasterfill.cpp index 54156411bb13..fa168dca48d6 100644 --- a/alg/rasterfill.cpp +++ b/alg/rasterfill.cpp @@ -218,14 +218,14 @@ static CPLErr GDALMultiFilter(GDALRasterBandH hTargetBand, { eErr = GDALRasterIO(hTargetMaskBand, GF_Read, 0, nNewLine, nXSize, 1, pabyTMaskBuf + nXSize * iBufOffset, nXSize, - 1, GDT_Byte, 0, 0); + 1, GDT_UInt8, 0, 0); if (eErr != CE_None) break; eErr = GDALRasterIO(hFiltMaskBand, GF_Read, 0, nNewLine, nXSize, 1, pabyFMaskBuf + nXSize * iBufOffset, nXSize, 1, - GDT_Byte, 0, 0); + GDT_UInt8, 0, 0); if (eErr != CE_None) break; @@ -477,7 +477,7 @@ CPLErr CPL_STDCALL GDALFillNodata(GDALRasterBandH hTargetBand, // when we fill pixels during the initial pass. const CPLString osMaskTmpFile = osTmpFile + "fill_mask_work.tif"; poTmpMaskDS.reset(GDALDataset::FromHandle( - GDALCreate(hDriver, osMaskTmpFile, nXSize, nYSize, 1, GDT_Byte, + GDALCreate(hDriver, osMaskTmpFile, nXSize, nYSize, 1, GDT_UInt8, aosWorkFileOptions.List()))); if (poTmpMaskDS == nullptr) { @@ -572,7 +572,7 @@ CPLErr CPL_STDCALL GDALFillNodata(GDALRasterBandH hTargetBand, const CPLString osFiltMaskTmpFile = osTmpFile + "fill_filtmask_work.tif"; auto poFiltMaskDS = std::unique_ptr(GDALDataset::FromHandle( - GDALCreate(hDriver, osFiltMaskTmpFile, nXSize, nYSize, 1, GDT_Byte, + GDALCreate(hDriver, osFiltMaskTmpFile, nXSize, nYSize, 1, GDT_UInt8, aosWorkFileOptions.List()))); if (poFiltMaskDS == nullptr) @@ -637,7 +637,7 @@ CPLErr CPL_STDCALL GDALFillNodata(GDALRasterBandH hTargetBand, /* -------------------------------------------------------------------- */ eErr = GDALRasterIO(hMaskBand, GF_Read, 0, iY, nXSize, 1, pabyMask, - nXSize, 1, GDT_Byte, 0, 0); + nXSize, 1, GDT_UInt8, 0, 0); if (eErr != CE_None) break; @@ -722,7 +722,7 @@ CPLErr CPL_STDCALL GDALFillNodata(GDALRasterBandH hTargetBand, for (int iY = nYSize - 1; iY >= 0 && eErr == CE_None; iY--) { eErr = GDALRasterIO(hMaskBand, GF_Read, 0, iY, nXSize, 1, pabyMask, - nXSize, 1, GDT_Byte, 0, 0); + nXSize, 1, GDT_UInt8, 0, 0); if (eErr != CE_None) break; @@ -930,14 +930,14 @@ CPLErr CPL_STDCALL GDALFillNodata(GDALRasterBandH hTargetBand, // Update (copy of) mask band when it has been provided by the // user eErr = GDALRasterIO(hMaskBand, GF_Write, 0, iY, nXSize, 1, pabyMask, - nXSize, 1, GDT_Byte, 0, 0); + nXSize, 1, GDT_UInt8, 0, 0); if (eErr != CE_None) break; } eErr = GDALRasterIO(hFiltMaskBand, GF_Write, 0, iY, nXSize, 1, - pabyFiltMask, nXSize, 1, GDT_Byte, 0, 0); + pabyFiltMask, nXSize, 1, GDT_UInt8, 0, 0); if (eErr != CE_None) break; diff --git a/alg/viewshed/cumulative.cpp b/alg/viewshed/cumulative.cpp index 7567b57d2025..a410a000973d 100644 --- a/alg/viewshed/cumulative.cpp +++ b/alg/viewshed/cumulative.cpp @@ -146,7 +146,7 @@ void Cumulative::runExecutor(const std::string &srcFilename, Progress &progress, while (!err && m_observerQueue.pop(loc)) { DatasetPtr dstDs(MEMDataset::Create( - "", m_extent.xSize(), m_extent.ySize(), 1, GDT_Byte, nullptr)); + "", m_extent.xSize(), m_extent.ySize(), 1, GDT_UInt8, nullptr)); if (!dstDs) { err = true; diff --git a/alg/viewshed/util.cpp b/alg/viewshed/util.cpp index 77b6662e6dbe..7532492adedd 100644 --- a/alg/viewshed/util.cpp +++ b/alg/viewshed/util.cpp @@ -211,7 +211,7 @@ DatasetPtr createOutputDataset(GDALRasterBand &srcBand, const Options &opts, /* create output raster */ DatasetPtr dataset(hDriver->Create( opts.outputFilename.c_str(), extent.xSize(), extent.ySize(), 1, - opts.outputMode == OutputMode::Normal ? GDT_Byte : GDT_Float64, + opts.outputMode == OutputMode::Normal ? GDT_UInt8 : GDT_Float64, const_cast(opts.creationOpts.List()))); if (!dataset) { diff --git a/alg/zonal.cpp b/alg/zonal.cpp index 7cbaacd30b4f..eeb694a516c6 100644 --- a/alg/zonal.cpp +++ b/alg/zonal.cpp @@ -296,7 +296,7 @@ class GDALZonalStatsImpl : m_src(src), m_weights(weights), m_dst(dst), m_zones(zones), m_coverageDataType(options.pixels == GDALZonalStatsOptions::FRACTIONAL ? GDT_Float32 - : GDT_Byte), + : GDT_UInt8), m_options(options), m_maxCells(options.memory / std::max(1, GDALGetDataTypeSizeBytes(m_workingDataType))) @@ -1187,7 +1187,7 @@ class GDALZonalStatsImpl return false; } if (!ReadWindow(*poWeightsBand->GetMaskBand(), oWindow, - m_pabyWeightsMaskBuf.get(), GDT_Byte)) + m_pabyWeightsMaskBuf.get(), GDT_UInt8)) { return false; } @@ -1454,7 +1454,7 @@ class GDALZonalStatsImpl return false; } if (!ReadWindow(*poWeightsBand->GetMaskBand(), oChunkWindow, - m_pabyWeightsMaskBuf.get(), GDT_Byte)) + m_pabyWeightsMaskBuf.get(), GDT_UInt8)) { return false; } @@ -1785,7 +1785,7 @@ class GDALZonalStatsImpl } if (!ReadWindow(*poWeightsBand->GetMaskBand(), oSubWindow, m_pabyWeightsMaskBuf.get(), - GDT_Byte)) + GDT_UInt8)) { return false; } @@ -1966,7 +1966,7 @@ class GDALZonalStatsImpl const GDALDataType m_coverageDataType; const GDALDataType m_workingDataType = GDT_Float64; - const GDALDataType m_maskDataType = GDT_Byte; + const GDALDataType m_maskDataType = GDT_UInt8; static constexpr GDALDataType m_zonesDataType = GDT_Float64; GDALGeoTransform m_srcGT{}; diff --git a/apps/gdal_create.cpp b/apps/gdal_create.cpp index c8af9dd4214c..013f7a5f68c0 100644 --- a/apps/gdal_create.cpp +++ b/apps/gdal_create.cpp @@ -392,7 +392,7 @@ MAIN_START(argc, argv) if (sOptions.nPixels != 0 && sOptions.eDT == GDT_Unknown) { - sOptions.eDT = GDT_Byte; + sOptions.eDT = GDT_UInt8; } if (sOptions.nBandCount < 0) { diff --git a/apps/gdal_footprint_lib.cpp b/apps/gdal_footprint_lib.cpp index 7a25518a15b9..dc2e45f7f489 100644 --- a/apps/gdal_footprint_lib.cpp +++ b/apps/gdal_footprint_lib.cpp @@ -287,7 +287,7 @@ class GDALFootprintMaskBand final : public GDALRasterBand { nRasterXSize = m_poSrcBand->GetXSize(); nRasterYSize = m_poSrcBand->GetYSize(); - eDataType = GDT_Byte; + eDataType = GDT_UInt8; m_poSrcBand->GetBlockSize(&nBlockXSize, &nBlockYSize); } @@ -312,7 +312,7 @@ CPLErr GDALFootprintMaskBand::IReadBlock(int nBlockXOff, int nBlockYOff, INIT_RASTERIO_EXTRA_ARG(sExtraArg); return IRasterIO(GF_Read, nBlockXOff * nBlockXSize, nBlockYOff * nBlockYSize, nWindowXSize, nWindowYSize, - pData, nWindowXSize, nWindowYSize, GDT_Byte, 1, + pData, nWindowXSize, nWindowYSize, GDT_UInt8, 1, nBlockXSize, &sExtraArg); } @@ -322,7 +322,7 @@ CPLErr GDALFootprintMaskBand::IRasterIO( GSpacing nPixelSpace, GSpacing nLineSpace, GDALRasterIOExtraArg *psExtraArg) { if (eRWFlag == GF_Read && nXSize == nBufXSize && nYSize == nBufYSize && - eBufType == GDT_Byte && nPixelSpace == 1) + eBufType == GDT_UInt8 && nPixelSpace == 1) { // Request when band seen as the mask band for GDALPolygonize() @@ -396,7 +396,7 @@ class GDALFootprintCombinedMaskBand final : public GDALRasterBand { nRasterXSize = m_apoSrcBands[0]->GetXSize(); nRasterYSize = m_apoSrcBands[0]->GetYSize(); - eDataType = GDT_Byte; + eDataType = GDT_UInt8; m_apoSrcBands[0]->GetBlockSize(&nBlockXSize, &nBlockYSize); } @@ -421,7 +421,7 @@ CPLErr GDALFootprintCombinedMaskBand::IReadBlock(int nBlockXOff, int nBlockYOff, INIT_RASTERIO_EXTRA_ARG(sExtraArg); return IRasterIO(GF_Read, nBlockXOff * nBlockXSize, nBlockYOff * nBlockYSize, nWindowXSize, nWindowYSize, - pData, nWindowXSize, nWindowYSize, GDT_Byte, 1, + pData, nWindowXSize, nWindowYSize, GDT_UInt8, 1, nBlockXSize, &sExtraArg); } @@ -431,7 +431,7 @@ CPLErr GDALFootprintCombinedMaskBand::IRasterIO( GSpacing nPixelSpace, GSpacing nLineSpace, GDALRasterIOExtraArg *psExtraArg) { if (eRWFlag == GF_Read && nXSize == nBufXSize && nYSize == nBufYSize && - eBufType == GDT_Byte && nPixelSpace == 1) + eBufType == GDT_UInt8 && nPixelSpace == 1) { // Request when band seen as the mask band for GDALPolygonize() { @@ -447,7 +447,7 @@ CPLErr GDALFootprintCombinedMaskBand::IRasterIO( for (auto poBand : m_apoSrcBands) { if (poBand->RasterIO(GF_Read, nXOff, nYOff, nXSize, nYSize, - abyTmp.data(), nBufXSize, nBufYSize, GDT_Byte, + abyTmp.data(), nBufXSize, nBufYSize, GDT_UInt8, 1, nXSize, psExtraArg) != CE_None) { return CE_Failure; @@ -507,7 +507,7 @@ CPLErr GDALFootprintCombinedMaskBand::IRasterIO( for (auto poBand : m_apoSrcBands) { if (poBand->RasterIO(GF_Read, nXOff, nYOff, nXSize, nYSize, - abyTmp.data(), nBufXSize, nBufYSize, GDT_Byte, + abyTmp.data(), nBufXSize, nBufYSize, GDT_UInt8, 1, nXSize, psExtraArg) != CE_None) { return CE_Failure; diff --git a/apps/gdal_translate_lib.cpp b/apps/gdal_translate_lib.cpp index 4f3516355041..93b6f7f24173 100644 --- a/apps/gdal_translate_lib.cpp +++ b/apps/gdal_translate_lib.cpp @@ -1997,7 +1997,7 @@ GDALDatasetH GDALTranslate(const char *pszDest, GDALDatasetH hSrcDataset, if (eOutputType == GDT_Unknown) { eBandType = poRealSrcBand->GetRasterDataType(); - if (eBandType != GDT_Byte && psOptions->nRGBExpand != 0) + if (eBandType != GDT_UInt8 && psOptions->nRGBExpand != 0) { // Use case of https://github.com/OSGeo/gdal/issues/9402 if (const auto poColorTable = poRealSrcBand->GetColorTable()) @@ -2023,7 +2023,7 @@ GDALDatasetH GDALTranslate(const char *pszDest, GDALDatasetH hSrcDataset, "Using Byte output data type due to range " "of values in color table"); } - eBandType = GDT_Byte; + eBandType = GDT_UInt8; } } eOutputType = eBandType; @@ -2054,7 +2054,7 @@ GDALDatasetH GDALTranslate(const char *pszDest, GDALDatasetH hSrcDataset, std::uint64_t nDstMax = 0; switch (eBandType) { - case GDT_Byte: + case GDT_UInt8: nDstMin = std::numeric_limits::min(); nDstMax = std::numeric_limits::max(); break; @@ -2178,7 +2178,7 @@ GDALDatasetH GDALTranslate(const char *pszDest, GDALDatasetH hSrcDataset, } // Preserve PIXELTYPE if no option change values - if (poSrcBand->GetRasterDataType() == GDT_Byte && + if (poSrcBand->GetRasterDataType() == GDT_UInt8 && psOptions->nRGBExpand == 0 && psOptions->asScaleParams.empty() && !psOptions->bUnscale && psOptions->eOutputType == GDT_Unknown && psOptions->osResampling.empty()) @@ -2291,7 +2291,7 @@ GDALDatasetH GDALTranslate(const char *pszDest, GDALDatasetH hSrcDataset, { switch (poVRTBand->GetRasterDataType()) { - case GDT_Byte: + case GDT_UInt8: dfScaleDstMin = std::numeric_limits::lowest(); dfScaleDstMax = std::numeric_limits::max(); break; @@ -2474,7 +2474,7 @@ GDALDatasetH GDALTranslate(const char *pszDest, GDALDatasetH hSrcDataset, const char *pszPixelType = psOptions->aosCreateOptions.FetchNameValue("PIXELTYPE"); if (pszPixelType == nullptr && - poVRTBand->GetRasterDataType() == GDT_Byte) + poVRTBand->GetRasterDataType() == GDT_UInt8) { poVRTBand->EnablePixelTypeSignedByteWarning(false); pszPixelType = diff --git a/apps/gdalalg_raster_blend.cpp b/apps/gdalalg_raster_blend.cpp index 19e2975d27ba..9a3ab661fd38 100644 --- a/apps/gdalalg_raster_blend.cpp +++ b/apps/gdalalg_raster_blend.cpp @@ -411,7 +411,7 @@ class BlendBand final : public GDALRasterBand nRasterYSize = oBlendDataset.GetRasterYSize(); oBlendDataset.m_oColorDS.GetRasterBand(1)->GetBlockSize(&nBlockXSize, &nBlockYSize); - eDataType = GDT_Byte; + eDataType = GDT_UInt8; } GDALColorInterp GetColorInterpretation() override @@ -444,7 +444,7 @@ class BlendBand final : public GDALRasterBand GetActualBlockSize(nBlockXOff, nBlockYOff, &nReqXSize, &nReqYSize); return RasterIO(GF_Read, nBlockXOff * nBlockXSize, nBlockYOff * nBlockYSize, nReqXSize, nReqYSize, pData, - nReqXSize, nReqYSize, GDT_Byte, 1, nBlockXSize, + nReqXSize, nReqYSize, GDT_UInt8, 1, nBlockXSize, nullptr); } @@ -592,14 +592,15 @@ bool BlendDataset::AcquireSourcePixels(int nXOff, int nYOff, int nXSize, } const bool bOK = - (m_oColorDS.RasterIO( - GF_Read, nXOff, nYOff, nXSize, nYSize, m_abyBuffer.data(), - nBufXSize, nBufYSize, GDT_Byte, nColorCount, nullptr, 1, nBufXSize, - static_cast(nPixelCount), psExtraArg) == CE_None && + (m_oColorDS.RasterIO(GF_Read, nXOff, nYOff, nXSize, nYSize, + m_abyBuffer.data(), nBufXSize, nBufYSize, + GDT_UInt8, nColorCount, nullptr, 1, nBufXSize, + static_cast(nPixelCount), + psExtraArg) == CE_None && m_oOverlayDS.RasterIO( GF_Read, nXOff, nYOff, nXSize, nYSize, m_abyBuffer.data() + nPixelCount * nColorCount, nBufXSize, - nBufYSize, GDT_Byte, nOverlayCount, nullptr, 1, nBufXSize, + nBufYSize, GDT_UInt8, nOverlayCount, nullptr, 1, nBufXSize, static_cast(nPixelCount), psExtraArg) == CE_None); if (bOK) { @@ -870,8 +871,9 @@ CPLErr BlendDataset::IRasterIO(GDALRWFlag eRWFlag, int nXOff, int nYOff, const int nColorCount = m_oColorDS.GetRasterCount(); const int nOverlayCount = m_oOverlayDS.GetRasterCount(); if (nOverlayCount == 1 && m_opacity255Scale == 255 && - m_operator == HSV_VALUE && eRWFlag == GF_Read && eBufType == GDT_Byte && - nBandCount == nBands && IsAllBands(nBands, panBandMap) && + m_operator == HSV_VALUE && eRWFlag == GF_Read && + eBufType == GDT_UInt8 && nBandCount == nBands && + IsAllBands(nBands, panBandMap) && AcquireSourcePixels(nXOff, nYOff, nXSize, nYSize, nBufXSize, nBufYSize, psExtraArg)) { @@ -915,8 +917,8 @@ CPLErr BlendDataset::IRasterIO(GDALRWFlag eRWFlag, int nXOff, int nYOff, { auto nDstOffset = 3 * nBandSpace + j * nLineSpace; const GByte *pabyA = m_abyBuffer.data() + nPixelCount * 3; - GDALCopyWords64(pabyA, GDT_Byte, 1, pabyDst + nDstOffset, - GDT_Byte, static_cast(nPixelSpace), + GDALCopyWords64(pabyA, GDT_UInt8, 1, pabyDst + nDstOffset, + GDT_UInt8, static_cast(nPixelSpace), nBufXSize); } } @@ -924,7 +926,7 @@ CPLErr BlendDataset::IRasterIO(GDALRWFlag eRWFlag, int nXOff, int nYOff, return CE_None; } else if (nOverlayCount == 4 && nColorCount == 4 && m_operator == SRC_OVER && - eRWFlag == GF_Read && eBufType == GDT_Byte && + eRWFlag == GF_Read && eBufType == GDT_UInt8 && nBandCount == nBands && IsAllBands(nBands, panBandMap) && AcquireSourcePixels(nXOff, nYOff, nXSize, nYSize, nBufXSize, nBufYSize, psExtraArg)) @@ -1056,7 +1058,7 @@ CPLErr BlendBand::IRasterIO(GDALRWFlag eRWFlag, int nXOff, int nYOff, GByte ch = 255; for (int iY = 0; iY < nBufYSize; ++iY) { - GDALCopyWords64(&ch, GDT_Byte, 0, + GDALCopyWords64(&ch, GDT_UInt8, 0, static_cast(pData) + iY * nLineSpace, eBufType, static_cast(nPixelSpace), nBufXSize); @@ -1073,7 +1075,7 @@ CPLErr BlendBand::IRasterIO(GDALRWFlag eRWFlag, int nXOff, int nYOff, } else if (nOverlayCount == 3 && nColorCount == 3 && m_oBlendDataset.m_operator == SRC_OVER && eRWFlag == GF_Read && - eBufType == GDT_Byte && + eBufType == GDT_UInt8 && m_oBlendDataset.AcquireSourcePixels(nXOff, nYOff, nXSize, nYSize, nBufXSize, nBufYSize, psExtraArg)) @@ -1111,7 +1113,7 @@ CPLErr BlendBand::IRasterIO(GDALRWFlag eRWFlag, int nXOff, int nYOff, } return CE_None; } - else if (eRWFlag == GF_Read && eBufType == GDT_Byte && + else if (eRWFlag == GF_Read && eBufType == GDT_UInt8 && m_oBlendDataset.AcquireSourcePixels(nXOff, nYOff, nXSize, nYSize, nBufXSize, nBufYSize, psExtraArg)) @@ -1377,7 +1379,7 @@ bool GDALRasterBlendAlgorithm::ValidateGlobal() if (poSrcDS) { if (poSrcDS->GetRasterCount() == 0 || poSrcDS->GetRasterCount() > 4 || - poSrcDS->GetRasterBand(1)->GetRasterDataType() != GDT_Byte) + poSrcDS->GetRasterBand(1)->GetRasterDataType() != GDT_UInt8) { ReportError(CE_Failure, CPLE_NotSupported, "Only 1-band, 2-band, 3-band or 4-band Byte dataset " @@ -1389,7 +1391,7 @@ bool GDALRasterBlendAlgorithm::ValidateGlobal() { if (poOverlayDS->GetRasterCount() == 0 || poOverlayDS->GetRasterCount() > 4 || - poOverlayDS->GetRasterBand(1)->GetRasterDataType() != GDT_Byte) + poOverlayDS->GetRasterBand(1)->GetRasterDataType() != GDT_UInt8) { ReportError(CE_Failure, CPLE_NotSupported, "Only 1-band, 2-band, 3-band or 4-band Byte dataset " diff --git a/apps/gdalalg_raster_calc.cpp b/apps/gdalalg_raster_calc.cpp index ad45ace1ded9..d4a0ba2453ee 100644 --- a/apps/gdalalg_raster_calc.cpp +++ b/apps/gdalalg_raster_calc.cpp @@ -1088,7 +1088,7 @@ bool GDALRasterCalcAlgorithm::RunStep(GDALPipelineStepRunContext &ctxt) VSIMemGenerateHiddenFilename("tmp.tif"); auto poDS = std::unique_ptr( poGTIFFDrv->Create(osFilename.c_str(), 1, 1, maxSourceBands, - GDT_Byte, nullptr)); + GDT_UInt8, nullptr)); if (poDS) osTmpFilename = std::move(osFilename); } @@ -1099,7 +1099,7 @@ bool GDALRasterCalcAlgorithm::RunStep(GDALPipelineStepRunContext &ctxt) pixelFunctionArgs, options, maxSourceBands, osTmpFilename); if (fakeVRT && fakeVRT->RasterIO(GF_Read, 0, 0, 1, 1, dummyData.data(), 1, - 1, GDT_Byte, vrt->GetRasterCount(), + 1, GDT_UInt8, vrt->GetRasterCount(), nullptr, 0, 0, 0, nullptr) != CE_None) { return false; diff --git a/apps/gdalalg_raster_compare.cpp b/apps/gdalalg_raster_compare.cpp index c9843c921468..3748f84870c2 100644 --- a/apps/gdalalg_raster_compare.cpp +++ b/apps/gdalalg_raster_compare.cpp @@ -568,7 +568,7 @@ void GDALRasterCompareAlgorithm::DatasetComparison( poInputDS->GetRasterBand(1)->GetRasterDataType()); switch (eReqDT) { - case GDT_Byte: + case GDT_UInt8: DatasetPixelComparison( aosReport, poRefDS, poInputDS, eReqDT, pfnProgress, pProgressData); @@ -728,7 +728,7 @@ static void ComparePixels(std::vector &aosReport, poInputBand->GetRasterDataType()); switch (eReqDT) { - case GDT_Byte: + case GDT_UInt8: ComparePixels(aosReport, bandId, poRefBand, poInputBand, eReqDT, pfnProgress, pProgressData); diff --git a/apps/gdalalg_raster_rgb_to_palette.cpp b/apps/gdalalg_raster_rgb_to_palette.cpp index d76bcff2e2a1..abd0c5d645c6 100644 --- a/apps/gdalalg_raster_rgb_to_palette.cpp +++ b/apps/gdalalg_raster_rgb_to_palette.cpp @@ -70,7 +70,7 @@ bool GDALRasterRGBToPaletteAlgorithm::RunStep(GDALPipelineStepRunContext &ctxt) for (int i = 1; i <= nSrcBandCount; ++i) { auto poSrcBand = poSrcDS->GetRasterBand(i); - if (poSrcBand->GetRasterDataType() != GDT_Byte) + if (poSrcBand->GetRasterDataType() != GDT_UInt8) { ReportError(CE_Failure, CPLE_NotSupported, "Non-byte band found and not supported"); @@ -115,7 +115,7 @@ bool GDALRasterRGBToPaletteAlgorithm::RunStep(GDALPipelineStepRunContext &ctxt) } auto poTmpDS = CreateTemporaryDataset( - poSrcDS->GetRasterXSize(), poSrcDS->GetRasterYSize(), 1, GDT_Byte, + poSrcDS->GetRasterXSize(), poSrcDS->GetRasterYSize(), 1, GDT_UInt8, /* bTiledIfPossible = */ true, poSrcDS, /* bCopyMetadata = */ true); if (!poTmpDS) return false; diff --git a/apps/gdalalg_raster_tile.cpp b/apps/gdalalg_raster_tile.cpp index b10702f7d8e4..f8f93944d74b 100644 --- a/apps/gdalalg_raster_tile.cpp +++ b/apps/gdalalg_raster_tile.cpp @@ -715,7 +715,7 @@ static bool GenerateTile( constexpr int EXTRA_BYTE_PER_ROW = 1; // for filter type constexpr int EXTRA_ROWS = 2; // for paethBuffer and paethBufferTmp if (!bAuxXML && EQUAL(pszExtension, "png") && - eWorkingDataType == GDT_Byte && poColorTable == nullptr && + eWorkingDataType == GDT_UInt8 && poColorTable == nullptr && pdfDstNoData == nullptr && W <= INT_MAX / nBands && nBands * W <= INT_MAX - EXTRA_BYTE_PER_ROW && H <= INT_MAX - EXTRA_ROWS && @@ -2552,7 +2552,7 @@ GenerateSTAC(const std::string &osDirectory, const std::string &osTitle, {GDT_Int16, "int16"}, {GDT_Int32, "int32"}, {GDT_Int64, "int64"}, - {GDT_Byte, "uint8"}, + {GDT_UInt8, "uint8"}, {GDT_UInt16, "uint16"}, {GDT_UInt32, "uint32"}, {GDT_UInt64, "uint64"}, @@ -3422,7 +3422,7 @@ bool GDALRasterTileAlgorithm::ValidateOutputFormat(GDALDataType eSrcDT) const "Only up to 4 bands supported for PNG."); return false; } - if (eSrcDT != GDT_Byte && eSrcDT != GDT_UInt16) + if (eSrcDT != GDT_UInt8 && eSrcDT != GDT_UInt16) { ReportError(CE_Failure, CPLE_NotSupported, "Only Byte and UInt16 data types supported for PNG."); @@ -3441,7 +3441,7 @@ bool GDALRasterTileAlgorithm::ValidateOutputFormat(GDALDataType eSrcDT) const const bool bUInt16Supported = strstr(m_poDstDriver->GetMetadataItem(GDAL_DMD_CREATIONDATATYPES), "UInt16"); - if (eSrcDT != GDT_Byte && !(eSrcDT == GDT_UInt16 && bUInt16Supported)) + if (eSrcDT != GDT_UInt8 && !(eSrcDT == GDT_UInt16 && bUInt16Supported)) { ReportError( CE_Failure, CPLE_NotSupported, @@ -3486,7 +3486,7 @@ bool GDALRasterTileAlgorithm::ValidateOutputFormat(GDALDataType eSrcDT) const "Only 3 or 4 bands supported for WEBP."); return false; } - if (eSrcDT != GDT_Byte) + if (eSrcDT != GDT_UInt8) { ReportError(CE_Failure, CPLE_NotSupported, "Only Byte data type supported for WEBP."); diff --git a/apps/gdalbuildvrt_lib.cpp b/apps/gdalbuildvrt_lib.cpp index de8eed0361e7..83a3bcac74af 100644 --- a/apps/gdalbuildvrt_lib.cpp +++ b/apps/gdalbuildvrt_lib.cpp @@ -1304,7 +1304,7 @@ void VRTBuilder::CreateVRTNonSeparate(VRTDataset *poVRTDS) VRTSourcedRasterBand *poMaskVRTBand = nullptr; if (bAddAlpha) { - poVRTDS->AddBand(GDT_Byte); + poVRTDS->AddBand(GDT_UInt8); GDALRasterBand *poBand = poVRTDS->GetRasterBand(nSelectedBands + 1); poBand->SetColorInterpretation(GCI_AlphaBand); } @@ -1399,7 +1399,7 @@ void VRTBuilder::CreateVRTNonSeparate(VRTDataset *poVRTDS) hProxyDS, j < static_cast(asBandProperties.size()) ? asBandProperties[j].dataType - : GDT_Byte, + : GDT_UInt8, psDatasetProperties->nBlockXSize, psDatasetProperties->nBlockYSize); } @@ -1410,7 +1410,7 @@ void VRTBuilder::CreateVRTNonSeparate(VRTDataset *poVRTDS) GDALDataset::FromHandle(hProxyDS)) ->GetRasterBand(1)) ->AddSrcMaskBandDescription( - GDT_Byte, psDatasetProperties->nMaskBlockXSize, + GDT_UInt8, psDatasetProperties->nMaskBlockXSize, psDatasetProperties->nMaskBlockYSize); } diff --git a/apps/gdaldem_lib.cpp b/apps/gdaldem_lib.cpp index 12211ec078d0..376228574162 100644 --- a/apps/gdaldem_lib.cpp +++ b/apps/gdaldem_lib.cpp @@ -361,12 +361,12 @@ static CPLErr GDALGeneric3x3Processing( if (bSrcHasNoData) { GDALDataType eSrcDT = GDALGetRasterDataType(hSrcBand); - CPLAssert(eSrcDT == GDT_Byte || eSrcDT == GDT_UInt16 || + CPLAssert(eSrcDT == GDT_UInt8 || eSrcDT == GDT_UInt16 || eSrcDT == GDT_Int16); - const int nMinVal = (eSrcDT == GDT_Byte) ? 0 + const int nMinVal = (eSrcDT == GDT_UInt8) ? 0 : (eSrcDT == GDT_UInt16) ? 0 : -32768; - const int nMaxVal = (eSrcDT == GDT_Byte) ? 255 + const int nMaxVal = (eSrcDT == GDT_UInt8) ? 255 : (eSrcDT == GDT_UInt16) ? 65535 : 32767; @@ -1808,10 +1808,10 @@ static GByte *GDALColorReliefPrecompute( *pnIndexOffset = nIndexOffset; const int nXSize = GDALGetRasterBandXSize(hSrcBand); const int nYSize = GDALGetRasterBandYSize(hSrcBand); - if (eDT == GDT_Byte || ((eDT == GDT_Int16 || eDT == GDT_UInt16) && - static_cast(nXSize) * nYSize > 65536)) + if (eDT == GDT_UInt8 || ((eDT == GDT_Int16 || eDT == GDT_UInt16) && + static_cast(nXSize) * nYSize > 65536)) { - const int iMax = (eDT == GDT_Byte) ? 256 : 65536; + const int iMax = (eDT == GDT_UInt8) ? 256 : 65536; pabyPrecomputed = static_cast(VSI_MALLOC2_VERBOSE(4, iMax)); if (pabyPrecomputed) { @@ -1947,7 +1947,7 @@ GDALColorReliefRasterBand::GDALColorReliefRasterBand( { poDS = poDSIn; nBand = nBandIn; - eDataType = GDT_Byte; + eDataType = GDT_UInt8; GDALGetBlockSize(poDSIn->hSrcBand, &nBlockXSize, &nBlockYSize); } @@ -2045,7 +2045,7 @@ GDALColorRelief(GDALRasterBandH hSrcBand, GDALRasterBandH hDstBand1, /* -------------------------------------------------------------------- */ /* Precompute the map from values to RGBA quadruplets */ - /* for GDT_Byte, GDT_Int16 or GDT_UInt16 */ + /* for GDT_UInt8, GDT_Int16 or GDT_UInt16 */ /* -------------------------------------------------------------------- */ int nIndexOffset = 0; std::unique_ptr pabyPrecomputed( @@ -2137,21 +2137,21 @@ GDALColorRelief(GDALRasterBandH hSrcBand, GDALRasterBandH hDstBand1, * Write Line to Raster */ eErr = GDALRasterIO(hDstBand1, GF_Write, 0, i, nXSize, 1, pabyDestBuf1, - nXSize, 1, GDT_Byte, 0, 0); + nXSize, 1, GDT_UInt8, 0, 0); if (eErr == CE_None) { eErr = GDALRasterIO(hDstBand2, GF_Write, 0, i, nXSize, 1, - pabyDestBuf2, nXSize, 1, GDT_Byte, 0, 0); + pabyDestBuf2, nXSize, 1, GDT_UInt8, 0, 0); } if (eErr == CE_None) { eErr = GDALRasterIO(hDstBand3, GF_Write, 0, i, nXSize, 1, - pabyDestBuf3, nXSize, 1, GDT_Byte, 0, 0); + pabyDestBuf3, nXSize, 1, GDT_UInt8, 0, 0); } if (eErr == CE_None && hDstBand4) { eErr = GDALRasterIO(hDstBand4, GF_Write, 0, i, nXSize, 1, - pabyDestBuf4, nXSize, 1, GDT_Byte, 0, 0); + pabyDestBuf4, nXSize, 1, GDT_UInt8, 0, 0); } if (eErr == CE_None && @@ -2527,7 +2527,7 @@ GDALGeneric3x3Dataset::GDALGeneric3x3Dataset( bDstHasNoData(bDstHasNoDataIn), dfDstNoDataValue(dfDstNoDataValueIn), bComputeAtEdges(bComputeAtEdgesIn), bTakeReference(bTakeReferenceIn) { - CPLAssert(eDstDataType == GDT_Byte || eDstDataType == GDT_Float32); + CPLAssert(eDstDataType == GDT_UInt8 || eDstDataType == GDT_Float32); if (bTakeReference) GDALReferenceDataset(hSrcDS); @@ -2543,7 +2543,7 @@ GDALGeneric3x3Dataset::GDALGeneric3x3Dataset( static_cast(VSI_MALLOC2_VERBOSE(sizeof(T), nRasterXSize)); apafSourceBuf[2] = static_cast(VSI_MALLOC2_VERBOSE(sizeof(T), nRasterXSize)); - if (pfnAlg_multisample && eDstDataType == GDT_Byte) + if (pfnAlg_multisample && eDstDataType == GDT_UInt8) { pafOutputBuf.reset(static_cast( VSI_MALLOC2_VERBOSE(sizeof(float), nRasterXSize))); @@ -2615,12 +2615,12 @@ GDALGeneric3x3RasterBand::GDALGeneric3x3RasterBand( if (bSrcHasNoData) { GDALDataType eSrcDT = GDALGetRasterDataType(poDSIn->hSrcBand); - CPLAssert(eSrcDT == GDT_Byte || eSrcDT == GDT_UInt16 || + CPLAssert(eSrcDT == GDT_UInt8 || eSrcDT == GDT_UInt16 || eSrcDT == GDT_Int16); - const int nMinVal = (eSrcDT == GDT_Byte) ? 0 + const int nMinVal = (eSrcDT == GDT_UInt8) ? 0 : (eSrcDT == GDT_UInt16) ? 0 : -32768; - const int nMaxVal = (eSrcDT == GDT_Byte) ? 255 + const int nMaxVal = (eSrcDT == GDT_UInt8) ? 255 : (eSrcDT == GDT_UInt16) ? 65535 : 32767; @@ -2647,7 +2647,7 @@ template void GDALGeneric3x3RasterBand::InitWithNoData(void *pImage) { auto poGDS = cpl::down_cast *>(poDS); - if (eDataType == GDT_Byte) + if (eDataType == GDT_UInt8) { for (int j = 0; j < nBlockXSize; j++) static_cast(pImage)[j] = @@ -2740,7 +2740,7 @@ CPLErr GDALGeneric3x3RasterBand::IReadBlock(int /*nBlockXOff*/, static_cast(poGDS->dfDstNoDataValue), poGDS->pfnAlg, poGDS->pAlgData.get(), poGDS->bComputeAtEdges); - if (eDataType == GDT_Byte) + if (eDataType == GDT_UInt8) static_cast(pImage)[j] = static_cast(fVal + 0.5f); else @@ -2795,7 +2795,7 @@ CPLErr GDALGeneric3x3RasterBand::IReadBlock(int /*nBlockXOff*/, static_cast(poGDS->dfDstNoDataValue), poGDS->pfnAlg, poGDS->pAlgData.get(), poGDS->bComputeAtEdges); - if (eDataType == GDT_Byte) + if (eDataType == GDT_UInt8) static_cast(pImage)[j] = static_cast(fVal + 0.5f); else @@ -2876,7 +2876,7 @@ CPLErr GDALGeneric3x3RasterBand::IReadBlock(int /*nBlockXOff*/, afWin, static_cast(poGDS->dfDstNoDataValue), poGDS->pfnAlg, poGDS->pAlgData.get(), poGDS->bComputeAtEdges); - if (eDataType == GDT_Byte) + if (eDataType == GDT_UInt8) static_cast(pImage)[j] = static_cast(fVal + 0.5f); else @@ -2906,14 +2906,14 @@ CPLErr GDALGeneric3x3RasterBand::IReadBlock(int /*nBlockXOff*/, static_cast(poGDS->dfDstNoDataValue), poGDS->pfnAlg, poGDS->pAlgData.get(), poGDS->bComputeAtEdges); - if (eDataType == GDT_Byte) + if (eDataType == GDT_UInt8) static_cast(pImage)[j] = static_cast(fVal + 0.5f); else static_cast(pImage)[j] = fVal; } else { - if (eDataType == GDT_Byte) + if (eDataType == GDT_UInt8) { static_cast(pImage)[0] = static_cast(poGDS->dfDstNoDataValue); @@ -2947,7 +2947,7 @@ CPLErr GDALGeneric3x3RasterBand::IReadBlock(int /*nBlockXOff*/, { GDALCopyWords64(poGDS->pafOutputBuf.get() + 1, GDT_Float32, static_cast(sizeof(float)), - static_cast(pImage) + 1, GDT_Byte, 1, + static_cast(pImage) + 1, GDT_UInt8, 1, j - 1); } } @@ -2966,7 +2966,7 @@ CPLErr GDALGeneric3x3RasterBand::IReadBlock(int /*nBlockXOff*/, static_cast(poGDS->dfDstNoDataValue), poGDS->pfnAlg, poGDS->pAlgData.get(), poGDS->bComputeAtEdges); - if (eDataType == GDT_Byte) + if (eDataType == GDT_UInt8) static_cast(pImage)[j] = static_cast(fVal + 0.5f); else static_cast(pImage)[j] = fVal; @@ -3995,7 +3995,7 @@ GDALDatasetH GDALDEMProcessing(const char *pszDest, GDALDatasetH hSrcDataset, const GDALDataType eDstDataType = (eUtilityMode == HILL_SHADE || eUtilityMode == COLOR_RELIEF) - ? GDT_Byte + ? GDT_UInt8 : GDT_Float32; if (EQUAL(osFormat, "VRT")) @@ -4098,7 +4098,7 @@ GDALDatasetH GDALDEMProcessing(const char *pszDest, GDALDatasetH hSrcDataset, } else { - if (eSrcDT == GDT_Byte || eSrcDT == GDT_Int16 || + if (eSrcDT == GDT_UInt8 || eSrcDT == GDT_Int16 || eSrcDT == GDT_UInt16) { auto poDS = std::make_unique>( @@ -4175,7 +4175,7 @@ GDALDatasetH GDALDEMProcessing(const char *pszDest, GDALDatasetH hSrcDataset, if (bDstHasNoData) GDALSetRasterNoDataValue(hDstBand, dfDstNoDataValue); - if (eSrcDT == GDT_Byte || eSrcDT == GDT_Int16 || eSrcDT == GDT_UInt16) + if (eSrcDT == GDT_UInt8 || eSrcDT == GDT_Int16 || eSrcDT == GDT_UInt16) { GDALGeneric3x3Processing( hSrcBand, hDstBand, pfnAlgInt32, pfnAlgInt32_multisample, diff --git a/apps/gdalenhance.cpp b/apps/gdalenhance.cpp index 0522cc05385b..2c0b2625ab97 100644 --- a/apps/gdalenhance.cpp +++ b/apps/gdalenhance.cpp @@ -480,7 +480,7 @@ static CPLErr EnhancerCallback(void *hCBData, int nXOff, int nYOff, int nXSize, { const EnhanceCBInfo *psEInfo = static_cast(hCBData); - if (psEInfo->eWrkType != GDT_Byte) + if (psEInfo->eWrkType != GDT_UInt8) { CPLError(CE_Failure, CPLE_AppDefined, "Currently gdalenhance only supports Byte output."); @@ -685,7 +685,7 @@ CPLErr WriteEnhanced(GDALDatasetH hDataset, int **papanLUTs, int nLUTBins, /* Select output data type to match source. */ /* ---------------------------------------------------------------- */ if (eOutputType == GDT_Unknown) - eBandType = GDT_Byte; + eBandType = GDT_UInt8; else eBandType = eOutputType; diff --git a/apps/gdalflattenmask.c b/apps/gdalflattenmask.c index ef0ff92e15fc..eb6ccd74a616 100644 --- a/apps/gdalflattenmask.c +++ b/apps/gdalflattenmask.c @@ -145,10 +145,10 @@ int main(int argc, char *argv[]) } } - if (eDataType != GDT_Byte) + if (eDataType != GDT_UInt8) { fprintf(stderr, - "Only GDT_Byte type supported for source dataset\n"); + "Only GDT_UInt8 type supported for source dataset\n"); exit(1); } } @@ -164,7 +164,7 @@ int main(int argc, char *argv[]) } hDstDS = GDALCreate(hDriver, pszDstFilename, nXSize, nYSize, - nBands + ((bSetAlpha) ? 1 : 0), GDT_Byte, + nBands + ((bSetAlpha) ? 1 : 0), GDT_UInt8, papszCreateOptions); if (hDstDS == NULL) { @@ -261,10 +261,10 @@ int main(int argc, char *argv[]) if (!bSetAlpha) { GDALRasterIO(hMaskBand, GF_Read, 0, iLine, nXSize, 1, - pabyMaskBuffer, nXSize, 1, GDT_Byte, 0, 0); + pabyMaskBuffer, nXSize, 1, GDT_UInt8, 0, 0); switch (eDataType) { - case GDT_Byte: + case GDT_UInt8: { for (iCol = 0; iCol < nXSize; iCol++) { @@ -308,7 +308,7 @@ int main(int argc, char *argv[]) for (iLine = 0; iLine < nYSize; iLine++) { GDALRasterIO(hMaskBand, GF_Read, 0, iLine, nXSize, 1, - pabyMaskBuffer, nXSize, 1, GDT_Byte, 0, 0); + pabyMaskBuffer, nXSize, 1, GDT_UInt8, 0, 0); for (iCol = 0; iCol < nXSize; iCol++) { /* If the mask is 1-bit, expand 1 to 255 */ @@ -316,7 +316,7 @@ int main(int argc, char *argv[]) pabyMaskBuffer[iCol] = 255; } GDALRasterIO(hDstAlphaBand, GF_Write, 0, iLine, nXSize, 1, - pabyMaskBuffer, nXSize, 1, GDT_Byte, 0, 0); + pabyMaskBuffer, nXSize, 1, GDT_UInt8, 0, 0); } } diff --git a/apps/gdalinfo_lib.cpp b/apps/gdalinfo_lib.cpp index 174ace79903a..aa672dfd8150 100644 --- a/apps/gdalinfo_lib.cpp +++ b/apps/gdalinfo_lib.cpp @@ -1073,7 +1073,7 @@ char *GDALInfo(GDALDatasetH hDataset, const GDALInfoOptions *psOptions) const char *stacDataType = nullptr; switch (eDT) { - case GDT_Byte: + case GDT_UInt8: stacDataType = "uint8"; break; case GDT_Int8: diff --git a/apps/gdalmdiminfo_lib.cpp b/apps/gdalmdiminfo_lib.cpp index b8b55d5e0424..dcd2f13900c0 100644 --- a/apps/gdalmdiminfo_lib.cpp +++ b/apps/gdalmdiminfo_lib.cpp @@ -209,7 +209,7 @@ static void DumpValue(CPLJSonStreamingWriter &serializer, const GByte *bytes, { switch (eDT) { - case GDT_Byte: + case GDT_UInt8: DumpValue(serializer, bytes); break; case GDT_Int8: diff --git a/apps/nearblack_lib.cpp b/apps/nearblack_lib.cpp index eed278cd3aff..42444576891a 100644 --- a/apps/nearblack_lib.cpp +++ b/apps/nearblack_lib.cpp @@ -172,7 +172,7 @@ GDALDatasetH CPL_DLL GDALNearblack(const char *pszDest, GDALDatasetH hDstDS, } hDstDS = GDALCreate(hDriver, pszDest, nXSize, nYSize, nDstBands, - GDT_Byte, psOptions->aosCreationOptions.List()); + GDT_UInt8, psOptions->aosCreationOptions.List()); if (hDstDS == nullptr) { return nullptr; @@ -291,10 +291,10 @@ GDALDatasetH CPL_DLL GDALNearblack(const char *pszDest, GDALDatasetH hDstDS, for (int iBand = 0; iBand < nBands; iBand++) { GDALRasterBandH hBand = GDALGetRasterBand(hSrcDataset, iBand + 1); - if (GDALGetRasterDataType(hBand) != GDT_Byte) + if (GDALGetRasterDataType(hBand) != GDT_UInt8) { CPLError(CE_Warning, CPLE_AppDefined, - "Band %d is not of type GDT_Byte. " + "Band %d is not of type GDT_UInt8. " "It can lead to unexpected results.", iBand + 1); } @@ -399,7 +399,7 @@ bool GDALNearblackTwoPassesAlgorithm(const GDALNearblackOptions *psOptions, { CPLErr eErr = GDALDatasetRasterIO( hSrcDataset, GF_Read, 0, iLine, nXSize, 1, pabyLine, nXSize, 1, - GDT_Byte, nBands, nullptr, nDstBands, nXSize * nDstBands, 1); + GDT_UInt8, nBands, nullptr, nDstBands, nXSize * nDstBands, 1); if (eErr != CE_None) { return false; @@ -435,7 +435,7 @@ bool GDALNearblackTwoPassesAlgorithm(const GDALNearblackOptions *psOptions, iLine); eErr = GDALDatasetRasterIO(hDstDS, GF_Write, 0, iLine, nXSize, 1, - pabyLine, nXSize, 1, GDT_Byte, nDstBands, + pabyLine, nXSize, 1, GDT_UInt8, nDstBands, nullptr, nDstBands, nXSize * nDstBands, 1); if (eErr != CE_None) @@ -448,7 +448,7 @@ bool GDALNearblackTwoPassesAlgorithm(const GDALNearblackOptions *psOptions, if (bSetMask) { eErr = GDALRasterIO(hMaskBand, GF_Write, 0, iLine, nXSize, 1, - pabyMask, nXSize, 1, GDT_Byte, 0, 0); + pabyMask, nXSize, 1, GDT_UInt8, 0, 0); if (eErr != CE_None) { CPLError(CE_Warning, CPLE_AppDefined, @@ -473,8 +473,8 @@ bool GDALNearblackTwoPassesAlgorithm(const GDALNearblackOptions *psOptions, for (iLine = nYSize - 1; hDstDS != nullptr && iLine >= 0; iLine--) { CPLErr eErr = GDALDatasetRasterIO( - hDstDS, GF_Read, 0, iLine, nXSize, 1, pabyLine, nXSize, 1, GDT_Byte, - nDstBands, nullptr, nDstBands, nXSize * nDstBands, 1); + hDstDS, GF_Read, 0, iLine, nXSize, 1, pabyLine, nXSize, 1, + GDT_UInt8, nDstBands, nullptr, nDstBands, nXSize * nDstBands, 1); if (eErr != CE_None) { return false; @@ -485,7 +485,7 @@ bool GDALNearblackTwoPassesAlgorithm(const GDALNearblackOptions *psOptions, if (bSetMask) { eErr = GDALRasterIO(hMaskBand, GF_Read, 0, iLine, nXSize, 1, - pabyMask, nXSize, 1, GDT_Byte, 0, 0); + pabyMask, nXSize, 1, GDT_UInt8, 0, 0); if (eErr != CE_None) { return false; @@ -506,7 +506,7 @@ bool GDALNearblackTwoPassesAlgorithm(const GDALNearblackOptions *psOptions, nYSize - 1 - iLine); eErr = GDALDatasetRasterIO(hDstDS, GF_Write, 0, iLine, nXSize, 1, - pabyLine, nXSize, 1, GDT_Byte, nDstBands, + pabyLine, nXSize, 1, GDT_UInt8, nDstBands, nullptr, nDstBands, nXSize * nDstBands, 1); if (eErr != CE_None) { @@ -518,7 +518,7 @@ bool GDALNearblackTwoPassesAlgorithm(const GDALNearblackOptions *psOptions, if (bSetMask) { eErr = GDALRasterIO(hMaskBand, GF_Write, 0, iLine, nXSize, 1, - pabyMask, nXSize, 1, GDT_Byte, 0, 0); + pabyMask, nXSize, 1, GDT_UInt8, 0, 0); if (eErr != CE_None) { return false; diff --git a/apps/nearblack_lib_floodfill.cpp b/apps/nearblack_lib_floodfill.cpp index 75d492f92111..a08d0b069b3b 100644 --- a/apps/nearblack_lib_floodfill.cpp +++ b/apps/nearblack_lib_floodfill.cpp @@ -167,7 +167,7 @@ bool GDALNearblackFloodFillAlg::LoadLine(int iY) { if (m_poDstDS->RasterIO( GF_Write, 0, m_nLoadedLine, nXSize, 1, m_abyLine.data(), - nXSize, 1, GDT_Byte, m_nDstBands, nullptr, m_nDstBands, + nXSize, 1, GDT_UInt8, m_nDstBands, nullptr, m_nDstBands, static_cast(nXSize) * m_nDstBands, 1, nullptr) != CE_None) { @@ -180,7 +180,7 @@ bool GDALNearblackFloodFillAlg::LoadLine(int iY) { if (m_poMaskBand->RasterIO(GF_Write, 0, m_nLoadedLine, nXSize, 1, m_abyMask.data(), nXSize, 1, - GDT_Byte, 0, 0, nullptr) != CE_None) + GDT_UInt8, 0, 0, nullptr) != CE_None) { return false; } @@ -198,7 +198,7 @@ bool GDALNearblackFloodFillAlg::LoadLine(int iY) // line of interest if (m_poDstDS->RasterIO( GF_Read, 0, iY, nXSize, 1, m_abyLine.data(), nXSize, 1, - GDT_Byte, m_nDstBands, nullptr, m_nDstBands, + GDT_UInt8, m_nDstBands, nullptr, m_nDstBands, static_cast(nXSize) * m_nDstBands, 1, nullptr) != CE_None) { @@ -210,7 +210,7 @@ bool GDALNearblackFloodFillAlg::LoadLine(int iY) // Otherwise load from the source data if (m_poSrcDataset->RasterIO( GF_Read, 0, iY, nXSize, 1, m_abyLine.data(), nXSize, 1, - GDT_Byte, + GDT_UInt8, // m_nSrcBands intended m_nSrcBands, // m_nDstBands intended @@ -245,7 +245,7 @@ bool GDALNearblackFloodFillAlg::LoadLine(int iY) { if (m_poMaskBand->RasterIO( GF_Read, 0, iY, nXSize, 1, m_abyMask.data(), nXSize, - 1, GDT_Byte, 0, 0, nullptr) != CE_None) + 1, GDT_UInt8, 0, 0, nullptr) != CE_None) { return false; } @@ -274,7 +274,7 @@ bool GDALNearblackFloodFillAlg::LoadLine(int iY) { if (m_poVisitedDS->GetRasterBand(1)->RasterIO( GF_Write, 0, m_nLoadedLine, nXSize, 1, - m_abyLineMustSet.data(), nXSize, 1, GDT_Byte, 0, 0, + m_abyLineMustSet.data(), nXSize, 1, GDT_UInt8, 0, 0, nullptr) != CE_None) { return false; @@ -285,7 +285,7 @@ bool GDALNearblackFloodFillAlg::LoadLine(int iY) { if (m_poVisitedDS->GetRasterBand(1)->RasterIO( GF_Read, 0, iY, nXSize, 1, m_abyLineMustSet.data(), nXSize, - 1, GDT_Byte, 0, 0, nullptr) != CE_None) + 1, GDT_UInt8, 0, 0, nullptr) != CE_None) { return false; } @@ -521,7 +521,7 @@ bool GDALNearblackFloodFillAlg::Process() } m_poVisitedDS.reset(GDALDataset::FromHandle( GDALCreate(hDriver, osVisitedDataset.c_str(), nXSize, nYSize, 1, - GDT_Byte, aosOptions.List()))); + GDT_UInt8, aosOptions.List()))); if (!m_poVisitedDS) return false; if (strcmp(pszTmpDriver, "MEM") != 0) diff --git a/autotest/alg/applyverticalshiftgrid.py b/autotest/alg/applyverticalshiftgrid.py index 407d6ae49791..ba0e1b934979 100755 --- a/autotest/alg/applyverticalshiftgrid.py +++ b/autotest/alg/applyverticalshiftgrid.py @@ -32,7 +32,7 @@ def test_applyverticalshiftgrid_1(): src_ds = gdal.Translate("", src_ds, format="MEM", width=20, height=40) grid_ds = gdal.Translate("", src_ds, format="MEM") out_ds = gdal.ApplyVerticalShiftGrid(src_ds, grid_ds) - assert out_ds.GetRasterBand(1).DataType == gdal.GDT_Byte + assert out_ds.GetRasterBand(1).DataType == gdal.GDT_UInt8 assert out_ds.RasterXSize == src_ds.RasterXSize assert out_ds.RasterYSize == src_ds.RasterYSize assert out_ds.GetGeoTransform() == src_ds.GetGeoTransform() @@ -77,14 +77,14 @@ def test_applyverticalshiftgrid_2(): if i != 1: src_ds.SetProjection(sr.ExportToWkt()) if i == 2: - src_ds.AddBand(gdal.GDT_Byte) + src_ds.AddBand(gdal.GDT_UInt8) grid_ds = gdal.GetDriverByName("MEM").Create("", 1, 1) if i != 3: grid_ds.SetGeoTransform([0, 1, 0, 0, 0, -1]) if i != 4: grid_ds.SetProjection(sr.ExportToWkt()) if i == 5: - grid_ds.AddBand(gdal.GDT_Byte) + grid_ds.AddBand(gdal.GDT_UInt8) with gdal.quiet_errors(): out_ds = gdal.ApplyVerticalShiftGrid(src_ds, grid_ds) assert out_ds is None, i diff --git a/autotest/alg/dither.py b/autotest/alg/dither.py index e8b7e4adac0c..de28e7dc97b0 100755 --- a/autotest/alg/dither.py +++ b/autotest/alg/dither.py @@ -31,7 +31,7 @@ def test_dither_1(): b_band = src_ds.GetRasterBand(3) dst_ds = drv.Create( - "tmp/rgbsmall.tif", src_ds.RasterXSize, src_ds.RasterYSize, 1, gdal.GDT_Byte + "tmp/rgbsmall.tif", src_ds.RasterXSize, src_ds.RasterYSize, 1, gdal.GDT_UInt8 ) dst_band = dst_ds.GetRasterBand(1) diff --git a/autotest/alg/proximity.py b/autotest/alg/proximity.py index 9bc4bd9e2186..a16b10ea8a05 100755 --- a/autotest/alg/proximity.py +++ b/autotest/alg/proximity.py @@ -26,7 +26,7 @@ def test_proximity_1(): src_ds = gdal.Open("data/pat.tif") src_band = src_ds.GetRasterBand(1) - dst_ds = drv.Create("tmp/proximity_1.tif", 25, 25, 1, gdal.GDT_Byte) + dst_ds = drv.Create("tmp/proximity_1.tif", 25, 25, 1, gdal.GDT_UInt8) dst_band = dst_ds.GetRasterBand(1) gdal.ComputeProximity(src_band, dst_band) @@ -88,7 +88,7 @@ def test_proximity_3(): src_ds = gdal.Open("data/pat.tif") src_band = src_ds.GetRasterBand(1) - dst_ds = drv.Create("tmp/proximity_3.tif", 25, 25, 1, gdal.GDT_Byte) + dst_ds = drv.Create("tmp/proximity_3.tif", 25, 25, 1, gdal.GDT_UInt8) dst_band = dst_ds.GetRasterBand(1) gdal.ComputeProximity( diff --git a/autotest/alg/rasterize.py b/autotest/alg/rasterize.py index 83c80f0c9c1e..16a453f17990 100755 --- a/autotest/alg/rasterize.py +++ b/autotest/alg/rasterize.py @@ -31,7 +31,7 @@ def test_rasterize_1(): # Create a memory raster to rasterize into. - target_ds = gdal.GetDriverByName("MEM").Create("", 100, 100, 3, gdal.GDT_Byte) + target_ds = gdal.GetDriverByName("MEM").Create("", 100, 100, 3, gdal.GDT_UInt8) target_ds.SetGeoTransform((1000, 1, 0, 1100, 0, -1)) target_ds.SetProjection(sr_wkt) @@ -94,7 +94,7 @@ def test_rasterize_2(): # Create a memory raster to rasterize into. - target_ds = gdal.GetDriverByName("MEM").Create("", 12, 12, 3, gdal.GDT_Byte) + target_ds = gdal.GetDriverByName("MEM").Create("", 12, 12, 3, gdal.GDT_UInt8) target_ds.SetGeoTransform((0, 1, 0, 12, 0, -1)) target_ds.SetProjection(sr_wkt) @@ -137,7 +137,7 @@ def test_rasterize_3(): # Create a memory raster to rasterize into. - target_ds = gdal.GetDriverByName("MEM").Create("", 100, 100, 3, gdal.GDT_Byte) + target_ds = gdal.GetDriverByName("MEM").Create("", 100, 100, 3, gdal.GDT_UInt8) target_ds.SetGeoTransform((1000, 1, 0, 1100, 0, -1)) # Create a memory layer to rasterize from. @@ -193,7 +193,7 @@ def test_rasterize_4(): sr = osr.SpatialReference(sr_wkt) # Create a memory raster to rasterize into. - target_ds = gdal.GetDriverByName("MEM").Create("", 100, 100, 3, gdal.GDT_Byte) + target_ds = gdal.GetDriverByName("MEM").Create("", 100, 100, 3, gdal.GDT_UInt8) target_ds.SetGeoTransform((1000, 1, 0, 1100, 0, -1)) target_ds.SetProjection(sr_wkt) @@ -249,7 +249,7 @@ def test_rasterize_5(): # Create a memory raster to rasterize into. - target_ds = gdal.GetDriverByName("MEM").Create("", 100, 100, 3, gdal.GDT_Byte) + target_ds = gdal.GetDriverByName("MEM").Create("", 100, 100, 3, gdal.GDT_UInt8) target_ds.SetGeoTransform((1000, 1, 0, 1100, 0, -1)) target_ds.SetProjection(sr_wkt) @@ -423,7 +423,7 @@ def test_rasterize_6(): feature.SetGeometryDirectly(ogr.CreateGeometryFromWkb(wkb)) layer.CreateFeature(feature) - mask_ds = gdal.GetDriverByName("Mem").Create("", 5000, 5000, 1, gdal.GDT_Byte) + mask_ds = gdal.GetDriverByName("Mem").Create("", 5000, 5000, 1, gdal.GDT_UInt8) mask_ds.SetGeoTransform([499000, 0.4, 0, 6095000, 0, -0.4]) mask_ds.SetProjection(sr_wkt) @@ -441,7 +441,7 @@ def test_rasterize_7(): sr_wkt = 'LOCAL_CS["arbitrary"]' # Create a memory raster to rasterize into. - target_ds = gdal.GetDriverByName("MEM").Create("", 12, 12, 1, gdal.GDT_Byte) + target_ds = gdal.GetDriverByName("MEM").Create("", 12, 12, 1, gdal.GDT_UInt8) target_ds.SetGeoTransform((0, 1, 0, 12, 0, -1)) target_ds.SetProjection(sr_wkt) @@ -484,7 +484,7 @@ def test_rasterize_all_touched_issue_7523(): sr = osr.SpatialReference(sr_wkt) # Create a memory raster to rasterize into. - target_ds = gdal.GetDriverByName("MEM").Create("", 3, 5, 1, gdal.GDT_Byte) + target_ds = gdal.GetDriverByName("MEM").Create("", 3, 5, 1, gdal.GDT_UInt8) target_ds.SetGeoTransform((475435, 5, 0, 424145, 0, -5)) target_ds.SetProjection(sr_wkt) @@ -553,7 +553,7 @@ def test_rasterize_merge_alg_add_multiple_segment_linestring(): ) layer.CreateFeature(feature) - ds = gdal.GetDriverByName("Mem").Create("", 10, 10, 1, gdal.GDT_Byte) + ds = gdal.GetDriverByName("Mem").Create("", 10, 10, 1, gdal.GDT_UInt8) ds.SetGeoTransform([0, 20, 0, 100, 0, -10]) ds.SetProjection(sr_wkt) @@ -799,7 +799,7 @@ def test_rasterize_merge_alg_add_polygon(wkt): feature.SetGeometryDirectly(ogr.CreateGeometryFromWkt(wkt)) layer.CreateFeature(feature) - ds = gdal.GetDriverByName("Mem").Create("", 5, 5, 1, gdal.GDT_Byte) + ds = gdal.GetDriverByName("Mem").Create("", 5, 5, 1, gdal.GDT_UInt8) ds.SetGeoTransform([-0.125, 0.25, 0, 1.125, 0, -0.25]) ds.SetProjection(sr_wkt) @@ -918,7 +918,7 @@ def test_rasterize_bugfix_gh8437(wkt, options, nbands): sr = osr.SpatialReference(sr_wkt) # Create a memory raster to rasterize into. - target_ds = gdal.GetDriverByName("MEM").Create("", 15, 15, nbands, gdal.GDT_Byte) + target_ds = gdal.GetDriverByName("MEM").Create("", 15, 15, nbands, gdal.GDT_UInt8) target_ds.SetGeoTransform((15, -1, 0, 15, 0, -1)) target_ds.SetProjection(sr_wkt) @@ -974,7 +974,7 @@ def test_rasterize_bugfix_gh8918(wkt): sr = osr.SpatialReference(sr_wkt) # Create a memory raster to rasterize into. - target_ds = gdal.GetDriverByName("MEM").Create("", 10, 10, 1, gdal.GDT_Byte) + target_ds = gdal.GetDriverByName("MEM").Create("", 10, 10, 1, gdal.GDT_UInt8) target_ds.SetGeoTransform((0, 1, 0, 0, 0, 1)) target_ds.SetProjection(sr_wkt) @@ -1010,7 +1010,7 @@ def test_rasterize_bugfix_gh12129(): sr = osr.SpatialReference(sr_wkt) # Create a memory raster to rasterize into. - target_ds = gdal.GetDriverByName("MEM").Create("", 20, 16, 1, gdal.GDT_Byte) + target_ds = gdal.GetDriverByName("MEM").Create("", 20, 16, 1, gdal.GDT_UInt8) target_ds.SetGeoTransform((163600, 20, 0, 168000, 0, -20)) target_ds.SetProjection(sr_wkt) @@ -1048,7 +1048,7 @@ def test_rasterize_bugfix_gh12129(): def test_rasterize_huge_geometry(): # Create a memory raster to rasterize into. - target_ds = gdal.GetDriverByName("MEM").Create("", 20, 20, 1, gdal.GDT_Byte) + target_ds = gdal.GetDriverByName("MEM").Create("", 20, 20, 1, gdal.GDT_UInt8) target_ds.SetGeoTransform((0, 1, 0, 0, 0, 1)) v = 1e300 diff --git a/autotest/alg/reproject.py b/autotest/alg/reproject.py index 86dc9b95171a..a9be5a045703 100755 --- a/autotest/alg/reproject.py +++ b/autotest/alg/reproject.py @@ -27,7 +27,7 @@ def test_reproject_1(): src_ds = gdal.Open("../gcore/data/byte.tif") dst_ds = drv.Create( - "tmp/byte.tif", src_ds.RasterXSize, src_ds.RasterYSize, gdal.GDT_Byte + "tmp/byte.tif", src_ds.RasterXSize, src_ds.RasterYSize, gdal.GDT_UInt8 ) dst_ds.SetProjection(src_ds.GetProjectionRef()) dst_ds.SetGeoTransform(src_ds.GetGeoTransform()) @@ -61,7 +61,7 @@ def test_reproject_2(): drv = gdal.GetDriverByName("GTiff") src_ds = gdal.Open("../gcore/data/byte.tif") - dst_ds = drv.Create("tmp/byte_4326.tif", 22, 18, gdal.GDT_Byte) + dst_ds = drv.Create("tmp/byte_4326.tif", 22, 18, gdal.GDT_UInt8) dst_ds.SetGeoTransform( [ -117.641169915168746, diff --git a/autotest/alg/sieve.py b/autotest/alg/sieve.py index 5c45ff3776ae..0043ffc03930 100755 --- a/autotest/alg/sieve.py +++ b/autotest/alg/sieve.py @@ -29,7 +29,7 @@ def test_sieve_1(): src_ds = gdal.Open("data/sieve_src.grd") src_band = src_ds.GetRasterBand(1) - dst_ds = drv.Create("tmp/sieve_1.tif", 5, 7, 1, gdal.GDT_Byte) + dst_ds = drv.Create("tmp/sieve_1.tif", 5, 7, 1, gdal.GDT_UInt8) dst_band = dst_ds.GetRasterBand(1) gdal.SieveFilter(src_band, None, dst_band, 2, 4) @@ -59,7 +59,7 @@ def test_sieve_2(): src_ds = gdal.Open("data/sieve_src.grd") src_band = src_ds.GetRasterBand(1) - dst_ds = drv.Create("tmp/sieve_2.tif", 5, 7, 1, gdal.GDT_Byte) + dst_ds = drv.Create("tmp/sieve_2.tif", 5, 7, 1, gdal.GDT_UInt8) dst_band = dst_ds.GetRasterBand(1) gdal.SieveFilter(src_band, None, dst_band, 2, 8) @@ -89,7 +89,7 @@ def test_sieve_3(): src_ds = gdal.Open("data/unmergable.grd") src_band = src_ds.GetRasterBand(1) - dst_ds = drv.Create("tmp/sieve_3.tif", 5, 7, 1, gdal.GDT_Byte) + dst_ds = drv.Create("tmp/sieve_3.tif", 5, 7, 1, gdal.GDT_UInt8) dst_band = dst_ds.GetRasterBand(1) gdal.SieveFilter(src_band, None, dst_band, 2, 8) @@ -120,7 +120,7 @@ def test_sieve_4(): src_ds = gdal.Open("data/sieve_2634.grd") src_band = src_ds.GetRasterBand(1) - dst_ds = drv.Create("tmp/sieve_4.tif", 10, 8, 1, gdal.GDT_Byte) + dst_ds = drv.Create("tmp/sieve_4.tif", 10, 8, 1, gdal.GDT_UInt8) dst_band = dst_ds.GetRasterBand(1) gdal.SieveFilter(src_band, None, dst_band, 2, 4) @@ -151,7 +151,7 @@ def test_sieve_5(): src_ds = gdal.Open("data/sieve_src.grd") src_band = src_ds.GetRasterBand(1) - dst_ds = drv.Create("tmp/sieve_1.tif", 5, 7, 1, gdal.GDT_Byte) + dst_ds = drv.Create("tmp/sieve_1.tif", 5, 7, 1, gdal.GDT_UInt8) dst_band = dst_ds.GetRasterBand(1) gdal.SieveFilter(src_band, dst_band.GetMaskBand(), dst_band, 2, 4) @@ -235,7 +235,7 @@ def test_sieve_7(): src_ds = gdal.Open("/vsimem/sieve_7.asc") src_band = src_ds.GetRasterBand(1) - dst_ds = drv.Create("/vsimem/sieve_7.tif", 7, 7, 1, gdal.GDT_Byte) + dst_ds = drv.Create("/vsimem/sieve_7.tif", 7, 7, 1, gdal.GDT_UInt8) dst_band = dst_ds.GetRasterBand(1) gdal.SieveFilter(src_band, src_band.GetMaskBand(), dst_band, 4, 4) @@ -293,7 +293,7 @@ def test_sieve_8(): src_ds = gdal.Open("/vsimem/sieve_8.asc") src_band = src_ds.GetRasterBand(1) - dst_ds = drv.Create("/vsimem/sieve_8.tif", 7, 7, 1, gdal.GDT_Byte) + dst_ds = drv.Create("/vsimem/sieve_8.tif", 7, 7, 1, gdal.GDT_UInt8) dst_band = dst_ds.GetRasterBand(1) gdal.SieveFilter(src_band, src_band.GetMaskBand(), dst_band, 4, 4) @@ -322,14 +322,14 @@ def test_sieve_8(): def test_sieve_all_masked(): drv = gdal.GetDriverByName("MEM") - src_ds = drv.Create("", 10, 10, gdal.GDT_Byte) + src_ds = drv.Create("", 10, 10, gdal.GDT_UInt8) src_band = src_ds.GetRasterBand(1) src_band.Fill(1) - mask_ds = drv.Create("", 10, 10, gdal.GDT_Byte) + mask_ds = drv.Create("", 10, 10, gdal.GDT_UInt8) mask_band = mask_ds.GetRasterBand(1) - dst_ds = drv.Create("", 10, 10, gdal.GDT_Byte) + dst_ds = drv.Create("", 10, 10, gdal.GDT_UInt8) dst_band = dst_ds.GetRasterBand(1) expected_cs = src_band.Checksum() diff --git a/autotest/alg/warp.py b/autotest/alg/warp.py index 1eb14c2b82c6..11ae4afba126 100755 --- a/autotest/alg/warp.py +++ b/autotest/alg/warp.py @@ -490,7 +490,7 @@ def test_warp_18(): @pytest.mark.parametrize( "datatype", [ - gdal.GDT_Byte, + gdal.GDT_UInt8, gdal.GDT_Int16, gdal.GDT_CInt16, gdal.GDT_UInt16, @@ -1518,7 +1518,7 @@ def test_warp_53(typestr, option, alg_name, expected_cs): src_ds.GetRasterBand(2).SetColorInterpretation(gdal.GCI_AlphaBand) src_ds.GetRasterBand(2).Fill(255) zero = struct.pack("B" * 1, 0) - src_ds.GetRasterBand(2).WriteRaster(10, 10, 1, 1, zero, buf_type=gdal.GDT_Byte) + src_ds.GetRasterBand(2).WriteRaster(10, 10, 1, 1, zero, buf_type=gdal.GDT_UInt8) dst_ds = gdal.Translate( "", src_ds, options="-outsize 10 10 -of MEM -a_srs EPSG:32611" @@ -1823,7 +1823,7 @@ def test_non_square(): lry = uly + (ds.RasterYSize * yres) assert lrx == pytest.approx(10.5) assert lry == pytest.approx(30.25) - assert ds.GetRasterBand(1).DataType == gdal.GDT_Byte + assert ds.GetRasterBand(1).DataType == gdal.GDT_UInt8 assert struct.unpack("b" * (3 * 3), ds.ReadRaster()) == ( 1, 2, @@ -1837,7 +1837,7 @@ def test_non_square(): ) warped = gdal.AutoCreateWarpedVRT(ds) - assert warped.GetRasterBand(1).DataType == gdal.GDT_Byte + assert warped.GetRasterBand(1).DataType == gdal.GDT_UInt8 assert ( warped.RasterXSize == ds.RasterXSize and warped.RasterYSize == ds.RasterYSize @@ -1871,7 +1871,7 @@ def test_non_square(): def test_warp_average_excluded_values(): - src_ds = gdal.GetDriverByName("MEM").Create("", 2, 2, 3, gdal.GDT_Byte) + src_ds = gdal.GetDriverByName("MEM").Create("", 2, 2, 3, gdal.GDT_UInt8) src_ds.GetRasterBand(1).WriteRaster( 0, 0, 2, 2, struct.pack("B" * 4, 10, 20, 30, 40) ) @@ -1946,7 +1946,7 @@ def test_warp_average_excluded_values(): def test_warp_average_NODATA_VALUES_PCT_THRESHOLD(): - src_ds = gdal.GetDriverByName("MEM").Create("", 2, 2, 1, gdal.GDT_Byte) + src_ds = gdal.GetDriverByName("MEM").Create("", 2, 2, 1, gdal.GDT_UInt8) src_ds.GetRasterBand(1).WriteRaster( 0, 0, 2, 2, struct.pack("B" * 4, 10, 20, 30, 40) ) @@ -1985,7 +1985,7 @@ def test_warp_average_NODATA_VALUES_PCT_THRESHOLD(): @pytest.mark.parametrize( "dt,expected_val", [ - (gdal.GDT_Byte, 1.0), + (gdal.GDT_UInt8, 1.0), (gdal.GDT_Int8, -1.0), (gdal.GDT_UInt16, 1.0), (gdal.GDT_Int16, -1.0), @@ -2128,7 +2128,7 @@ def test_warp_validate_options(): "dt", [ gdal.GDT_Int8, - gdal.GDT_Byte, + gdal.GDT_UInt8, gdal.GDT_Int16, gdal.GDT_UInt16, gdal.GDT_Int32, diff --git a/autotest/gcore/band_arithmetic.py b/autotest/gcore/band_arithmetic.py index 7bcd34e65cc2..24fd13b23f5d 100755 --- a/autotest/gcore/band_arithmetic.py +++ b/autotest/gcore/band_arithmetic.py @@ -218,7 +218,7 @@ def greylevel(): R = ds.GetRasterBand(1) G = ds.GetRasterBand(2) B = ds.GetRasterBand(3) - return (0.299 * R + 0.587 * G + 0.114 * B).astype(gdal.GDT_Byte) + return (0.299 * R + 0.587 * G + 0.114 * B).astype(gdal.GDT_UInt8) assert greylevel().Checksum() == 21466 @@ -229,7 +229,7 @@ def test_band_arithmetic_rgb_to_greylevel_with(): R = ds.GetRasterBand(1) G = ds.GetRasterBand(2) B = ds.GetRasterBand(3) - greylevel = (0.299 * R + 0.587 * G + 0.114 * B).astype(gdal.GDT_Byte) + greylevel = (0.299 * R + 0.587 * G + 0.114 * B).astype(gdal.GDT_UInt8) assert greylevel.Checksum() == 21466 @@ -239,7 +239,7 @@ def test_band_arithmetic_rgb_to_greylevel_with_error(): R = ds.GetRasterBand(1) G = ds.GetRasterBand(2) B = ds.GetRasterBand(3) - greylevel = (0.299 * R + 0.587 * G + 0.114 * B).astype(gdal.GDT_Byte) + greylevel = (0.299 * R + 0.587 * G + 0.114 * B).astype(gdal.GDT_UInt8) with pytest.raises(Exception): greylevel.Checksum() @@ -255,7 +255,7 @@ def greylevel(): R = ds.GetRasterBand(1) G = ds.GetRasterBand(2).ReadAsArray() B = ds.GetRasterBand(3).ReadAsArray() - return (0.299 * R + 0.587 * G + 0.114 * B).astype(gdal.GDT_Byte) + return (0.299 * R + 0.587 * G + 0.114 * B).astype(gdal.GDT_UInt8) assert greylevel().Checksum() == 21466 @@ -274,7 +274,7 @@ def get(): return gdal.minimum(R, G) res = get() - assert res.DataType == gdal.GDT_Byte + assert res.DataType == gdal.GDT_UInt8 assert res.ComputeRasterMinMax(False) == (2, 2) @@ -288,7 +288,7 @@ def get(): return gdal.minimum(R, 3, G) res = get() - assert res.DataType == gdal.GDT_Byte + assert res.DataType == gdal.GDT_UInt8 assert res.ComputeRasterMinMax(False) == (2, 2) @@ -329,7 +329,7 @@ def get(): return gdal.maximum(R, G) res = get() - assert res.DataType == gdal.GDT_Byte + assert res.DataType == gdal.GDT_UInt8 assert res.ComputeRasterMinMax(False) == (4, 4) @@ -343,7 +343,7 @@ def get(): return gdal.maximum(R, 3, G) res = get() - assert res.DataType == gdal.GDT_Byte + assert res.DataType == gdal.GDT_UInt8 assert res.ComputeRasterMinMax(False) == (4, 4) @@ -380,7 +380,7 @@ def test_band_arithmetic_rgb_to_greylevel_vrt(tmp_vsimem): R = ds.GetRasterBand(1) G = ds.GetRasterBand(2) B = ds.GetRasterBand(3) - greylevel = (0.299 * R + 0.587 * G + 0.114 * B).astype(gdal.GDT_Byte) + greylevel = (0.299 * R + 0.587 * G + 0.114 * B).astype(gdal.GDT_UInt8) gdal.GetDriverByName("VRT").CreateCopy(tmp_vsimem / "out.vrt", greylevel) ds = gdal.Open(tmp_vsimem / "out.vrt") @@ -426,7 +426,7 @@ def get(): res = get() assert res.GetNoDataValue() == 1 - assert res.ReadRaster(buf_type=gdal.GDT_Byte) == b"\x01\x06" + assert res.ReadRaster(buf_type=gdal.GDT_UInt8) == b"\x01\x06" def test_band_arithmetic_add_nodata_nan(): @@ -691,19 +691,19 @@ def test_band_arithmetic_ternary(): elseBand = ds.GetRasterBand(3) elseBand.Fill(3) - assert gdal.where(cond, then, elseBand).DataType == gdal.GDT_Byte + assert gdal.where(cond, then, elseBand).DataType == gdal.GDT_UInt8 assert gdal.where(cond, then, elseBand).ComputeRasterMinMax(False)[0] == 2 - assert gdal.where(cond, 10, elseBand).DataType == gdal.GDT_Byte + assert gdal.where(cond, 10, elseBand).DataType == gdal.GDT_UInt8 assert gdal.where(cond, 10, elseBand).ComputeRasterMinMax(False)[0] == 10 assert gdal.where(cond, 10, 11).ComputeRasterMinMax(False)[0] == 10 cond.Fill(0) - assert gdal.where(cond, then, elseBand).DataType == gdal.GDT_Byte + assert gdal.where(cond, then, elseBand).DataType == gdal.GDT_UInt8 assert gdal.where(cond, then, elseBand).ComputeRasterMinMax(False)[0] == 3 - assert gdal.where(cond, then, 11).DataType == gdal.GDT_Byte + assert gdal.where(cond, then, 11).DataType == gdal.GDT_UInt8 assert gdal.where(cond, then, 11).ComputeRasterMinMax(False)[0] == 11 assert gdal.where(cond, 10, 11).ComputeRasterMinMax(False)[0] == 11 diff --git a/autotest/gcore/basic_test.py b/autotest/gcore/basic_test.py index 1ca1c81a9baf..a28852b1c25b 100755 --- a/autotest/gcore/basic_test.py +++ b/autotest/gcore/basic_test.py @@ -651,7 +651,7 @@ def test_gdal_setgcpspatialref(): def test_gdal_getdatatypename(): - assert gdal.GetDataTypeName(gdal.GDT_Byte) == "Byte" + assert gdal.GetDataTypeName(gdal.GDT_UInt8) == "Byte" with pytest.raises(Exception): gdal.GetDataTypeName(-1) with pytest.raises(Exception): @@ -763,7 +763,7 @@ def test_gdal_EscapeString_errors(): def test_gdal_DataTypeUnion(): - assert gdal.DataTypeUnion(gdal.GDT_Byte, gdal.GDT_UInt16) == gdal.GDT_UInt16 + assert gdal.DataTypeUnion(gdal.GDT_UInt8, gdal.GDT_UInt16) == gdal.GDT_UInt16 def test_exceptionmanager(): @@ -1180,3 +1180,14 @@ def test_basic_get_extent_rotated(): assert ds.GetExtent() == pytest.approx( (1840900, 1841030, 1143870, 1144000), abs=4 ) + + +def test_basic_GetDataTypeByName(): + + assert gdal.GetDataTypeByName("Byte") == gdal.GDT_Byte + assert gdal.GetDataTypeByName("Byte") == gdal.GDT_UInt8 + assert gdal.GetDataTypeByName("UInt8") == gdal.GDT_Byte + assert gdal.GetDataTypeByName("UInt8") == gdal.GDT_UInt8 + + # For now, to avoid breaking backwards compatibility + assert gdal.GetDataTypeName(gdal.GDT_UInt8) == "Byte" diff --git a/autotest/gcore/gdal_stats.py b/autotest/gcore/gdal_stats.py index bffb9a05f036..c4924e7af97c 100755 --- a/autotest/gcore/gdal_stats.py +++ b/autotest/gcore/gdal_stats.py @@ -813,7 +813,7 @@ def test_stats_nodata_almost_max_float32(): # Test STATISTICS_APPROXIMATE -def test_stats_approx_stats_flag(dt=gdal.GDT_Byte, struct_frmt="B"): +def test_stats_approx_stats_flag(dt=gdal.GDT_UInt8, struct_frmt="B"): ds = gdal.GetDriverByName("MEM").Create("", 2000, 2000, 1, dt) ds.GetRasterBand(1).WriteRaster(1000, 1000, 1, 1, struct.pack(struct_frmt * 1, 20)) @@ -914,8 +914,8 @@ def test_stats_clear(): @pytest.mark.parametrize( "datatype,minval,maxval", [ - (gdal.GDT_Byte, 1, 254), - (gdal.GDT_Byte, -127, 127), + (gdal.GDT_UInt8, 1, 254), + (gdal.GDT_UInt8, -127, 127), (gdal.GDT_UInt16, 1, 65535), (gdal.GDT_Int16, -32767, 32766), (gdal.GDT_UInt32, 1, (1 << 32) - 2), @@ -943,7 +943,7 @@ def test_stats_computeminmax(datatype, minval, maxval, nodata): ds = gdal.GetDriverByName("MEM").Create("", 64, 1, 1, datatype) minval_mod = minval expected_minval = minval - if datatype == gdal.GDT_Byte and minval < 0: + if datatype == gdal.GDT_UInt8 and minval < 0: ds.GetRasterBand(1).SetMetadataItem( "PIXELTYPE", "SIGNEDBYTE", "IMAGE_STRUCTURE" ) @@ -1158,7 +1158,7 @@ def test_stats_float64_nan_with_nodata(tmp_vsimem, GDAL_STATS_USE_FLOAT64_OPTIM) @pytest.mark.parametrize( "datatype", [ - gdal.GDT_Byte, + gdal.GDT_UInt8, gdal.GDT_Int8, gdal.GDT_UInt16, gdal.GDT_Int16, @@ -1174,7 +1174,7 @@ def test_stats_float64_nan_with_nodata(tmp_vsimem, GDAL_STATS_USE_FLOAT64_OPTIM) def test_stats_minmax_one_two(datatype): ds = gdal.GetDriverByName("MEM").Create("", 2, 1, 1, datatype) - ds.GetRasterBand(1).WriteRaster(0, 0, 2, 1, b"\x01\x02", buf_type=gdal.GDT_Byte) + ds.GetRasterBand(1).WriteRaster(0, 0, 2, 1, b"\x01\x02", buf_type=gdal.GDT_UInt8) assert ds.GetRasterBand(1).ComputeRasterMinMax() == (1.0, 2.0) @@ -1184,7 +1184,7 @@ def test_stats_minmax_one_two(datatype): @pytest.mark.parametrize( "datatype", [ - gdal.GDT_Byte, + gdal.GDT_UInt8, gdal.GDT_Int8, gdal.GDT_UInt16, gdal.GDT_Int16, @@ -1211,7 +1211,7 @@ def test_stats_minmax_all_invalid_nodata(datatype): @pytest.mark.parametrize( "datatype", [ - gdal.GDT_Byte, + gdal.GDT_UInt8, gdal.GDT_Int8, gdal.GDT_UInt16, gdal.GDT_Int16, diff --git a/autotest/gcore/hdf4multidim.py b/autotest/gcore/hdf4multidim.py index 68c5732624e1..cb2d3feddc19 100644 --- a/autotest/gcore/hdf4multidim.py +++ b/autotest/gcore/hdf4multidim.py @@ -219,7 +219,7 @@ def test_hdf4multidim_gdal_sds_2d(): assert len(dims) == 2 assert dims[0].GetFullName() == "/Y" assert dims[1].GetFullName() == "/X" - assert array.GetDataType().GetNumericDataType() == gdal.GDT_Byte + assert array.GetDataType().GetNumericDataType() == gdal.GDT_UInt8 got_data = array.Read(array_start_idx=[0, 0], count=[2, 2]) assert len(got_data) == 2 * 2 @@ -266,7 +266,7 @@ def test_hdf4multidim_gdal_sds_3d(): assert dims[0].GetFullName() == "/Y" assert dims[1].GetFullName() == "/X" assert dims[2].GetFullName() == "/Band" - assert array.GetDataType().GetNumericDataType() == gdal.GDT_Byte + assert array.GetDataType().GetNumericDataType() == gdal.GDT_UInt8 got_data = array.Read(array_start_idx=[0, 0, 0], count=[2, 2, 1]) assert len(got_data) == 2 * 2 diff --git a/autotest/gcore/hfa_rfc40.py b/autotest/gcore/hfa_rfc40.py index 1c4e41b347df..34470be34fea 100755 --- a/autotest/gcore/hfa_rfc40.py +++ b/autotest/gcore/hfa_rfc40.py @@ -64,7 +64,7 @@ def CreateAndWriteRAT(fname): """ # create driver = gdal.GetDriverByName("HFA") - ds = driver.Create(fname, 10, 10, 1, gdal.GDT_Byte) + ds = driver.Create(fname, 10, 10, 1, gdal.GDT_UInt8) ds.SetGeoTransform([0, 1, 0, 0, 0, -1]) diff --git a/autotest/gcore/hfa_write.py b/autotest/gcore/hfa_write.py index 1954912f6304..c0bbd9e024c3 100755 --- a/autotest/gcore/hfa_write.py +++ b/autotest/gcore/hfa_write.py @@ -88,7 +88,7 @@ def test_hfa_write_nd_invalid(tmp_path): img_path = tmp_path / "ndinvalid.img" drv = gdal.GetDriverByName("HFA") - ds = drv.Create(img_path, 512, 512, 1, gdal.GDT_Byte, []) + ds = drv.Create(img_path, 512, 512, 1, gdal.GDT_UInt8, []) ds.GetRasterBand(1).SetNoDataValue(200) ds = None diff --git a/autotest/gcore/mask.py b/autotest/gcore/mask.py index b5dad850f8d4..f9fef1302c2a 100755 --- a/autotest/gcore/mask.py +++ b/autotest/gcore/mask.py @@ -634,7 +634,7 @@ def test_mask_19(): def test_mask_20(): types = [ - gdal.GDT_Byte, + gdal.GDT_UInt8, gdal.GDT_Int16, gdal.GDT_UInt16, gdal.GDT_Int32, @@ -675,7 +675,7 @@ def test_mask_20(): def test_mask_21(): types = [ - gdal.GDT_Byte, + gdal.GDT_UInt8, gdal.GDT_Int16, gdal.GDT_UInt16, gdal.GDT_Int32, @@ -959,13 +959,13 @@ def test_mask_27(): # Test setting nodata after having first queried GetMaskBand() -@pytest.mark.parametrize("dt", [gdal.GDT_Byte, gdal.GDT_Int64, gdal.GDT_UInt64]) +@pytest.mark.parametrize("dt", [gdal.GDT_UInt8, gdal.GDT_Int64, gdal.GDT_UInt64]) @pytest.mark.parametrize( "GDAL_SIMUL_MEM_ALLOC_FAILURE_NODATA_MASK_BAND", [None, "YES", "ALWAYS"] ) def test_mask_setting_nodata(dt, GDAL_SIMUL_MEM_ALLOC_FAILURE_NODATA_MASK_BAND): def set_nodata_value(ds, val): - if dt == gdal.GDT_Byte: + if dt == gdal.GDT_UInt8: ds.GetRasterBand(1).SetNoDataValue(val) elif dt == gdal.GDT_Int64: ds.GetRasterBand(1).SetNoDataValueAsInt64(val) @@ -980,14 +980,14 @@ def test(): got = ds.GetRasterBand(1).GetMaskBand().ReadRaster() if ( GDAL_SIMUL_MEM_ALLOC_FAILURE_NODATA_MASK_BAND == "ALWAYS" - and dt != gdal.GDT_Byte + and dt != gdal.GDT_UInt8 ): assert got is None assert gdal.GetLastErrorType() == gdal.CE_Failure else: if ( GDAL_SIMUL_MEM_ALLOC_FAILURE_NODATA_MASK_BAND == "YES" - and dt != gdal.GDT_Byte + and dt != gdal.GDT_UInt8 ): assert gdal.GetLastErrorType() == gdal.CE_Warning assert got == struct.pack("B", 0) diff --git a/autotest/gcore/misc.py b/autotest/gcore/misc.py index 85714ce311aa..fd739b3cc7e4 100755 --- a/autotest/gcore/misc.py +++ b/autotest/gcore/misc.py @@ -236,7 +236,7 @@ def test_misc_5(): # MBTiles only support some precise resolutions continue if "DCAP_CREATE" in md and "DCAP_RASTER" in md: - datatype = gdal.GDT_Byte + datatype = gdal.GDT_UInt8 for nBands in range(6): _misc_5_internal(drv, datatype, nBands) @@ -475,7 +475,7 @@ def test_misc_6(): # w.r.t system/OS crashes, unless you know what you are doing. with gdal.config_option("OGR_SQLITE_SYNCHRONOUS", "OFF"): - datatype = gdal.GDT_Byte + datatype = gdal.GDT_UInt8 setDriversDone = set() for nBands in range(6): misc_6_internal(datatype, nBands, setDriversDone) @@ -546,7 +546,7 @@ def test_update_metadata(tmp_path, tmp_vsimem, driver_name): if "RasterValues" in flags_str: assert ( update_ds.GetRasterBand(1).WriteRaster( - 0, 0, 1, 1, b"\x00", buf_type=gdal.GDT_Byte + 0, 0, 1, 1, b"\x00", buf_type=gdal.GDT_UInt8 ) == gdal.CE_None ) @@ -712,7 +712,7 @@ def test_misc_12(): if drv.ShortName == "WEBP" or drv.ShortName == "ADRG": nbands = 3 - datatype = gdal.GDT_Byte + datatype = gdal.GDT_UInt8 if drv.ShortName == "BT" or drv.ShortName == "BLX": datatype = gdal.GDT_Int16 elif ( diff --git a/autotest/gcore/multidim.py b/autotest/gcore/multidim.py index 212f0211b6da..6f1c4d545bd2 100644 --- a/autotest/gcore/multidim.py +++ b/autotest/gcore/multidim.py @@ -327,7 +327,7 @@ def test_multidim_getresampled_3d(): dimY = ar_b1.GetDimensions()[0] dimX = ar_b1.GetDimensions()[1] ar = rg.CreateMDArray( - "ar", [dimBand, dimY, dimX], gdal.ExtendedDataType.Create(gdal.GDT_Byte) + "ar", [dimBand, dimY, dimX], gdal.ExtendedDataType.Create(gdal.GDT_UInt8) ) ar.SetOffset(1.5) ar.SetScale(2.5) @@ -377,7 +377,7 @@ def test_multidim_getresampled_error_single_dim(): mem_ds = drv.CreateMultiDimensional("myds") rg = mem_ds.GetRootGroup() dimX = rg.CreateDimension("X", None, None, 3) - ar = rg.CreateMDArray("ar", [dimX], gdal.ExtendedDataType.Create(gdal.GDT_Byte)) + ar = rg.CreateMDArray("ar", [dimX], gdal.ExtendedDataType.Create(gdal.GDT_UInt8)) with gdal.quiet_errors(): resampled_ar = ar.GetResampled([None], gdal.GRIORA_NearestNeighbour, None) assert resampled_ar is None @@ -391,7 +391,7 @@ def test_multidim_getresampled_error_too_large_y(): dimY = rg.CreateDimension("Y", None, None, 4) dimX = rg.CreateDimension("X", None, None, 3) ar = rg.CreateMDArray( - "ar", [dimY, dimX], gdal.ExtendedDataType.Create(gdal.GDT_Byte) + "ar", [dimY, dimX], gdal.ExtendedDataType.Create(gdal.GDT_UInt8) ) new_dimY = rg.CreateDimension("Y", None, None, 4 * 1000 * 1000 * 1000) with gdal.quiet_errors(): @@ -409,7 +409,7 @@ def test_multidim_getresampled_error_too_large_x(): dimY = rg.CreateDimension("Y", None, None, 4) dimX = rg.CreateDimension("X", None, None, 3) ar = rg.CreateMDArray( - "ar", [dimY, dimX], gdal.ExtendedDataType.Create(gdal.GDT_Byte) + "ar", [dimY, dimX], gdal.ExtendedDataType.Create(gdal.GDT_UInt8) ) new_dimX = rg.CreateDimension("Y", None, None, 4 * 1000 * 1000 * 1000) with gdal.quiet_errors(): @@ -427,7 +427,7 @@ def test_multidim_getresampled_error_no_geotransform(): dimY = rg.CreateDimension("Y", None, None, 2) dimX = rg.CreateDimension("X", None, None, 3) ar = rg.CreateMDArray( - "ar", [dimY, dimX], gdal.ExtendedDataType.Create(gdal.GDT_Byte) + "ar", [dimY, dimX], gdal.ExtendedDataType.Create(gdal.GDT_UInt8) ) with gdal.quiet_errors(): resampled_ar = ar.GetResampled([None, None], gdal.GRIORA_NearestNeighbour, None) @@ -446,7 +446,7 @@ def test_multidim_getresampled_error_extra_dim_not_same(): dimY = ar_b1.GetDimensions()[0] dimX = ar_b1.GetDimensions()[1] ar = rg.CreateMDArray( - "ar", [dimOther, dimY, dimX], gdal.ExtendedDataType.Create(gdal.GDT_Byte) + "ar", [dimOther, dimY, dimX], gdal.ExtendedDataType.Create(gdal.GDT_UInt8) ) dimOtherNew = rg.CreateDimension("otherNew", None, None, 1) @@ -1298,7 +1298,9 @@ def test_multidim_SubsetDimensionFromSelection(): "too_large_dim", None, None, 10 * 1024 * 1024 + 1 ) rg.CreateMDArray( - "too_large_dim_ar", [too_large_dim], gdal.ExtendedDataType.Create(gdal.GDT_Byte) + "too_large_dim_ar", + [too_large_dim], + gdal.ExtendedDataType.Create(gdal.GDT_UInt8), ) same_value = rg.CreateMDArray( @@ -1947,7 +1949,7 @@ def test_multidim_dataset_as_mdarray_errors(): with pytest.raises(Exception, match="Non-uniform data type amongst bands"): with gdal.GetDriverByName("MEM").Create("", 1, 1, 0) as ds: - ds.AddBand(gdal.GDT_Byte) + ds.AddBand(gdal.GDT_UInt8) ds.AddBand(gdal.GDT_UInt16) ds.AsMDArray() diff --git a/autotest/gcore/nodatamaskband.py b/autotest/gcore/nodatamaskband.py index 276436eddf42..cbb492b8f9b9 100755 --- a/autotest/gcore/nodatamaskband.py +++ b/autotest/gcore/nodatamaskband.py @@ -22,7 +22,7 @@ @pytest.mark.parametrize( "dt,struct_type,v", [ - (gdal.GDT_Byte, "B", 255), + (gdal.GDT_UInt8, "B", 255), (gdal.GDT_Int8, "b", 127), (gdal.GDT_Int16, "h", 32767), (gdal.GDT_UInt16, "H", 65535), diff --git a/autotest/gcore/numpy_rw.py b/autotest/gcore/numpy_rw.py index 889236c10890..09181b983be2 100755 --- a/autotest/gcore/numpy_rw.py +++ b/autotest/gcore/numpy_rw.py @@ -260,7 +260,7 @@ def test_numpy_rw_10_bis(options): @pytest.mark.parametrize( "name,in_dt,np_dt,val", [ - ("uint8", gdal.GDT_Byte, numpy.uint8, 255), + ("uint8", gdal.GDT_UInt8, numpy.uint8, 255), ("uint16", gdal.GDT_UInt16, numpy.uint16, 65535), ("int16", gdal.GDT_Int16, numpy.int16, -32767), ("uint32", gdal.GDT_UInt32, numpy.uint32, 4294967295), @@ -343,7 +343,7 @@ def test_numpy_rw_12(): ar[1][1] = 3 drv = gdal.GetDriverByName("MEM") - ds = drv.Create("", 1, 2, 1, gdal.GDT_Byte) + ds = drv.Create("", 1, 2, 1, gdal.GDT_UInt8) ds.GetRasterBand(1).WriteArray(ar[:, 1:]) @@ -362,7 +362,7 @@ def test_numpy_rw_12(): def test_numpy_rw_13(): drv = gdal.GetDriverByName("MEM") - ds = drv.Create("", 2, 1, 1, gdal.GDT_Byte) + ds = drv.Create("", 2, 1, 1, gdal.GDT_UInt8) ar = numpy.empty([1, 2], dtype=numpy.uint8) ar[0][0] = 100 ar[0][1] = 200 @@ -426,7 +426,7 @@ def test_numpy_rw_13(): # With a multiband file drv = gdal.GetDriverByName("MEM") - ds = drv.Create("", 2, 1, 3, gdal.GDT_Byte) + ds = drv.Create("", 2, 1, 3, gdal.GDT_UInt8) ar = numpy.empty([3, 1, 2], dtype=numpy.uint8) ar[0][0][0] = 100 ar[0][0][1] = 200 @@ -491,7 +491,7 @@ def test_numpy_rw_13(): # This one should be OK ! ar = numpy.zeros([3, 1, 2], dtype=numpy.uint8) - ds.ReadAsArray(buf_obj=ar, buf_xsize=2, buf_ysize=1, buf_type=gdal.GDT_Byte) + ds.ReadAsArray(buf_obj=ar, buf_xsize=2, buf_ysize=1, buf_type=gdal.GDT_UInt8) assert ( ar[0][0][0] == 100 and ar[0][0][1] == 200 diff --git a/autotest/gcore/numpy_rw_multidim.py b/autotest/gcore/numpy_rw_multidim.py index f4c4e55c8ab4..9d96a6226465 100755 --- a/autotest/gcore/numpy_rw_multidim.py +++ b/autotest/gcore/numpy_rw_multidim.py @@ -48,7 +48,7 @@ def test_numpy_rw_multidim_readasarray_writearray(): dim0 = rg.CreateDimension("dim0", None, None, 2) dim1 = rg.CreateDimension("dim1", None, None, 3) myarray = rg.CreateMDArray( - "myarray", [dim0, dim1], gdal.ExtendedDataType.Create(gdal.GDT_Byte) + "myarray", [dim0, dim1], gdal.ExtendedDataType.Create(gdal.GDT_UInt8) ) assert myarray ar = np.array([[1, 2, 3], [4, 5, 6]], dtype=np.uint8) @@ -126,7 +126,7 @@ def test_numpy_rw_multidim_readasarray_writearray_negative_strides(): dim0 = rg.CreateDimension("dim0", None, None, 2) dim1 = rg.CreateDimension("dim1", None, None, 3) myarray = rg.CreateMDArray( - "myarray", [dim0, dim1], gdal.ExtendedDataType.Create(gdal.GDT_Byte) + "myarray", [dim0, dim1], gdal.ExtendedDataType.Create(gdal.GDT_UInt8) ) assert myarray ar = np.array([[1, 2, 3], [4, 5, 6]], dtype=np.uint8) @@ -238,7 +238,7 @@ def test_numpy_rw_multidim_compound_datatype(): @pytest.mark.parametrize( "datatype", [ - gdal.GDT_Byte, + gdal.GDT_UInt8, gdal.GDT_Int16, gdal.GDT_UInt16, gdal.GDT_Int32, diff --git a/autotest/gcore/pixfun.py b/autotest/gcore/pixfun.py index ef1b5795b4e9..0782314f367a 100755 --- a/autotest/gcore/pixfun.py +++ b/autotest/gcore/pixfun.py @@ -537,7 +537,7 @@ def test_pixfun_div_r(): @pytest.mark.parametrize( "dtype,expected", - [(gdal.GDT_Float32, float("inf")), (gdal.GDT_Int16, 32767), (gdal.GDT_Byte, 255)], + [(gdal.GDT_Float32, float("inf")), (gdal.GDT_Int16, 32767), (gdal.GDT_UInt8, 255)], ) def test_pixfun_div_by_zero(tmp_vsimem, dtype, expected): diff --git a/autotest/gcore/rasterio.py b/autotest/gcore/rasterio.py index f241bc27c3f4..0e6c358ee09a 100755 --- a/autotest/gcore/rasterio.py +++ b/autotest/gcore/rasterio.py @@ -42,7 +42,7 @@ def test_rasterio_1(): ds.RasterXSize, ds.RasterYSize, data, - buf_type=gdal.GDT_Byte, + buf_type=gdal.GDT_UInt8, buf_xsize=1, buf_ysize=1, ) @@ -76,7 +76,7 @@ def test_rasterio_2(): ds.RasterXSize, ds.RasterYSize, data, - buf_type=gdal.GDT_Byte, + buf_type=gdal.GDT_UInt8, buf_xsize=5, buf_ysize=4, ) @@ -122,12 +122,12 @@ def test_rasterio_3(): k + 1, m + 1, data[xsize][ysize], - buf_type=gdal.GDT_Byte, + buf_type=gdal.GDT_UInt8, buf_xsize=xsize + 1, buf_ysize=ysize + 1, ) data2 = ds.ReadRaster( - i, j, k + 1, m + 1, xsize + 1, ysize + 1, gdal.GDT_Byte + i, j, k + 1, m + 1, xsize + 1, ysize + 1, gdal.GDT_UInt8 ) assert ( data2 == data[xsize][ysize] @@ -179,12 +179,12 @@ def test_rasterio_4(): k + 1, m + 1, data[(xsize + 1) * (ysize + 1) - 1], - buf_type=gdal.GDT_Byte, + buf_type=gdal.GDT_UInt8, buf_xsize=xsize + 1, buf_ysize=ysize + 1, ) data2 = ds.ReadRaster( - i, j, k + 1, m + 1, xsize + 1, ysize + 1, gdal.GDT_Byte + i, j, k + 1, m + 1, xsize + 1, ysize + 1, gdal.GDT_UInt8 ) if data2 != data[(xsize + 1) * (ysize + 1) - 1]: print(i, j, k, m, xsize, ysize) @@ -486,7 +486,7 @@ def rasterio_9_progress_callback(pct, message, user_data): return 1 # 1 to continue, 0 to stop -def rasterio_9_checksum(data, buf_xsize, buf_ysize, data_type=gdal.GDT_Byte): +def rasterio_9_checksum(data, buf_xsize, buf_ysize, data_type=gdal.GDT_UInt8): ds = gdal.GetDriverByName("MEM").Create("", buf_xsize, buf_ysize, 1) ds.GetRasterBand(1).WriteRaster( 0, 0, buf_xsize, buf_ysize, data, buf_type=data_type @@ -563,7 +563,7 @@ def test_rasterio_9(): tab = [0, None] complex_ds = gdal.GetDriverByName("MEM").Create("", 20, 20, 1, gdal.GDT_CInt16) complex_ds.GetRasterBand(1).WriteRaster( - 0, 0, 20, 20, ds.GetRasterBand(1).ReadRaster(), buf_type=gdal.GDT_Byte + 0, 0, 20, 20, ds.GetRasterBand(1).ReadRaster(), buf_type=gdal.GDT_UInt8 ) data = complex_ds.GetRasterBand(1).ReadRaster( buf_xsize=10, @@ -713,7 +713,7 @@ def test_rasterio_overview_subpixel_resampling(): numpy = pytest.importorskip("numpy") temp_path = "/vsimem/rasterio_ovr.tif" - ds = gdal.GetDriverByName("GTiff").Create(temp_path, 8, 8, 1, gdal.GDT_Byte) + ds = gdal.GetDriverByName("GTiff").Create(temp_path, 8, 8, 1, gdal.GDT_UInt8) ds.GetRasterBand(1).WriteArray( numpy.array( [ @@ -892,7 +892,7 @@ def test_rasterio_13(dt): mem_ds.GetRasterBand(1).SetNoDataValue(0) if dt == gdal.GDT_Int8: x = (1 << 7) - 1 - elif dt == gdal.GDT_Byte: + elif dt == gdal.GDT_UInt8: x = (1 << 8) - 1 elif dt == gdal.GDT_Int16: x = (1 << 15) - 1 @@ -965,7 +965,7 @@ def test_rasterio_nearest_or_mode(dt, resample_alg, use_nan): mem_ds = gdal.GetDriverByName("MEM").Create("", 4, 4, 1, dt) if dt == gdal.GDT_Int8: x = (1 << 7) - 1 - elif dt == gdal.GDT_Byte: + elif dt == gdal.GDT_UInt8: x = (1 << 8) - 1 elif dt == gdal.GDT_Int16 or dt == gdal.GDT_CInt16: x = (1 << 15) - 1 @@ -1226,7 +1226,7 @@ def test_rasterio_nodata(): ndv = 123 btype = [ - gdal.GDT_Byte, + gdal.GDT_UInt8, gdal.GDT_Int16, gdal.GDT_Int32, gdal.GDT_Float32, @@ -1583,7 +1583,7 @@ def test_rasterio_average_halfsize_downsampling_byte(): v32 = 220 m8 = (v29 + v30 + v31 + v32 + 2) >> 2 - ds = gdal.GetDriverByName("MEM").Create("", 64 + 2, 4, 1, gdal.GDT_Byte) + ds = gdal.GetDriverByName("MEM").Create("", 64 + 2, 4, 1, gdal.GDT_UInt8) ds.WriteRaster( 0, 0, @@ -2740,7 +2740,7 @@ def internal_test_rasterio_rms_halfsize_downsampling_byte_content(gdal_dt, struc def test_rasterio_rms_halfsize_downsampling_byte(): - internal_test_rasterio_rms_halfsize_downsampling_byte_content(gdal.GDT_Byte, "B") + internal_test_rasterio_rms_halfsize_downsampling_byte_content(gdal.GDT_UInt8, "B") ############################################################################### @@ -2750,7 +2750,7 @@ def test_rasterio_rms_halfsize_downsampling_byte(): def test_rasterio_rms_halfsize_downsampling_byte_nodata_not_hit(): - ds = gdal.GetDriverByName("MEM").Create("", 20, 6, 1, gdal.GDT_Byte) + ds = gdal.GetDriverByName("MEM").Create("", 20, 6, 1, gdal.GDT_UInt8) ds.GetRasterBand(1).SetNoDataValue(180) ds.WriteRaster( 0, @@ -3649,7 +3649,7 @@ def test_rasterio_float64(resample_alg): @pytest.mark.parametrize( "dt,struct_type,val", [ - (gdal.GDT_Byte, "B", 255), + (gdal.GDT_UInt8, "B", 255), (gdal.GDT_UInt16, "H", 65535), (gdal.GDT_Float32, "f", 1.5), (gdal.GDT_Float32, "f", struct.unpack(""], "xml:ESRI") ds.SetMetadataItem("BaseTest", "Value") @@ -5203,7 +5209,7 @@ def test_tiff_write_123(): # From implicit RGB to BGR (with Photometric = MinIsBlack) ds = gdaltest.tiff_drv.Create( - "/vsimem/tiff_write_123_bgr.tif", 1, 1, 3, gdal.GDT_Byte + "/vsimem/tiff_write_123_bgr.tif", 1, 1, 3, gdal.GDT_UInt8 ) assert ds.GetMetadataItem("TIFFTAG_PHOTOMETRIC", "_DEBUG_") == "2" assert ds.GetMetadataItem("TIFFTAG_EXTRASAMPLES", "_DEBUG_") is None @@ -5269,7 +5275,7 @@ def test_tiff_write_123(): # From implicit RGBA to MINISBLACK ds = gdaltest.tiff_drv.Create( - "/vsimem/tiff_write_123_rgba.tif", 1, 1, 4, gdal.GDT_Byte + "/vsimem/tiff_write_123_rgba.tif", 1, 1, 4, gdal.GDT_UInt8 ) assert ds.GetMetadataItem("TIFFTAG_PHOTOMETRIC", "_DEBUG_") == "2" assert ds.GetRasterBand(1).GetColorInterpretation() == gdal.GCI_RedBand @@ -5287,7 +5293,7 @@ def test_tiff_write_123(): # From that implicit RGBA to Gray,Undefined,Undefined,Alpha doesn't # produce PAM file ds = gdaltest.tiff_drv.Create( - "/vsimem/tiff_write_123_guua.tif", 1, 1, 4, gdal.GDT_Byte + "/vsimem/tiff_write_123_guua.tif", 1, 1, 4, gdal.GDT_UInt8 ) ds.GetRasterBand(1).SetColorInterpretation(gdal.GCI_GrayIndex) ds.GetRasterBand(2).SetColorInterpretation(gdal.GCI_Undefined) @@ -5411,7 +5417,7 @@ def handler(lvl, no, msg): def test_tiff_write_124(): - ds = gdaltest.tiff_drv.Create("/vsimem/tiff_write_124.tif", 1, 1, 3, gdal.GDT_Byte) + ds = gdaltest.tiff_drv.Create("/vsimem/tiff_write_124.tif", 1, 1, 3, gdal.GDT_UInt8) with gdal.quiet_errors(): # Test "SetColorTable() can only be called on band 1" @@ -6328,7 +6334,7 @@ def test_tiff_write_134(): 1, 1, 2, - gdal.GDT_Byte, + gdal.GDT_UInt8, options=["DISCARD_LSB=3", "INTERLEAVE=" + interleave], ) ds.GetRasterBand(1).Fill(inval) @@ -6398,7 +6404,7 @@ def test_tiff_write_134(): for interleave in ["BAND", "PIXEL"]: for dt in [ - gdal.GDT_Byte, + gdal.GDT_UInt8, gdal.GDT_Int16, gdal.GDT_UInt16, gdal.GDT_Int32, @@ -6455,7 +6461,7 @@ def test_tiff_write_134(): # Test with nodata for interleave in ["BAND", "PIXEL"]: for dt in [ - gdal.GDT_Byte, + gdal.GDT_UInt8, gdal.GDT_Int16, gdal.GDT_UInt16, gdal.GDT_Int32, @@ -6476,7 +6482,7 @@ def test_tiff_write_134(): ds = None ds = gdal.Open("/vsimem/tiff_write_134.tif") val1 = struct.unpack( - "B", ds.GetRasterBand(1).ReadRaster(0, 0, 1, 1, 1, 1, gdal.GDT_Byte) + "B", ds.GetRasterBand(1).ReadRaster(0, 0, 1, 1, 1, 1, gdal.GDT_UInt8) )[0] assert val1 == 127, (interleave, dt, val1) ds = None @@ -6485,7 +6491,7 @@ def test_tiff_write_134(): # Test with nodata and discarding non-nodata value would result to nodata without correction for interleave in ["BAND", "PIXEL"]: for dt in [ - gdal.GDT_Byte, + gdal.GDT_UInt8, gdal.GDT_Int16, gdal.GDT_UInt16, gdal.GDT_Int32, @@ -6506,7 +6512,7 @@ def test_tiff_write_134(): ds = None ds = gdal.Open("/vsimem/tiff_write_134.tif") val1 = struct.unpack( - "B", ds.GetRasterBand(1).ReadRaster(0, 0, 1, 1, 1, 1, gdal.GDT_Byte) + "B", ds.GetRasterBand(1).ReadRaster(0, 0, 1, 1, 1, 1, gdal.GDT_UInt8) )[0] if dt in (gdal.GDT_Float32, gdal.GDT_Float64): assert val1 == 1, (interleave, dt, val1) @@ -6518,7 +6524,7 @@ def test_tiff_write_134(): # Test with nodata out of range for integer values for interleave in ["BAND", "PIXEL"]: for dt in [ - gdal.GDT_Byte, + gdal.GDT_UInt8, gdal.GDT_Int16, gdal.GDT_UInt16, gdal.GDT_Int32, @@ -6540,7 +6546,7 @@ def test_tiff_write_134(): ds = gdal.Open("/vsimem/tiff_write_134.tif") assert ds.GetRasterBand(1).GetNoDataValue() == 127.5 val1 = struct.unpack( - "B", ds.GetRasterBand(1).ReadRaster(0, 0, 1, 1, 1, 1, gdal.GDT_Byte) + "B", ds.GetRasterBand(1).ReadRaster(0, 0, 1, 1, 1, 1, gdal.GDT_UInt8) )[0] if dt in (gdal.GDT_Float32, gdal.GDT_Float64): assert val1 == 127, (interleave, dt, val1) @@ -7224,7 +7230,7 @@ def test_tiff_write_145(): xsize = options.get("xsize", 1) ysize = options.get("ysize", 1) bands = options.get("bands", 1) - datatype = options.get("datatype", gdal.GDT_Byte) + datatype = options.get("datatype", gdal.GDT_UInt8) use_tmp = options.get("use_tmp", False) if use_tmp: filename = "tmp/tiff_write_145.tif" @@ -7603,7 +7609,7 @@ def test_tiff_write_154(): ]: # SPARSE_OK in CreateCopy(): blocks are not written if dt == "signedbyte": - src_ds = gdal.GetDriverByName("MEM").Create("", 500, 500, 1, gdal.GDT_Byte) + src_ds = gdal.GetDriverByName("MEM").Create("", 500, 500, 1, gdal.GDT_UInt8) options = ["SPARSE_OK=YES", "BLOCKYSIZE=256", "PIXELTYPE=SIGNEDBYTE"] else: src_ds = gdal.GetDriverByName("MEM").Create("", 500, 500, 1, dt) @@ -7625,7 +7631,7 @@ def test_tiff_write_154(): ]: # SPARSE_OK in CreateCopy(): blocks are not written if dt == "signedbyte": - src_ds = gdal.GetDriverByName("MEM").Create("", 500, 500, 1, gdal.GDT_Byte) + src_ds = gdal.GetDriverByName("MEM").Create("", 500, 500, 1, gdal.GDT_UInt8) options = ["SPARSE_OK=YES", "BLOCKYSIZE=256", "PIXELTYPE=SIGNEDBYTE"] else: src_ds = gdal.GetDriverByName("MEM").Create("", 500, 500, 1, dt) @@ -9282,7 +9288,7 @@ def test_tiff_write_no_gdal_metadata_tag_for_ycbcr_jpeg(): 16, 16, 3, - gdal.GDT_Byte, + gdal.GDT_UInt8, options=["PHOTOMETRIC=YCBCR", "COMPRESS=JPEG"], ) statBuf = gdal.VSIStatL( @@ -9939,7 +9945,7 @@ def test_tiff_write_jpegxl_float16(tmp_vsimem): @pytest.mark.require_creation_option("GTiff", "JXL") -@pytest.mark.parametrize("dt,nbits", [(gdal.GDT_Float64, None), (gdal.GDT_Byte, 1)]) +@pytest.mark.parametrize("dt,nbits", [(gdal.GDT_Float64, None), (gdal.GDT_UInt8, 1)]) @gdaltest.enable_exceptions() def test_tiff_write_jpegxl_errors(tmp_vsimem, dt, nbits): @@ -10776,7 +10782,7 @@ def test_tiff_write_createcopy_alpha_not_in_last_band(options): ], ], ) -@pytest.mark.parametrize("dtype", [gdal.GDT_Byte, gdal.GDT_UInt16, gdal.GDT_Float32]) +@pytest.mark.parametrize("dtype", [gdal.GDT_UInt8, gdal.GDT_UInt16, gdal.GDT_Float32]) @pytest.mark.parametrize( "copts", [ @@ -10964,17 +10970,17 @@ def test_tiff_write_lossless_extraction_of_JPEGXL_tile(): "xsize,ysize,nbands,dt,interleave,tiled,blockxsize,blockysize,write_dt", [ # Raster size multiple of block size - (128, 64, 1, gdal.GDT_Byte, "BAND", True, 32, 16, gdal.GDT_Byte), + (128, 64, 1, gdal.GDT_UInt8, "BAND", True, 32, 16, gdal.GDT_UInt8), # Write with a different data type - (128, 64, 1, gdal.GDT_Byte, "BAND", True, 32, 16, gdal.GDT_UInt16), + (128, 64, 1, gdal.GDT_UInt8, "BAND", True, 32, 16, gdal.GDT_UInt16), # Non-byte data type (128, 64, 1, gdal.GDT_UInt16, "BAND", True, 32, 16, gdal.GDT_UInt16), # Raster size is NOT a multiple of block size - (130, 65, 1, gdal.GDT_Byte, "BAND", True, 32, 16, gdal.GDT_Byte), + (130, 65, 1, gdal.GDT_UInt8, "BAND", True, 32, 16, gdal.GDT_UInt8), # Multiple bands - (128, 64, 2, gdal.GDT_Byte, "BAND", True, 32, 16, gdal.GDT_Byte), + (128, 64, 2, gdal.GDT_UInt8, "BAND", True, 32, 16, gdal.GDT_UInt8), # Non tiled - (128, 64, 1, gdal.GDT_Byte, "BAND", False, 128, 16, gdal.GDT_Byte), + (128, 64, 1, gdal.GDT_UInt8, "BAND", False, 128, 16, gdal.GDT_UInt8), ], ) def test_tiff_write_band_block_cache_bypass_optim( @@ -10982,7 +10988,7 @@ def test_tiff_write_band_block_cache_bypass_optim( ): mem_ds = gdal.GetDriverByName("MEM").Create("", xsize, ysize, nbands, dt) - if dt == gdal.GDT_Byte: + if dt == gdal.GDT_UInt8: dtype = "B" maxval = 255 elif dt == gdal.GDT_UInt16: @@ -11190,7 +11196,7 @@ def test_tiff_write_band_block_cache_bypass_optim_non_triggered(): 128, 64, 1, - gdal.GDT_Byte, + gdal.GDT_UInt8, "BAND", True, 32, @@ -11336,17 +11342,17 @@ def test_tiff_write_band_block_cache_bypass_optim_non_triggered(): "xsize,ysize,nbands,dt,interleave,tiled,blockxsize,blockysize,write_dt", [ # Raster size multiple of block size - (128, 64, 3, gdal.GDT_Byte, "PIXEL", True, 32, 16, gdal.GDT_Byte), + (128, 64, 3, gdal.GDT_UInt8, "PIXEL", True, 32, 16, gdal.GDT_UInt8), # Write with a different data type - (128, 64, 3, gdal.GDT_Byte, "PIXEL", True, 32, 16, gdal.GDT_UInt16), + (128, 64, 3, gdal.GDT_UInt8, "PIXEL", True, 32, 16, gdal.GDT_UInt16), # Non-byte data type (128, 64, 3, gdal.GDT_UInt16, "PIXEL", True, 32, 16, gdal.GDT_UInt16), # Raster size is NOT a multiple of block size - (130, 65, 3, gdal.GDT_Byte, "PIXEL", True, 32, 16, gdal.GDT_Byte), + (130, 65, 3, gdal.GDT_UInt8, "PIXEL", True, 32, 16, gdal.GDT_UInt8), # Multiple bands - (128, 64, 3, gdal.GDT_Byte, "PIXEL", True, 32, 16, gdal.GDT_Byte), + (128, 64, 3, gdal.GDT_UInt8, "PIXEL", True, 32, 16, gdal.GDT_UInt8), # Non tiled - (128, 64, 3, gdal.GDT_Byte, "PIXEL", False, 128, 16, gdal.GDT_Byte), + (128, 64, 3, gdal.GDT_UInt8, "PIXEL", False, 128, 16, gdal.GDT_UInt8), ], ) def test_tiff_write_dataset_block_cache_bypass_optim( @@ -11354,7 +11360,7 @@ def test_tiff_write_dataset_block_cache_bypass_optim( ): mem_ds = gdal.GetDriverByName("MEM").Create("", xsize, ysize, nbands, dt) - if dt == gdal.GDT_Byte: + if dt == gdal.GDT_UInt8: dtype = "B" maxval = 255 elif dt == gdal.GDT_UInt16: @@ -11522,7 +11528,7 @@ def test_tiff_write_dataset_block_cache_bypass_optim_non_triggered(): 128, 64, 3, - gdal.GDT_Byte, + gdal.GDT_UInt8, "PIXEL", True, 32, @@ -11849,7 +11855,7 @@ def test_tiff_write_colormap_256_mult_factor(tmp_vsimem): filename = str(tmp_vsimem / "test.tif") ds = gdal.GetDriverByName("GTiff").Create( - filename, 1, 1, 1, gdal.GDT_Byte, ["COLOR_TABLE_MULTIPLIER=256"] + filename, 1, 1, 1, gdal.GDT_UInt8, ["COLOR_TABLE_MULTIPLIER=256"] ) ds.GetRasterBand(1).SetRasterColorInterpretation(gdal.GCI_PaletteIndex) ct = gdal.ColorTable() @@ -12181,7 +12187,7 @@ def test_tiff_write_5_bands_interleaved_predictor_2(tmp_vsimem): 2, 1, 5, - gdal.GDT_Byte, + gdal.GDT_UInt8, options=["INTERLEAVE=PIXEL", "PREDICTOR=2", "COMPRESS=LZW"], ) as ds: ds.WriteRaster(0, 0, 2, 1, ref_content) diff --git a/autotest/gcore/transformer.py b/autotest/gcore/transformer.py index b05ecb450b62..62224e75de36 100644 --- a/autotest/gcore/transformer.py +++ b/autotest/gcore/transformer.py @@ -510,7 +510,7 @@ def test_transformer_9(): # (long,lat)=(125.64828521533849 39.869345204440144) -> (Easting,Northing)=(213324.662167036 4418634.47813677) in EPSG:32652 ds_dem = gdal.GetDriverByName("GTiff").Create( - "/vsimem/dem.tif", 100, 100, 1, gdal.GDT_Byte + "/vsimem/dem.tif", 100, 100, 1, gdal.GDT_UInt8 ) sr = osr.SpatialReference() sr.ImportFromEPSG(4326) @@ -580,7 +580,7 @@ def test_transformer_10(): # Create a fake DEM ds_dem = gdal.GetDriverByName("GTiff").Create( - "/vsimem/dem.tif", 100, 100, 1, gdal.GDT_Byte + "/vsimem/dem.tif", 100, 100, 1, gdal.GDT_UInt8 ) ds_dem.SetGeoTransform( [ diff --git a/autotest/gcore/vrt_read.py b/autotest/gcore/vrt_read.py index e76efbdba183..c04123068f66 100755 --- a/autotest/gcore/vrt_read.py +++ b/autotest/gcore/vrt_read.py @@ -106,13 +106,13 @@ def test_vrt_read_3(tmp_vsimem, tmp_path): gdal.CopyFile("data/test_mosaic2.vrt", tmp_vsimem / "test_mosaic2.vrt") output_dst = driver_tif.Create( - tmp_vsimem / "test_mosaic1.tif", 100, 100, 3, gdal.GDT_Byte + tmp_vsimem / "test_mosaic1.tif", 100, 100, 3, gdal.GDT_UInt8 ) output_dst.GetRasterBand(1).Fill(255) output_dst = None output_dst = driver_tif.Create( - tmp_vsimem / "test_mosaic2.tif", 100, 100, 3, gdal.GDT_Byte + tmp_vsimem / "test_mosaic2.tif", 100, 100, 3, gdal.GDT_UInt8 ) output_dst.GetRasterBand(1).Fill(127) output_dst = None @@ -1274,7 +1274,7 @@ def test_vrt_read_31(tmp_vsimem): ) ds = gdal.Translate( - "", tmp_vsimem / "in.asc", outputType=gdal.GDT_Byte, format="VRT" + "", tmp_vsimem / "in.asc", outputType=gdal.GDT_UInt8, format="VRT" ) data = ds.GetRasterBand(1).ReadRaster(0, 0, 2, 2, buf_type=gdal.GDT_Float32) @@ -2446,7 +2446,7 @@ def test_vrt_read_compute_statistics_mosaic_optimization_single_source(tmp_vsime @pytest.mark.parametrize("obj_type", ["ds", "band"]) @pytest.mark.parametrize( - "struct_type,gdal_type ", [("B", gdal.GDT_Byte), ("i", gdal.GDT_Int32)] + "struct_type,gdal_type ", [("B", gdal.GDT_UInt8), ("i", gdal.GDT_Int32)] ) def test_vrt_read_complex_source_use_band_data_type_constraint( obj_type, struct_type, gdal_type @@ -2495,12 +2495,12 @@ def test_vrt_read_top_and_bottom_strips_average(): @pytest.mark.parametrize( "input_datatype,vrt_type,nodata,vrt_nodata,request_type", [ - (gdal.GDT_Byte, "Byte", 0, 255, gdal.GDT_Byte), - (gdal.GDT_Byte, "Byte", 254, 255, gdal.GDT_Byte), - (gdal.GDT_Byte, "Int8", 254, 255, gdal.GDT_Byte), - (gdal.GDT_Byte, "Byte", 254, 127, gdal.GDT_Int8), - (gdal.GDT_Byte, "UInt16", 254, 255, gdal.GDT_Byte), - (gdal.GDT_Byte, "Byte", 254, 255, gdal.GDT_UInt16), + (gdal.GDT_UInt8, "Byte", 0, 255, gdal.GDT_UInt8), + (gdal.GDT_UInt8, "Byte", 254, 255, gdal.GDT_UInt8), + (gdal.GDT_UInt8, "Int8", 254, 255, gdal.GDT_UInt8), + (gdal.GDT_UInt8, "Byte", 254, 127, gdal.GDT_Int8), + (gdal.GDT_UInt8, "UInt16", 254, 255, gdal.GDT_UInt8), + (gdal.GDT_UInt8, "Byte", 254, 255, gdal.GDT_UInt16), (gdal.GDT_Int8, "Int8", 0, 127, gdal.GDT_Int8), (gdal.GDT_Int8, "Int16", 0, 127, gdal.GDT_Int8), (gdal.GDT_UInt16, "UInt16", 0, 65535, gdal.GDT_UInt16), @@ -2524,7 +2524,7 @@ def test_vrt_read_complex_source_nodata( ): def get_array_type(dt): m = { - gdal.GDT_Byte: "B", + gdal.GDT_UInt8: "B", gdal.GDT_Int8: "b", gdal.GDT_UInt16: "H", gdal.GDT_Int16: "h", @@ -2640,10 +2640,10 @@ def get_array_type(dt): ############################################################################### -@pytest.mark.parametrize("data_type", [gdal.GDT_Byte, gdal.GDT_UInt16, gdal.GDT_Int16]) +@pytest.mark.parametrize("data_type", [gdal.GDT_UInt8, gdal.GDT_UInt16, gdal.GDT_Int16]) def test_vrt_read_complex_source_nodata_out_of_range(tmp_vsimem, data_type): - if data_type == gdal.GDT_Byte: + if data_type == gdal.GDT_UInt8: array_type = "B" elif data_type == gdal.GDT_UInt16: array_type = "H" diff --git a/autotest/gcore/vrtmisc.py b/autotest/gcore/vrtmisc.py index 14af917709ad..8f44e1b7e170 100755 --- a/autotest/gcore/vrtmisc.py +++ b/autotest/gcore/vrtmisc.py @@ -582,7 +582,7 @@ def test_vrtmisc_blocksize(tmp_vsimem): filename = tmp_vsimem / "test_vrtmisc_blocksize.vrt" vrt_ds = gdal.GetDriverByName("VRT").Create(filename, 50, 50, 0) options = ["subClass=VRTSourcedRasterBand", "blockXSize=32", "blockYSize=48"] - vrt_ds.AddBand(gdal.GDT_Byte, options) + vrt_ds.AddBand(gdal.GDT_UInt8, options) vrt_ds = None vrt_ds = gdal.Open(filename) diff --git a/autotest/gdrivers/aigrid.py b/autotest/gdrivers/aigrid.py index 227739f1a142..2baee956a3fc 100755 --- a/autotest/gdrivers/aigrid.py +++ b/autotest/gdrivers/aigrid.py @@ -62,7 +62,7 @@ def test_aigrid_2(): band1 = ds.GetRasterBand(1) assert band1.GetNoDataValue() == 255, "Grid NODATA value wrong or missing." - assert band1.DataType == gdal.GDT_Byte, "Data type is not Byte!" + assert band1.DataType == gdal.GDT_UInt8, "Data type is not Byte!" ############################################################################### diff --git a/autotest/gdrivers/bag.py b/autotest/gdrivers/bag.py index da4eda298b93..c618f27649ef 100755 --- a/autotest/gdrivers/bag.py +++ b/autotest/gdrivers/bag.py @@ -687,7 +687,7 @@ def test_bag_vr_resampled_mask(): ) assert ds is not None assert ds.RasterCount == 1 - assert ds.GetRasterBand(1).DataType == gdal.GDT_Byte + assert ds.GetRasterBand(1).DataType == gdal.GDT_UInt8 assert ds.GetRasterBand(1).GetNoDataValue() is None cs = ds.GetRasterBand(1).Checksum() assert cs == 4552 diff --git a/autotest/gdrivers/daas.py b/autotest/gdrivers/daas.py index a1f6e7ef91b1..768942a1a7cf 100755 --- a/autotest/gdrivers/daas.py +++ b/autotest/gdrivers/daas.py @@ -2098,7 +2098,7 @@ def test_daas_mask(): ) with webserver.install_http_handler(handler): - data = ds.GetRasterBand(1).GetMaskBand().ReadRaster(buf_type=gdal.GDT_Byte) + data = ds.GetRasterBand(1).GetMaskBand().ReadRaster(buf_type=gdal.GDT_UInt8) assert data == "GHIJKL".encode("ascii") ds.FlushCache() @@ -2123,9 +2123,9 @@ def test_daas_mask(): response2, ) with webserver.install_http_handler(handler): - data = ds.ReadRaster(buf_type=gdal.GDT_Byte) + data = ds.ReadRaster(buf_type=gdal.GDT_UInt8) assert data == "XXXXXX".encode("ascii") - data = ds.GetRasterBand(1).GetMaskBand().ReadRaster(buf_type=gdal.GDT_Byte) + data = ds.GetRasterBand(1).GetMaskBand().ReadRaster(buf_type=gdal.GDT_UInt8) assert data == "GHIJKL".encode("ascii") diff --git a/autotest/gdrivers/doq2.py b/autotest/gdrivers/doq2.py index 9976a49859f8..0dcbd3e38250 100755 --- a/autotest/gdrivers/doq2.py +++ b/autotest/gdrivers/doq2.py @@ -26,7 +26,7 @@ def test_doq2_1(): ds = gdal.Open("data/doq2/C3607614_truncated.NWS") - mem_ds = gdal.GetDriverByName("MEM").Create("mem_1.mem", 500, 1, gdal.GDT_Byte, 1) + mem_ds = gdal.GetDriverByName("MEM").Create("mem_1.mem", 500, 1, gdal.GDT_UInt8, 1) mem_ds.GetRasterBand(1).WriteRaster( 0, 0, 500, 1, ds.GetRasterBand(1).ReadRaster(0, 0, 500, 1) diff --git a/autotest/gdrivers/ecw.py b/autotest/gdrivers/ecw.py index 0eaac23100a0..9a0c2b0424b0 100755 --- a/autotest/gdrivers/ecw.py +++ b/autotest/gdrivers/ecw.py @@ -381,7 +381,7 @@ def test_ecw_11(tmp_path): pytest.skip("ECW write support not available") drv = gdal.GetDriverByName("NITF") - ds = drv.Create(tmp_path / "test_11.ntf", 200, 100, 3, gdal.GDT_Byte, ["ICORDS=G"]) + ds = drv.Create(tmp_path / "test_11.ntf", 200, 100, 3, gdal.GDT_UInt8, ["ICORDS=G"]) ds.SetGeoTransform((100, 0.1, 0.0, 30.0, 0.0, -0.1)) my_list = list(range(200)) + list(range(20, 220)) + list(range(30, 230)) diff --git a/autotest/gdrivers/ehdr.py b/autotest/gdrivers/ehdr.py index f9d5dfdfe075..41cb58556b37 100755 --- a/autotest/gdrivers/ehdr.py +++ b/autotest/gdrivers/ehdr.py @@ -63,7 +63,7 @@ def test_ehdr_3(): def test_ehdr_4(): drv = gdal.GetDriverByName("EHdr") - ds = drv.Create("tmp/test_4.bil", 200, 100, 1, gdal.GDT_Byte) + ds = drv.Create("tmp/test_4.bil", 200, 100, 1, gdal.GDT_UInt8) raw_data = b"".join(struct.pack("h", v) for v in range(200)) diff --git a/autotest/gdrivers/envi.py b/autotest/gdrivers/envi.py index fb43b798db81..9c669effb5fb 100755 --- a/autotest/gdrivers/envi.py +++ b/autotest/gdrivers/envi.py @@ -929,7 +929,7 @@ def test_envi_read_direct_access(byte_order): 2, 3, 4, - buf_type=gdal.GDT_Byte, + buf_type=gdal.GDT_UInt8, buf_pixel_space=ds.RasterCount, buf_band_space=1, ) == src_ds.ReadRaster( @@ -937,7 +937,7 @@ def test_envi_read_direct_access(byte_order): 2, 3, 4, - buf_type=gdal.GDT_Byte, + buf_type=gdal.GDT_UInt8, buf_pixel_space=ds.RasterCount, buf_band_space=1, ) @@ -970,7 +970,7 @@ def test_envi_read_direct_access_update_scenario(): 0, ds.RasterXSize, ds.RasterYSize, - buf_type=gdal.GDT_Byte, + buf_type=gdal.GDT_UInt8, buf_pixel_space=ds.RasterCount, buf_band_space=1, ) == src_ds.ReadRaster( @@ -978,7 +978,7 @@ def test_envi_read_direct_access_update_scenario(): 0, ds.RasterXSize, ds.RasterYSize, - buf_type=gdal.GDT_Byte, + buf_type=gdal.GDT_UInt8, buf_pixel_space=ds.RasterCount, buf_band_space=1, ) diff --git a/autotest/gdrivers/envisat.py b/autotest/gdrivers/envisat.py index ac4e8b369d52..8ad54805b3fd 100755 --- a/autotest/gdrivers/envisat.py +++ b/autotest/gdrivers/envisat.py @@ -270,7 +270,7 @@ def test_envisat_meris_3(self): assert flags_band, "No flag band in MERIS Level 1 product." band = ds.GetRasterBand(flags_band) - assert band.DataType == gdal.GDT_Byte, ( + assert band.DataType == gdal.GDT_UInt8, ( "Incorrect data type of the flag band in " "MERIS Level 1 product." ) diff --git a/autotest/gdrivers/esric.py b/autotest/gdrivers/esric.py index dfc0012668cc..bc31f9028161 100755 --- a/autotest/gdrivers/esric.py +++ b/autotest/gdrivers/esric.py @@ -227,7 +227,7 @@ def test_tpkx_default_full_extent(extent_source): ) assert ds.GetDriver().GetDescription() == "ESRIC" assert ds.GetFileList() == ["data/esric/Usa.tpkx"] - assert ds.GetRasterBand(1).DataType == gdal.GDT_Byte + assert ds.GetRasterBand(1).DataType == gdal.GDT_UInt8 assert ds.GetRasterBand(1).GetBlockSize() == [256, 256] assert ds.GetRasterBand(1).Checksum() == 59047 assert ds.GetRasterBand(1).GetOverviewCount() == 3 diff --git a/autotest/gdrivers/gpkg.py b/autotest/gdrivers/gpkg.py index dd7d75ad0178..99dbc1cc9902 100755 --- a/autotest/gdrivers/gpkg.py +++ b/autotest/gdrivers/gpkg.py @@ -4104,7 +4104,7 @@ def test_gpkg_byte_nodata_value(band_count): gdal.Unlink(filename) ds = gdaltest.gpkg_dr.Create( - filename, 1, 1, band_count, gdal.GDT_Byte, options=["TILE_FORMAT=PNG"] + filename, 1, 1, band_count, gdal.GDT_UInt8, options=["TILE_FORMAT=PNG"] ) ds.SetGeoTransform([0, 1, 0, 0, 0, -1]) with gdal.quiet_errors(): @@ -4311,7 +4311,7 @@ def test_gpkg_gti_gpkg_ext(tmp_vsimem): # Test rename a raster table with SQL -@pytest.mark.parametrize("data_type", [gdal.GDT_Byte, gdal.GDT_UInt16]) +@pytest.mark.parametrize("data_type", [gdal.GDT_UInt8, gdal.GDT_UInt16]) def test_gpkg_rename_raster_table(data_type, tmp_vsimem): test_layer_path = str(tmp_vsimem / "test_gpkg_rename_raster_table.gpkg") diff --git a/autotest/gdrivers/grib.py b/autotest/gdrivers/grib.py index f37bac93b90f..071be5acdcc7 100755 --- a/autotest/gdrivers/grib.py +++ b/autotest/gdrivers/grib.py @@ -1813,7 +1813,7 @@ def test_grib_grib2_write_temperatures(): @pytest.mark.parametrize( - "datatype", [gdal.GDT_Byte, gdal.GDT_Float32], ids=gdal.GetDataTypeName + "datatype", [gdal.GDT_UInt8, gdal.GDT_Float32], ids=gdal.GetDataTypeName ) def test_grib_grib2_write_nodata(datatype): @@ -1840,7 +1840,7 @@ def test_grib_grib2_write_nodata(datatype): @pytest.mark.parametrize( - "datatype", [gdal.GDT_Byte, gdal.GDT_Float32], ids=gdal.GetDataTypeName + "datatype", [gdal.GDT_UInt8, gdal.GDT_Float32], ids=gdal.GetDataTypeName ) def test_grib_grib2_write_nodata_only(datatype): @@ -1863,14 +1863,14 @@ def test_grib_grib2_write_nodata_only(datatype): gdaltest.grib_drv.CreateCopy(tmpfilename, src_ds, options=options) ds = gdal.Open(tmpfilename) - if datatype == gdal.GDT_Byte: + if datatype == gdal.GDT_UInt8: assert ds.GetRasterBand(1).GetNoDataValue() == 12 else: assert ds.GetRasterBand(1).GetNoDataValue() == pytest.approx(12.3, rel=1e-4) got_vals = struct.unpack(4 * "d", ds.ReadRaster()) ds = None gdal.Unlink(tmpfilename) - if datatype == gdal.GDT_Byte: + if datatype == gdal.GDT_UInt8: expected_vals = (12, 12, 12, 12) else: expected_vals = (12.3, 12.3, 12.3, 12.3) @@ -1881,7 +1881,7 @@ def test_grib_grib2_write_nodata_only(datatype): @pytest.mark.parametrize( - "datatype", [gdal.GDT_Byte, gdal.GDT_Float32], ids=gdal.GetDataTypeName + "datatype", [gdal.GDT_UInt8, gdal.GDT_Float32], ids=gdal.GetDataTypeName ) def test_grib_grib2_write_full_OneData(datatype): @@ -1908,7 +1908,7 @@ def test_grib_grib2_write_full_OneData(datatype): got_vals = struct.unpack(4 * "d", ds.ReadRaster()) ds = None gdal.Unlink(tmpfilename) - if datatype == gdal.GDT_Byte: + if datatype == gdal.GDT_UInt8: expected_vals = (25, 25, 25, 25) else: expected_vals = (25.4, 25.4, 25.4, 25.4) diff --git a/autotest/gdrivers/hdf5multidim.py b/autotest/gdrivers/hdf5multidim.py index 3b562fc029af..1bc0f6498eee 100755 --- a/autotest/gdrivers/hdf5multidim.py +++ b/autotest/gdrivers/hdf5multidim.py @@ -41,7 +41,7 @@ def test_hdf5_multidim_basic(): assert len(dims) == 2 assert dims[0].GetSize() == 6 assert dims[1].GetSize() == 5 - assert ar.GetDataType().GetNumericDataType() == gdal.GDT_Byte + assert ar.GetDataType().GetNumericDataType() == gdal.GDT_UInt8 got_data = ar.Read(buffer_datatype=gdal.ExtendedDataType.Create(gdal.GDT_UInt16)) assert len(got_data) == 30 * 2 @@ -113,11 +113,11 @@ def test_hdf5_multidim_var_alldatatypes(): rg = ds.GetRootGroup() assert rg - expected_vars = [ # ('char_var', gdal.GDT_Byte, (ord('x'),ord('y'))), - ("ubyte_var", gdal.GDT_Byte, (255, 254)), + expected_vars = [ # ('char_var', gdal.GDT_UInt8, (ord('x'),ord('y'))), + ("ubyte_var", gdal.GDT_UInt8, (255, 254)), # ("byte_var", gdal.GDT_Int16, (-128, -127)), # ("byte_unsigned_false_var", gdal.GDT_Int8, (-128, -127)), - # ('byte_unsigned_true_var', gdal.GDT_Byte, (128, 129)), + # ('byte_unsigned_true_var', gdal.GDT_UInt8, (128, 129)), ("ushort_var", gdal.GDT_UInt16, (65534, 65533)), ("short_var", gdal.GDT_Int16, (-32768, -32767)), ("uint_var", gdal.GDT_UInt32, (4294967294, 4294967293)), @@ -140,7 +140,7 @@ def test_hdf5_multidim_var_alldatatypes(): assert var assert var.GetDataType().GetClass() == gdal.GEDTC_NUMERIC, var_name assert var.GetDataType().GetNumericDataType() == dt, var_name - if dt == gdal.GDT_Byte: + if dt == gdal.GDT_UInt8: assert struct.unpack("B" * len(val), var.Read()) == val if dt == gdal.GDT_Int8: assert struct.unpack("b" * len(val), var.Read()) == val @@ -460,7 +460,8 @@ def test_hdf5_multidim_attr_alldatatypes(): assert map_attrs["attr_two_doubles"].ReadAsDouble() == 1.25125 assert ( - map_attrs["attr_enum_ubyte"].GetDataType().GetNumericDataType() == gdal.GDT_Byte + map_attrs["attr_enum_ubyte"].GetDataType().GetNumericDataType() + == gdal.GDT_UInt8 ) assert map_attrs["attr_enum_ubyte"].Read() == 1 @@ -546,7 +547,7 @@ def create(): gdal.ErrorReset() var = rg.OpenMDArray("test") assert gdal.GetLastErrorMsg() != "" - assert var.GetDataType().GetNumericDataType() == gdal.GDT_Byte + assert var.GetDataType().GetNumericDataType() == gdal.GDT_UInt8 assert ( var.GetAttribute("_FillValue").GetDataType().GetNumericDataType() == gdal.GDT_Float64 diff --git a/autotest/gdrivers/heif.py b/autotest/gdrivers/heif.py index 072ae282749d..2822fd716095 100644 --- a/autotest/gdrivers/heif.py +++ b/autotest/gdrivers/heif.py @@ -176,7 +176,7 @@ def test_heif_tiled(): assert ds.RasterXSize == 30 assert ds.RasterYSize == 20 assert ds.RasterCount == 3 - assert ds.GetRasterBand(1).DataType == gdal.GDT_Byte + assert ds.GetRasterBand(1).DataType == gdal.GDT_UInt8 assert ds.GetRasterBand(1).GetBlockSize() == [15, 5] assert ds.GetRasterBand(2).GetBlockSize() == [15, 5] assert ds.GetRasterBand(3).GetBlockSize() == [15, 5] @@ -595,7 +595,7 @@ def method(request): def make_data(): - ds = gdal.GetDriverByName("MEM").Create("", 300, 200, 3, gdal.GDT_Byte) + ds = gdal.GetDriverByName("MEM").Create("", 300, 200, 3, gdal.GDT_UInt8) ds.GetRasterBand(1).SetRasterColorInterpretation(gdal.GCI_RedBand) ds.GetRasterBand(2).SetRasterColorInterpretation(gdal.GCI_GreenBand) @@ -609,7 +609,7 @@ def make_data(): rgb_bytes = array.array("B", red_green_blue).tobytes() for line in range(100): ds.WriteRaster( - 0, line, 300, 1, rgb_bytes, buf_type=gdal.GDT_Byte, band_list=[1, 2, 3] + 0, line, 300, 1, rgb_bytes, buf_type=gdal.GDT_UInt8, band_list=[1, 2, 3] ) black_white = ([0xFF] * 150 + [0x00] * 150) * 3 black_white_bytes = array.array("B", black_white).tobytes() @@ -620,7 +620,7 @@ def make_data(): 300, 1, black_white_bytes, - buf_type=gdal.GDT_Byte, + buf_type=gdal.GDT_UInt8, band_list=[1, 2, 3], ) @@ -629,7 +629,7 @@ def make_data(): def make_data_with_alpha(): - ds = gdal.GetDriverByName("MEM").Create("", 300, 200, 4, gdal.GDT_Byte) + ds = gdal.GetDriverByName("MEM").Create("", 300, 200, 4, gdal.GDT_UInt8) ds.GetRasterBand(1).SetRasterColorInterpretation(gdal.GCI_RedBand) ds.GetRasterBand(2).SetRasterColorInterpretation(gdal.GCI_GreenBand) @@ -645,7 +645,7 @@ def make_data_with_alpha(): rgba_bytes = array.array("B", red_green_blue_alpha).tobytes() for line in range(100): ds.WriteRaster( - 0, line, 300, 1, rgba_bytes, buf_type=gdal.GDT_Byte, band_list=[1, 2, 3, 4] + 0, line, 300, 1, rgba_bytes, buf_type=gdal.GDT_UInt8, band_list=[1, 2, 3, 4] ) black_white = ([0xFF] * 150 + [0x00] * 150) * 4 black_white_bytes = array.array("B", black_white).tobytes() @@ -656,7 +656,7 @@ def make_data_with_alpha(): 300, 1, black_white_bytes, - buf_type=gdal.GDT_Byte, + buf_type=gdal.GDT_UInt8, band_list=[1, 2, 3, 4], ) diff --git a/autotest/gdrivers/hfa.py b/autotest/gdrivers/hfa.py index f060736480b1..26af09c1d640 100755 --- a/autotest/gdrivers/hfa.py +++ b/autotest/gdrivers/hfa.py @@ -338,7 +338,7 @@ def test_hfa_metadata_1(tmp_path): md1_img = str(tmp_path / "md_1.img") drv = gdal.GetDriverByName("HFA") - ds = drv.Create(md1_img, 100, 150, 1, gdal.GDT_Byte) + ds = drv.Create(md1_img, 100, 150, 1, gdal.GDT_UInt8) md_val = "0123456789" * 60 md = {"test": md_val} @@ -492,7 +492,7 @@ def test_hfa_nodata_write(tmp_path): nodata_img = str(tmp_path / "nodata.img") drv = gdal.GetDriverByName("HFA") - ds = drv.Create(nodata_img, 7, 7, 1, gdal.GDT_Byte) + ds = drv.Create(nodata_img, 7, 7, 1, gdal.GDT_UInt8) p = [1, 2, 1, 4, 1, 2, 1] raw_data = b"".join(struct.pack("h", x) for x in p) @@ -576,7 +576,7 @@ def test_hfa_rotated_write(): pass drv = gdal.GetDriverByName("HFA") - ds = drv.Create("tmp/rot.img", 100, 150, 1, gdal.GDT_Byte) + ds = drv.Create("tmp/rot.img", 100, 150, 1, gdal.GDT_UInt8) check_gt = ( 11856857.07898215, @@ -1198,7 +1198,7 @@ def test_hfa_write_rat(): rat = src_ds.GetRasterBand(1).GetDefaultRAT() - dst_ds = drv.Create("tmp/write_rat.img", 100, 100, 1, gdal.GDT_Byte) + dst_ds = drv.Create("tmp/write_rat.img", 100, 100, 1, gdal.GDT_UInt8) dst_ds.GetRasterBand(1).SetDefaultRAT(rat) @@ -1299,7 +1299,7 @@ def test_hfa_read_nan_nodata(tmp_vsimem): def test_hfa_rat_grow_string(tmp_vsimem): with gdal.GetDriverByName("HFA").Create( - tmp_vsimem / "test.img", 1, 1, 1, gdal.GDT_Byte + tmp_vsimem / "test.img", 1, 1, 1, gdal.GDT_UInt8 ) as ds: rat = gdal.RasterAttributeTable() rat.CreateColumn("str", gdal.GFT_String, gdal.GFU_Generic) @@ -1324,7 +1324,7 @@ def test_hfa_rat_grow_string(tmp_vsimem): def test_hfa_rat_new_types(tmp_vsimem): with gdal.GetDriverByName("HFA").Create( - tmp_vsimem / "test.img", 1, 1, 1, gdal.GDT_Byte + tmp_vsimem / "test.img", 1, 1, 1, gdal.GDT_UInt8 ) as ds: rat = gdal.RasterAttributeTable() rat.CreateColumn("bool", gdal.GFT_Boolean, gdal.GFU_Generic) diff --git a/autotest/gdrivers/isis.py b/autotest/gdrivers/isis.py index 5007c34003e6..aef0312f2c9d 100755 --- a/autotest/gdrivers/isis.py +++ b/autotest/gdrivers/isis.py @@ -459,10 +459,10 @@ def test_isis_16(): for read_before_write in [False, True]: for init_nd in [False, True]: for dt, cs, nd, options in [ - [gdal.GDT_Byte, 0, 0, []], - [gdal.GDT_Byte, 0, 0, ["TILED=YES"]], + [gdal.GDT_UInt8, 0, 0, []], + [gdal.GDT_UInt8, 0, 0, ["TILED=YES"]], [ - gdal.GDT_Byte, + gdal.GDT_UInt8, 0, 0, ["DATA_LOCATION=GEOTIFF", "GEOTIFF_OPTIONS=COMPRESS=LZW"], diff --git a/autotest/gdrivers/jpeg_profile.py b/autotest/gdrivers/jpeg_profile.py index 5e34d5700a7b..16e2a289841f 100755 --- a/autotest/gdrivers/jpeg_profile.py +++ b/autotest/gdrivers/jpeg_profile.py @@ -54,7 +54,7 @@ def test_jpeg_copy_icc(): driver = gdal.GetDriverByName("JPEG") driver_tiff = gdal.GetDriverByName("GTiff") - ds = driver_tiff.Create("tmp/icc_test.tiff", 64, 64, 3, gdal.GDT_Byte, options) + ds = driver_tiff.Create("tmp/icc_test.tiff", 64, 64, 3, gdal.GDT_UInt8, options) # Check with dataset from CreateCopy() ds2 = driver.CreateCopy("tmp/icc_test.jpg", ds) @@ -92,7 +92,7 @@ def test_jpeg_copy_options_icc(): driver = gdal.GetDriverByName("JPEG") driver_tiff = gdal.GetDriverByName("GTiff") - ds = driver_tiff.Create("tmp/icc_test.tiff", 64, 64, 3, gdal.GDT_Byte) + ds = driver_tiff.Create("tmp/icc_test.tiff", 64, 64, 3, gdal.GDT_UInt8) # Check with dataset from CreateCopy() ds2 = driver.CreateCopy("tmp/icc_test.jpg", ds, options=options) @@ -136,7 +136,7 @@ def test_jpeg_copy_icc_64K(): driver = gdal.GetDriverByName("JPEG") driver_tiff = gdal.GetDriverByName("GTiff") - ds = driver_tiff.Create("tmp/icc_test.tiff", 64, 64, 3, gdal.GDT_Byte, options) + ds = driver_tiff.Create("tmp/icc_test.tiff", 64, 64, 3, gdal.GDT_UInt8, options) # Check with dataset from CreateCopy() ds2 = driver.CreateCopy("tmp/icc_test.jpg", ds, options=["COMMENT=foo"]) diff --git a/autotest/gdrivers/jpegxl.py b/autotest/gdrivers/jpegxl.py index 0bcf523947bf..755ec8b09afe 100755 --- a/autotest/gdrivers/jpegxl.py +++ b/autotest/gdrivers/jpegxl.py @@ -491,7 +491,7 @@ def test_jpegxl_write_jxl_to_jxl_data_type_change(tmp_vsimem): out_filename = tmp_vsimem / "out.jxl" gdal.Translate(out_filename, "data/jpegxl/float16.jxl", options="-ot Byte") with gdal.Open(out_filename) as ds: - assert ds.GetRasterBand(1).DataType == gdal.GDT_Byte + assert ds.GetRasterBand(1).DataType == gdal.GDT_UInt8 def test_jpegxl_write_five_bands_lossy(tmp_vsimem): @@ -661,7 +661,7 @@ def test_jpegxl_band_combinations(tmp_vsimem): ] types = [ - gdal.GDT_Byte, + gdal.GDT_UInt8, gdal.GDT_UInt16, ] diff --git a/autotest/gdrivers/kea.py b/autotest/gdrivers/kea.py index 5dde8074a849..cecc6220b01a 100755 --- a/autotest/gdrivers/kea.py +++ b/autotest/gdrivers/kea.py @@ -155,7 +155,7 @@ def test_kea_4(tmp_path): assert ret != 0 with gdal.quiet_errors(): - ret = ds.AddBand(gdal.GDT_Byte) + ret = ds.AddBand(gdal.GDT_UInt8) assert ret != 0 with gdal.quiet_errors(): @@ -380,11 +380,11 @@ def test_kea_9(tmp_path): @pytest.mark.parametrize( "dt,nd,expected_nd", [ - (gdal.GDT_Byte, 0, 0), - (gdal.GDT_Byte, 1.1, 1.0), - (gdal.GDT_Byte, 255, 255), - (gdal.GDT_Byte, -1, None), - (gdal.GDT_Byte, 256, None), + (gdal.GDT_UInt8, 0, 0), + (gdal.GDT_UInt8, 1.1, 1.0), + (gdal.GDT_UInt8, 255, 255), + (gdal.GDT_UInt8, -1, None), + (gdal.GDT_UInt8, 256, None), (gdal.GDT_UInt16, 0, 0), (gdal.GDT_UInt16, 65535, 65535), (gdal.GDT_UInt16, -1, None), @@ -439,17 +439,17 @@ def test_kea_10(tmp_path, dt, nd, expected_nd): def test_kea_11(tmp_path): - ds = gdaltest.kea_driver.Create(tmp_path / "out.kea", 1, 1, 1, gdal.GDT_Byte) + ds = gdaltest.kea_driver.Create(tmp_path / "out.kea", 1, 1, 1, gdal.GDT_UInt8) ds = None ds = gdal.Open(tmp_path / "out.kea", gdal.GA_Update) - assert ds.AddBand(gdal.GDT_Byte) == 0 + assert ds.AddBand(gdal.GDT_UInt8) == 0 assert ds.AddBand(gdal.GDT_Int16, options=["DEFLATE=9"]) == 0 ds = None ds = gdal.Open(tmp_path / "out.kea") assert ds.RasterCount == 3 - assert ds.GetRasterBand(2).DataType == gdal.GDT_Byte + assert ds.GetRasterBand(2).DataType == gdal.GDT_UInt8 assert ds.GetRasterBand(3).DataType == gdal.GDT_Int16 ds = None @@ -460,7 +460,7 @@ def test_kea_11(tmp_path): def test_kea_rat(tmp_path): - ds = gdaltest.kea_driver.Create(tmp_path / "out.kea", 1, 1, 1, gdal.GDT_Byte) + ds = gdaltest.kea_driver.Create(tmp_path / "out.kea", 1, 1, 1, gdal.GDT_UInt8) assert ds.GetRasterBand(1).GetDefaultRAT().GetColumnCount() == 0 assert ds.GetRasterBand(1).SetDefaultRAT(None) != 0 rat = ds.GetRasterBand(1).GetDefaultRAT() @@ -663,7 +663,7 @@ def test_kea_13(tmp_path): def test_kea_14(tmp_path): - ds = gdaltest.kea_driver.Create(tmp_path / "out.kea", 1, 1, 1, gdal.GDT_Byte) + ds = gdaltest.kea_driver.Create(tmp_path / "out.kea", 1, 1, 1, gdal.GDT_UInt8) assert ds.GetRasterBand(1).GetMaskFlags() == gdal.GMF_ALL_VALID assert ds.GetRasterBand(1).GetMaskBand().Checksum() == 3 ds.GetRasterBand(1).CreateMaskBand(0) diff --git a/autotest/gdrivers/mem.py b/autotest/gdrivers/mem.py index bbdca95f55f1..7e964b01accc 100755 --- a/autotest/gdrivers/mem.py +++ b/autotest/gdrivers/mem.py @@ -350,7 +350,7 @@ def test_mem_7(): drv = gdal.GetDriverByName("MEM") ds = drv.Create("MEM:::", 1, 1, 1) - ds.AddBand(gdal.GDT_Byte, []) + ds.AddBand(gdal.GDT_UInt8, []) assert ds.RasterCount == 2 ds = None diff --git a/autotest/gdrivers/memmultidim.py b/autotest/gdrivers/memmultidim.py index f473ab0bafec..3b03d4aba08c 100755 --- a/autotest/gdrivers/memmultidim.py +++ b/autotest/gdrivers/memmultidim.py @@ -90,7 +90,7 @@ def test_mem_md_subgroup(): assert subsubg is not None assert subsubg.GetFullName() == "/subgroup/subsubgroup" - subg.CreateMDArray("myarray", [], gdal.ExtendedDataType.Create(gdal.GDT_Byte)) + subg.CreateMDArray("myarray", [], gdal.ExtendedDataType.Create(gdal.GDT_UInt8)) array = rg.OpenMDArrayFromFullname("/subgroup/myarray") assert array is not None assert array.GetFullName() == "/subgroup/myarray" @@ -109,7 +109,7 @@ def test_mem_md_array_unnamed_array(): drv = gdal.GetDriverByName("MEM") ds = drv.CreateMultiDimensional("myds") rg = ds.GetRootGroup() - edt = gdal.ExtendedDataType.Create(gdal.GDT_Byte) + edt = gdal.ExtendedDataType.Create(gdal.GDT_UInt8) with gdal.quiet_errors(): assert not rg.CreateMDArray("", [], edt) @@ -120,11 +120,11 @@ def test_mem_md_array_duplicated_array_name(): ds = drv.CreateMultiDimensional("myds") rg = ds.GetRootGroup() assert rg.CreateMDArray( - "same_name", [], gdal.ExtendedDataType.Create(gdal.GDT_Byte) + "same_name", [], gdal.ExtendedDataType.Create(gdal.GDT_UInt8) ) with gdal.quiet_errors(): assert not rg.CreateMDArray( - "same_name", [], gdal.ExtendedDataType.Create(gdal.GDT_Byte) + "same_name", [], gdal.ExtendedDataType.Create(gdal.GDT_UInt8) ) @@ -177,7 +177,7 @@ def test_mem_md_array_single_dim(): dims = rg.GetDimensions() assert len(dims) == 1 myarray = rg.CreateMDArray( - "myarray", [dim], gdal.ExtendedDataType.Create(gdal.GDT_Byte) + "myarray", [dim], gdal.ExtendedDataType.Create(gdal.GDT_UInt8) ) assert myarray assert myarray.GetName() == "myarray" @@ -233,7 +233,7 @@ def test_mem_md_array_single_dim(): assert myarray.AdviseRead() == gdal.CE_None attr = myarray.CreateAttribute( - "attr", [], gdal.ExtendedDataType.Create(gdal.GDT_Byte) + "attr", [], gdal.ExtendedDataType.Create(gdal.GDT_UInt8) ) assert attr assert attr.GetFullName() == "/myarray/attr" @@ -316,16 +316,16 @@ def test_mem_md_array_string(): def test_mem_md_datatypes(): - dt_byte = gdal.ExtendedDataType.Create(gdal.GDT_Byte) + dt_byte = gdal.ExtendedDataType.Create(gdal.GDT_UInt8) assert dt_byte.GetClass() == gdal.GEDTC_NUMERIC assert dt_byte.GetName() == "" - assert dt_byte.GetNumericDataType() == gdal.GDT_Byte + assert dt_byte.GetNumericDataType() == gdal.GDT_UInt8 assert dt_byte.GetSize() == 1 assert dt_byte.CanConvertTo(dt_byte) with pytest.raises(Exception): assert dt_byte.CanConvertTo(None) - assert dt_byte == gdal.ExtendedDataType.Create(gdal.GDT_Byte) - assert not dt_byte != gdal.ExtendedDataType.Create(gdal.GDT_Byte) + assert dt_byte == gdal.ExtendedDataType.Create(gdal.GDT_UInt8) + assert not dt_byte != gdal.ExtendedDataType.Create(gdal.GDT_UInt8) assert dt_byte.Equals(dt_byte) with pytest.raises(Exception): assert dt_byte.Equals(None) @@ -518,7 +518,7 @@ def test_mem_md_array_3_dim(): dim1 = rg.CreateDimension("dim1", None, None, 3) dim2 = rg.CreateDimension("dim2", None, None, 4) myarray = rg.CreateMDArray( - "myarray", [dim0, dim1, dim2], gdal.ExtendedDataType.Create(gdal.GDT_Byte) + "myarray", [dim0, dim1, dim2], gdal.ExtendedDataType.Create(gdal.GDT_UInt8) ) assert myarray assert myarray.GetName() == "myarray" @@ -546,7 +546,7 @@ def test_mem_md_array_3_dim(): [2, 3, 4], [1, 1, 1], [12, 4, 1], - gdal.ExtendedDataType.Create(gdal.GDT_Byte), + gdal.ExtendedDataType.Create(gdal.GDT_UInt8), ) assert got_data == data @@ -658,7 +658,7 @@ def test_mem_md_array_read_write_errors(): dim1 = rg.CreateDimension("dim1", None, None, 3) dim2 = rg.CreateDimension("dim2", None, None, 4) myarray = rg.CreateMDArray( - "myarray", [dim0, dim1, dim2], gdal.ExtendedDataType.Create(gdal.GDT_Byte) + "myarray", [dim0, dim1, dim2], gdal.ExtendedDataType.Create(gdal.GDT_UInt8) ) assert myarray @@ -737,7 +737,7 @@ def test_mem_md_array_invalid_args(): drv = gdal.GetDriverByName("MEM") ds = drv.CreateMultiDimensional("myds") rg = ds.GetRootGroup() - edt = gdal.ExtendedDataType.Create(gdal.GDT_Byte) + edt = gdal.ExtendedDataType.Create(gdal.GDT_UInt8) dim = rg.CreateDimension("dim0", None, None, 1) with pytest.raises(TypeError): rg.CreateMDArray("myarray", None, edt) @@ -759,7 +759,7 @@ def test_mem_md_array_too_large(): dim = rg.CreateDimension("dim0", None, None, (1 << 64) - 1) with gdal.quiet_errors(): assert not rg.CreateMDArray( - "myarray", [dim], gdal.ExtendedDataType.Create(gdal.GDT_Byte) + "myarray", [dim], gdal.ExtendedDataType.Create(gdal.GDT_UInt8) ) @@ -773,7 +773,7 @@ def test_mem_md_array_too_large_overflow_dim(): dim2 = rg.CreateDimension("dim2", None, None, 1 << 25) with gdal.quiet_errors(): assert not rg.CreateMDArray( - "myarray", [dim0, dim1, dim2], gdal.ExtendedDataType.Create(gdal.GDT_Byte) + "myarray", [dim0, dim1, dim2], gdal.ExtendedDataType.Create(gdal.GDT_UInt8) ) @@ -787,7 +787,7 @@ def test_mem_md_array_30dim(): dim = rg.CreateDimension("dim%d" % i, None, None, 1 + (i % 2)) dims.append(dim) myarray = rg.CreateMDArray( - "myarray", dims, gdal.ExtendedDataType.Create(gdal.GDT_Byte) + "myarray", dims, gdal.ExtendedDataType.Create(gdal.GDT_UInt8) ) assert myarray assert myarray.GetDimensionCount() == 30 @@ -806,7 +806,7 @@ def test_mem_md_array_32dim(): dim = rg.CreateDimension("dim%d" % i, None, None, 1 + (i % 2)) dims.append(dim) myarray = rg.CreateMDArray( - "myarray", dims, gdal.ExtendedDataType.Create(gdal.GDT_Byte) + "myarray", dims, gdal.ExtendedDataType.Create(gdal.GDT_UInt8) ) assert len(myarray.Read()) == 2**16 @@ -930,7 +930,7 @@ def test_mem_md_array_attribute(): ds = drv.CreateMultiDimensional("myds") rg = ds.GetRootGroup() myarray = rg.CreateMDArray( - "myarray", [], gdal.ExtendedDataType.Create(gdal.GDT_Byte) + "myarray", [], gdal.ExtendedDataType.Create(gdal.GDT_UInt8) ) float64dt = gdal.ExtendedDataType.Create(gdal.GDT_Float64) @@ -958,14 +958,14 @@ def test_mem_md_array_slice(): dim_3 = rg.CreateDimension("dim_3", None, None, 3) dim_4 = rg.CreateDimension("dim_4", None, None, 4) - ar = rg.CreateMDArray("nodim", [], gdal.ExtendedDataType.Create(gdal.GDT_Byte)) + ar = rg.CreateMDArray("nodim", [], gdal.ExtendedDataType.Create(gdal.GDT_UInt8)) assert ar.Write(struct.pack("B", 1)) == gdal.CE_None with gdal.quiet_errors(): assert not ar[:] dim_1 = rg.CreateDimension("dim_1", None, None, 1) ar = rg.CreateMDArray( - "array_1", [dim_1], gdal.ExtendedDataType.Create(gdal.GDT_Byte) + "array_1", [dim_1], gdal.ExtendedDataType.Create(gdal.GDT_UInt8) ) data = b"\xFE" assert ar.Write(data) == gdal.CE_None @@ -979,7 +979,7 @@ def test_mem_md_array_slice(): ar[0:0] ar = rg.CreateMDArray( - "array", [dim_2, dim_3, dim_4], gdal.ExtendedDataType.Create(gdal.GDT_Byte) + "array", [dim_2, dim_3, dim_4], gdal.ExtendedDataType.Create(gdal.GDT_UInt8) ) data = array.array("B", list(range(2 * 3 * 4))).tobytes() assert ar.Write(data) == gdal.CE_None @@ -1281,11 +1281,11 @@ def test_mem_md_array_as_classic_dataset(): dim_y_var.Write(struct.pack("d" * 2, 10, 8)) dim_y.SetIndexingVariable(dim_y_var) - ar = rg.CreateMDArray("nodim", [], gdal.ExtendedDataType.Create(gdal.GDT_Byte)) + ar = rg.CreateMDArray("nodim", [], gdal.ExtendedDataType.Create(gdal.GDT_UInt8)) with gdal.quiet_errors(): assert not ar.AsClassicDataset(0, 0) - ar = rg.CreateMDArray("1d", [dim_x], gdal.ExtendedDataType.Create(gdal.GDT_Byte)) + ar = rg.CreateMDArray("1d", [dim_x], gdal.ExtendedDataType.Create(gdal.GDT_UInt8)) with gdal.quiet_errors(): assert not ar.AsClassicDataset(1, 0) ds = ar.AsClassicDataset(0, 0) @@ -1578,7 +1578,7 @@ def test_mem_md_array_single_dim_non_contiguous_copy(): spacing = 63 data = array.array("B", list(range(nvalues))).tobytes() for t in ( - gdal.GDT_Byte, + gdal.GDT_UInt8, gdal.GDT_Int16, gdal.GDT_Int32, gdal.GDT_Float64, @@ -1590,12 +1590,12 @@ def test_mem_md_array_single_dim_non_contiguous_copy(): ar = rg.CreateMDArray("ar", [dim], gdal.ExtendedDataType.Create(t)) assert ar assert ( - ar.Write(data, buffer_datatype=gdal.ExtendedDataType.Create(gdal.GDT_Byte)) + ar.Write(data, buffer_datatype=gdal.ExtendedDataType.Create(gdal.GDT_UInt8)) == gdal.CE_None ) got_data = ar.Read( buffer_stride=[spacing], - buffer_datatype=gdal.ExtendedDataType.Create(gdal.GDT_Byte), + buffer_datatype=gdal.ExtendedDataType.Create(gdal.GDT_UInt8), ) assert len(got_data) == (nvalues - 1) * spacing + 1 got_data = struct.unpack("B" * len(got_data), got_data) @@ -1609,7 +1609,7 @@ def test_mem_md_array_get_unscaled_0dim(): ds = drv.CreateMultiDimensional("myds") rg = ds.GetRootGroup() myarray = rg.CreateMDArray( - "myarray", [], gdal.ExtendedDataType.Create(gdal.GDT_Byte) + "myarray", [], gdal.ExtendedDataType.Create(gdal.GDT_UInt8) ) assert myarray @@ -1693,7 +1693,7 @@ def test_mem_md_array_get_unscaled_0dim_non_matching_nodata(): ds = drv.CreateMultiDimensional("myds") rg = ds.GetRootGroup() myarray = rg.CreateMDArray( - "myarray", [], gdal.ExtendedDataType.Create(gdal.GDT_Byte) + "myarray", [], gdal.ExtendedDataType.Create(gdal.GDT_UInt8) ) assert myarray @@ -1729,7 +1729,7 @@ def test_mem_md_array_get_unscaled_0dim_matching_nodata(): ds = drv.CreateMultiDimensional("myds") rg = ds.GetRootGroup() myarray = rg.CreateMDArray( - "myarray", [], gdal.ExtendedDataType.Create(gdal.GDT_Byte) + "myarray", [], gdal.ExtendedDataType.Create(gdal.GDT_UInt8) ) assert myarray @@ -1790,7 +1790,7 @@ def test_mem_md_array_get_unscaled_3dim(): dim1 = rg.CreateDimension("dim1", None, None, 3) dim2 = rg.CreateDimension("dim2", None, None, 4) myarray = rg.CreateMDArray( - "myarray", [dim0, dim1, dim2], gdal.ExtendedDataType.Create(gdal.GDT_Byte) + "myarray", [dim0, dim1, dim2], gdal.ExtendedDataType.Create(gdal.GDT_UInt8) ) assert myarray @@ -1950,7 +1950,7 @@ def test_mem_md_array_get_mask(): assert [x.GetSize() for x in mask.GetDimensions()] == [ x.GetSize() for x in myarray.GetDimensions() ] - assert mask.GetDataType().GetNumericDataType() == gdal.GDT_Byte + assert mask.GetDataType().GetNumericDataType() == gdal.GDT_UInt8 # Case when we don't need to read the underlying array at all: the mask is always valid assert [x for x in struct.unpack("B" * 24, mask.Read())] == [1] * 24 assert [x for x in struct.unpack("B" * 24, mask.Read(buffer_stride=[1, 2, 6]))] == [ @@ -2015,7 +2015,7 @@ def test_mem_md_array_get_mask(): ] == expected_data # Test missing_value, _FillValue, valid_min, valid_max - bytedt = gdal.ExtendedDataType.Create(gdal.GDT_Byte) + bytedt = gdal.ExtendedDataType.Create(gdal.GDT_UInt8) attr = myarray.CreateAttribute("missing_value", [1], bytedt) assert attr.Write(8) == gdal.CE_None attr = myarray.CreateAttribute("_FillValue", [1], bytedt) @@ -2077,8 +2077,8 @@ def test_mem_md_array_get_mask(): # Test all data types for dt, v, nv, expected in [ - (gdal.GDT_Byte, 1, 1, [1, 0]), - (gdal.GDT_Byte, 1, 1.5, [1, 1]), + (gdal.GDT_UInt8, 1, 1, [1, 0]), + (gdal.GDT_UInt8, 1, 1.5, [1, 1]), (gdal.GDT_Int16, 1, 1, [1, 0]), (gdal.GDT_UInt16, 1, 1, [1, 0]), (gdal.GDT_Int32, 1, 1, [1, 0]), @@ -2726,25 +2726,25 @@ def test_mem_md_rename_group(): rg = ds.GetRootGroup() group = rg.CreateGroup("group") group_attr = group.CreateAttribute( - "group_attr", [], gdal.ExtendedDataType.Create(gdal.GDT_Byte) + "group_attr", [], gdal.ExtendedDataType.Create(gdal.GDT_UInt8) ) rg.CreateGroup("other_group") dim = group.CreateDimension("dim0", "unspecified type", "unspecified direction", 2) - ar = group.CreateMDArray("ar", [dim], gdal.ExtendedDataType.Create(gdal.GDT_Byte)) + ar = group.CreateMDArray("ar", [dim], gdal.ExtendedDataType.Create(gdal.GDT_UInt8)) ar_attr = ar.CreateAttribute( - "ar_attr", [], gdal.ExtendedDataType.Create(gdal.GDT_Byte) + "ar_attr", [], gdal.ExtendedDataType.Create(gdal.GDT_UInt8) ) subgroup = group.CreateGroup("subgroup") subgroup.CreateGroup("subsubgroup") subgroup_attr = subgroup.CreateAttribute( - "subgroup_attr", [], gdal.ExtendedDataType.Create(gdal.GDT_Byte) + "subgroup_attr", [], gdal.ExtendedDataType.Create(gdal.GDT_UInt8) ) subgroup_ar = subgroup.CreateMDArray( - "subgroup_ar", [dim], gdal.ExtendedDataType.Create(gdal.GDT_Byte) + "subgroup_ar", [dim], gdal.ExtendedDataType.Create(gdal.GDT_UInt8) ) subgroup_ar_attr = subgroup_ar.CreateAttribute( - "subgroup_ar_attr", [], gdal.ExtendedDataType.Create(gdal.GDT_Byte) + "subgroup_ar_attr", [], gdal.ExtendedDataType.Create(gdal.GDT_UInt8) ) # Cannot rename root group @@ -2802,7 +2802,7 @@ def test_mem_md_rename_dimension(): rg = ds.GetRootGroup() dim = rg.CreateDimension("dim", "unspecified type", "unspecified direction", 2) rg.CreateDimension("other_dim", "unspecified type", "unspecified direction", 2) - ar = rg.CreateMDArray("ar", [dim], gdal.ExtendedDataType.Create(gdal.GDT_Byte)) + ar = rg.CreateMDArray("ar", [dim], gdal.ExtendedDataType.Create(gdal.GDT_UInt8)) # Empty name with pytest.raises(Exception): @@ -2833,14 +2833,14 @@ def test_mem_md_rename_attribute(): rg = ds.GetRootGroup() subg = rg.CreateGroup("group") subg_attr = subg.CreateAttribute( - "subg_attr", [], gdal.ExtendedDataType.Create(gdal.GDT_Byte) + "subg_attr", [], gdal.ExtendedDataType.Create(gdal.GDT_UInt8) ) subg.CreateAttribute( - "subg_other_attr", [], gdal.ExtendedDataType.Create(gdal.GDT_Byte) + "subg_other_attr", [], gdal.ExtendedDataType.Create(gdal.GDT_UInt8) ) - ar = subg.CreateMDArray("ar", [], gdal.ExtendedDataType.Create(gdal.GDT_Byte)) - attr = ar.CreateAttribute("attr", [], gdal.ExtendedDataType.Create(gdal.GDT_Byte)) - ar.CreateAttribute("other_attr", [], gdal.ExtendedDataType.Create(gdal.GDT_Byte)) + ar = subg.CreateMDArray("ar", [], gdal.ExtendedDataType.Create(gdal.GDT_UInt8)) + attr = ar.CreateAttribute("attr", [], gdal.ExtendedDataType.Create(gdal.GDT_UInt8)) + ar.CreateAttribute("other_attr", [], gdal.ExtendedDataType.Create(gdal.GDT_UInt8)) # Empty name with pytest.raises(Exception): @@ -2880,9 +2880,9 @@ def test_mem_md_rename_array(): ds = drv.CreateMultiDimensional("myds") rg = ds.GetRootGroup() subg = rg.CreateGroup("group") - ar = subg.CreateMDArray("ar", [], gdal.ExtendedDataType.Create(gdal.GDT_Byte)) - subg.CreateMDArray("other_array", [], gdal.ExtendedDataType.Create(gdal.GDT_Byte)) - attr = ar.CreateAttribute("attr", [], gdal.ExtendedDataType.Create(gdal.GDT_Byte)) + ar = subg.CreateMDArray("ar", [], gdal.ExtendedDataType.Create(gdal.GDT_UInt8)) + subg.CreateMDArray("other_array", [], gdal.ExtendedDataType.Create(gdal.GDT_UInt8)) + attr = ar.CreateAttribute("attr", [], gdal.ExtendedDataType.Create(gdal.GDT_UInt8)) # Empty name with pytest.raises(Exception): @@ -2912,11 +2912,11 @@ def test_mem_md_delete_group(): group = rg.CreateGroup("group") group_attr = group.CreateAttribute( - "ar_attr", [], gdal.ExtendedDataType.Create(gdal.GDT_Byte) + "ar_attr", [], gdal.ExtendedDataType.Create(gdal.GDT_UInt8) ) - ar = group.CreateMDArray("ar", [], gdal.ExtendedDataType.Create(gdal.GDT_Byte)) + ar = group.CreateMDArray("ar", [], gdal.ExtendedDataType.Create(gdal.GDT_UInt8)) ar_attr = ar.CreateAttribute( - "ar_attr", [], gdal.ExtendedDataType.Create(gdal.GDT_Byte) + "ar_attr", [], gdal.ExtendedDataType.Create(gdal.GDT_UInt8) ) subgroup = group.CreateGroup("subgroup") @@ -2952,9 +2952,9 @@ def test_mem_md_delete_array(): rg = ds.GetRootGroup() group = rg.CreateGroup("group") - ar = group.CreateMDArray("ar", [], gdal.ExtendedDataType.Create(gdal.GDT_Byte)) + ar = group.CreateMDArray("ar", [], gdal.ExtendedDataType.Create(gdal.GDT_UInt8)) ar_attr = ar.CreateAttribute( - "ar_attr", [], gdal.ExtendedDataType.Create(gdal.GDT_Byte) + "ar_attr", [], gdal.ExtendedDataType.Create(gdal.GDT_UInt8) ) with pytest.raises(Exception, match="is not an array"): @@ -2981,7 +2981,7 @@ def test_mem_md_delete_group_attribute(): group = rg.CreateGroup("group") group_attr = group.CreateAttribute( - "group_attr", [], gdal.ExtendedDataType.Create(gdal.GDT_Byte) + "group_attr", [], gdal.ExtendedDataType.Create(gdal.GDT_UInt8) ) with pytest.raises(Exception, match="is not an attribute"): @@ -3004,9 +3004,9 @@ def test_mem_md_delete_array_attribute(): rg = ds.GetRootGroup() group = rg.CreateGroup("group") - ar = group.CreateMDArray("ar", [], gdal.ExtendedDataType.Create(gdal.GDT_Byte)) + ar = group.CreateMDArray("ar", [], gdal.ExtendedDataType.Create(gdal.GDT_UInt8)) ar_attr = ar.CreateAttribute( - "ar_attr", [], gdal.ExtendedDataType.Create(gdal.GDT_Byte) + "ar_attr", [], gdal.ExtendedDataType.Create(gdal.GDT_UInt8) ) with pytest.raises(Exception, match="is not an attribute"): @@ -3028,16 +3028,16 @@ def test_mem_md_GetMDArrayFullNamesRecursive(): ds = drv.CreateMultiDimensional("myds") rg = ds.GetRootGroup() - rg.CreateMDArray("ar0", [], gdal.ExtendedDataType.Create(gdal.GDT_Byte)) + rg.CreateMDArray("ar0", [], gdal.ExtendedDataType.Create(gdal.GDT_UInt8)) group = rg.CreateGroup("group") - group.CreateMDArray("ar1", [], gdal.ExtendedDataType.Create(gdal.GDT_Byte)) + group.CreateMDArray("ar1", [], gdal.ExtendedDataType.Create(gdal.GDT_UInt8)) subgroup = group.CreateGroup("subgroup") - subgroup.CreateMDArray("ar2", [], gdal.ExtendedDataType.Create(gdal.GDT_Byte)) + subgroup.CreateMDArray("ar2", [], gdal.ExtendedDataType.Create(gdal.GDT_UInt8)) group2 = rg.CreateGroup("group2") - group2.CreateMDArray("ar3", [], gdal.ExtendedDataType.Create(gdal.GDT_Byte)) + group2.CreateMDArray("ar3", [], gdal.ExtendedDataType.Create(gdal.GDT_UInt8)) assert rg.GetMDArrayFullNamesRecursive() == [ "/ar0", diff --git a/autotest/gdrivers/miramon_read.py b/autotest/gdrivers/miramon_read.py index 9bdcd66ed1ab..e34d9019fda5 100644 --- a/autotest/gdrivers/miramon_read.py +++ b/autotest/gdrivers/miramon_read.py @@ -23,7 +23,7 @@ pytestmark = pytest.mark.require_driver("MiraMonRaster") gdal_to_struct = { - gdal.GDT_Byte: ("B", 1), + gdal.GDT_UInt8: ("B", 1), gdal.GDT_UInt16: ("H", 2), gdal.GDT_Int16: ("h", 2), gdal.GDT_UInt32: ("I", 4), diff --git a/autotest/gdrivers/mrf.py b/autotest/gdrivers/mrf.py index d6c6d695cd70..d44433e50e70 100755 --- a/autotest/gdrivers/mrf.py +++ b/autotest/gdrivers/mrf.py @@ -254,7 +254,7 @@ def test_mrf_overview_nnb_fact_2(): expected_cs = 1087 for dt in ( - gdal.GDT_Byte, + gdal.GDT_UInt8, gdal.GDT_Int16, gdal.GDT_UInt16, gdal.GDT_Int32, @@ -284,7 +284,7 @@ def test_mrf_overview_nnb_with_nodata_fact_2(): expected_cs = 1117 for dt in [ - gdal.GDT_Byte, + gdal.GDT_UInt8, gdal.GDT_Int16, gdal.GDT_UInt16, gdal.GDT_Int32, @@ -314,7 +314,7 @@ def test_mrf_overview_nnb_with_nodata_fact_2(): def test_mrf_overview_avg_fact_2(): for dt in [ - gdal.GDT_Byte, + gdal.GDT_UInt8, gdal.GDT_Int16, gdal.GDT_UInt16, gdal.GDT_Int32, @@ -354,7 +354,7 @@ def test_mrf_overview_avg_fact_2(): def test_mrf_overview_avg_with_nodata_fact_2(): for dt in ( - gdal.GDT_Byte, + gdal.GDT_UInt8, gdal.GDT_Int16, gdal.GDT_UInt16, gdal.GDT_Int32, diff --git a/autotest/gdrivers/netcdf.py b/autotest/gdrivers/netcdf.py index a41a9eeabaf5..b4b8040e2d65 100755 --- a/autotest/gdrivers/netcdf.py +++ b/autotest/gdrivers/netcdf.py @@ -1663,7 +1663,7 @@ def test_netcdf_geolocation_array_no_srs(tmp_path, write_bottomup, read_bottomup ): ds = gdal.Open(f'NETCDF:"{ofile}":Band1') got_data = struct.unpack( - "B" * 6, ds.GetRasterBand(1).ReadRaster(0, 0, 3, 2, buf_type=gdal.GDT_Byte) + "B" * 6, ds.GetRasterBand(1).ReadRaster(0, 0, 3, 2, buf_type=gdal.GDT_UInt8) ) if (write_bottomup and not read_bottomup) or ( not write_bottomup and read_bottomup @@ -1675,7 +1675,7 @@ def test_netcdf_geolocation_array_no_srs(tmp_path, write_bottomup, read_bottomup ds = gdal.Open(f'NETCDF:"{ofile}":lon') got_data = struct.unpack( - "B" * 6, ds.GetRasterBand(1).ReadRaster(0, 0, 3, 2, buf_type=gdal.GDT_Byte) + "B" * 6, ds.GetRasterBand(1).ReadRaster(0, 0, 3, 2, buf_type=gdal.GDT_UInt8) ) if (write_bottomup and not read_bottomup) or ( not write_bottomup and read_bottomup @@ -1687,7 +1687,7 @@ def test_netcdf_geolocation_array_no_srs(tmp_path, write_bottomup, read_bottomup ds = gdal.Open(f'NETCDF:"{ofile}":lat') got_data = struct.unpack( - "B" * 6, ds.GetRasterBand(1).ReadRaster(0, 0, 3, 2, buf_type=gdal.GDT_Byte) + "B" * 6, ds.GetRasterBand(1).ReadRaster(0, 0, 3, 2, buf_type=gdal.GDT_UInt8) ) if (write_bottomup and not read_bottomup) or ( not write_bottomup and read_bottomup diff --git a/autotest/gdrivers/netcdf_multidim.py b/autotest/gdrivers/netcdf_multidim.py index 77bff9046061..87e910880218 100755 --- a/autotest/gdrivers/netcdf_multidim.py +++ b/autotest/gdrivers/netcdf_multidim.py @@ -74,7 +74,7 @@ def test_netcdf_multidim_single_group(): assert dims[1].GetSize() == 20 assert not dims[1].GetIndexingVariable() assert var.GetDataType().GetClass() == gdal.GEDTC_NUMERIC - assert var.GetDataType().GetNumericDataType() == gdal.GDT_Byte + assert var.GetDataType().GetNumericDataType() == gdal.GDT_UInt8 assert var.GetAttribute("long_name") assert len(var.GetNoDataValueAsRaw()) == 1 assert var.GetNoDataValueAsDouble() == 0.0 @@ -180,11 +180,11 @@ def test_netcdf_multidim_var_alldatatypes(): assert rg expected_vars = [ - ("char_var", gdal.GDT_Byte, (ord("x"), ord("y"))), - ("ubyte_var", gdal.GDT_Byte, (255, 254)), + ("char_var", gdal.GDT_UInt8, (ord("x"), ord("y"))), + ("ubyte_var", gdal.GDT_UInt8, (255, 254)), ("byte_var", gdal.GDT_Int8, (-128, -127)), ("byte_unsigned_false_var", gdal.GDT_Int8, (-128, -127)), - ("byte_unsigned_true_var", gdal.GDT_Byte, (128, 129)), + ("byte_unsigned_true_var", gdal.GDT_UInt8, (128, 129)), ("ushort_var", gdal.GDT_UInt16, (65534, 65533)), ("short_var", gdal.GDT_Int16, (-32768, -32767)), ("uint_var", gdal.GDT_UInt32, (4294967294, 4294967293)), @@ -207,7 +207,7 @@ def test_netcdf_multidim_var_alldatatypes(): assert var assert var.GetDataType().GetClass() == gdal.GEDTC_NUMERIC assert var.GetDataType().GetNumericDataType() == dt, var_name - if dt == gdal.GDT_Byte: + if dt == gdal.GDT_UInt8: assert struct.unpack("B" * len(val), var.Read()) == val if dt == gdal.GDT_Int8: assert struct.unpack("b" * len(val), var.Read()) == val @@ -577,7 +577,8 @@ def test_netcdf_multidim_attr_alldatatypes(): assert map_attrs["attr_two_doubles"].ReadAsDouble() == 1.25125 assert ( - map_attrs["attr_enum_ubyte"].GetDataType().GetNumericDataType() == gdal.GDT_Byte + map_attrs["attr_enum_ubyte"].GetDataType().GetNumericDataType() + == gdal.GDT_UInt8 ) assert map_attrs["attr_enum_ubyte"].Read() == 1 @@ -946,7 +947,7 @@ def dims_from_non_netcdf(rg): dims_from_non_netcdf(rg) for dt in ( - gdal.GDT_Byte, + gdal.GDT_UInt8, gdal.GDT_Int8, gdal.GDT_Int16, gdal.GDT_UInt16, @@ -1974,7 +1975,7 @@ def create(): dim1 = rg.CreateDimension( "dim1", "unspecified type", "unspecified direction", 3 ) - bytedt = gdal.ExtendedDataType.Create(gdal.GDT_Byte) + bytedt = gdal.ExtendedDataType.Create(gdal.GDT_UInt8) ar = rg.CreateMDArray("myarray", [dim0, dim1], bytedt) ar.SetNoDataValueDouble(6) data = struct.pack("B" * 6, 1, 2, 3, 4, 5, 6) @@ -2324,8 +2325,8 @@ def test_netcdf_multidim_open_char_2d_zero_dim(): @pytest.mark.parametrize( "datatype,request_datatype", [ - (gdal.GDT_Byte, gdal.GDT_Byte), - (gdal.GDT_Byte, gdal.GDT_UInt16), # different data type + (gdal.GDT_UInt8, gdal.GDT_UInt8), + (gdal.GDT_UInt8, gdal.GDT_UInt16), # different data type (gdal.GDT_UInt16, gdal.GDT_UInt16), (gdal.GDT_UInt16, gdal.GDT_UInt32), # different data type (gdal.GDT_UInt32, gdal.GDT_UInt32), @@ -2342,7 +2343,7 @@ def test_netcdf_multidim_read_transposed_optimized_last_2dims( ): map_gdal_datatype_to_array_letter = { - gdal.GDT_Byte: "B", + gdal.GDT_UInt8: "B", gdal.GDT_UInt16: "H", gdal.GDT_UInt32: "I", gdal.GDT_Float64: "d", @@ -2416,7 +2417,7 @@ def f(): @pytest.mark.parametrize( "datatype,request_datatype", [ - (gdal.GDT_Byte, gdal.GDT_Byte), + (gdal.GDT_UInt8, gdal.GDT_UInt8), (gdal.GDT_UInt16, gdal.GDT_UInt16), (gdal.GDT_UInt32, gdal.GDT_UInt32), (gdal.GDT_Float64, gdal.GDT_Float64), @@ -2427,7 +2428,7 @@ def test_netcdf_multidim_read_transposed_4d_optimized_case_for_last_2dims( ): map_gdal_datatype_to_array_letter = { - gdal.GDT_Byte: "B", + gdal.GDT_UInt8: "B", gdal.GDT_UInt16: "H", gdal.GDT_UInt32: "I", gdal.GDT_Float64: "d", @@ -2495,7 +2496,7 @@ def f(): @pytest.mark.parametrize( "datatype,request_datatype", [ - (gdal.GDT_Byte, gdal.GDT_Byte), + (gdal.GDT_UInt8, gdal.GDT_UInt8), (gdal.GDT_UInt16, gdal.GDT_UInt16), (gdal.GDT_UInt32, gdal.GDT_UInt32), (gdal.GDT_Float64, gdal.GDT_Float64), @@ -2504,7 +2505,7 @@ def f(): def test_netcdf_multidim_read_transposed_3d_general_case(datatype, request_datatype): map_gdal_datatype_to_array_letter = { - gdal.GDT_Byte: "B", + gdal.GDT_UInt8: "B", gdal.GDT_UInt16: "H", gdal.GDT_UInt32: "I", gdal.GDT_Float64: "d", @@ -2583,7 +2584,7 @@ def create(): var = rg.CreateMDArray( "var", dims, - gdal.ExtendedDataType.Create(gdal.GDT_Byte), + gdal.ExtendedDataType.Create(gdal.GDT_UInt8), ["COMPRESS=DEFLATE", "BLOCKSIZE=1024,1024"], ) data = b"\0" * (y_size * x_size) @@ -2730,7 +2731,7 @@ def test_netcdf_read_missing_value_of_different_type_not_in_range(): def create(): ds = gdal.GetDriverByName("netCDF").CreateMultiDimensional(filename) rg = ds.GetRootGroup() - ar = rg.CreateMDArray("test", [], gdal.ExtendedDataType.Create(gdal.GDT_Byte)) + ar = rg.CreateMDArray("test", [], gdal.ExtendedDataType.Create(gdal.GDT_UInt8)) attr = ar.CreateAttribute( "missing_value", [], gdal.ExtendedDataType.Create(gdal.GDT_Float64) ) @@ -2743,7 +2744,7 @@ def check(): ) rg = ds.GetRootGroup() var = rg.OpenMDArray("test") - assert var.GetDataType().GetNumericDataType() == gdal.GDT_Byte + assert var.GetDataType().GetNumericDataType() == gdal.GDT_UInt8 assert ( var.GetAttribute("missing_value").GetDataType().GetNumericDataType() == gdal.GDT_Float64 @@ -2771,9 +2772,9 @@ def test_netcdf_multidim_update_missing_value(): def create(): ds = drv.CreateMultiDimensional(filename) rg = ds.GetRootGroup() - var = rg.CreateMDArray("var", [], gdal.ExtendedDataType.Create(gdal.GDT_Byte)) + var = rg.CreateMDArray("var", [], gdal.ExtendedDataType.Create(gdal.GDT_UInt8)) attr = var.CreateAttribute( - "missing_value", [], gdal.ExtendedDataType.Create(gdal.GDT_Byte) + "missing_value", [], gdal.ExtendedDataType.Create(gdal.GDT_UInt8) ) attr.Write(1) @@ -2812,13 +2813,13 @@ def test_netcdf_multidim_update_missing_value_and_FillValue(): def create(): ds = drv.CreateMultiDimensional(filename) rg = ds.GetRootGroup() - var = rg.CreateMDArray("var", [], gdal.ExtendedDataType.Create(gdal.GDT_Byte)) + var = rg.CreateMDArray("var", [], gdal.ExtendedDataType.Create(gdal.GDT_UInt8)) attr = var.CreateAttribute( - "missing_value", [], gdal.ExtendedDataType.Create(gdal.GDT_Byte) + "missing_value", [], gdal.ExtendedDataType.Create(gdal.GDT_UInt8) ) attr.Write(1) attr = var.CreateAttribute( - "_FillValue", [], gdal.ExtendedDataType.Create(gdal.GDT_Byte) + "_FillValue", [], gdal.ExtendedDataType.Create(gdal.GDT_UInt8) ) attr.Write(1) @@ -3153,28 +3154,28 @@ def test(): rg = ds.GetRootGroup() group = rg.CreateGroup("group") group_attr = group.CreateAttribute( - "group_attr", [], gdal.ExtendedDataType.Create(gdal.GDT_Byte) + "group_attr", [], gdal.ExtendedDataType.Create(gdal.GDT_UInt8) ) rg.CreateGroup("other_group") dim = group.CreateDimension( "dim0", "unspecified type", "unspecified direction", 2 ) ar = group.CreateMDArray( - "ar", [dim], gdal.ExtendedDataType.Create(gdal.GDT_Byte) + "ar", [dim], gdal.ExtendedDataType.Create(gdal.GDT_UInt8) ) attr = ar.CreateAttribute( - "attr", [], gdal.ExtendedDataType.Create(gdal.GDT_Byte) + "attr", [], gdal.ExtendedDataType.Create(gdal.GDT_UInt8) ) subgroup = group.CreateGroup("subgroup") subgroup_attr = subgroup.CreateAttribute( - "subgroup_attr", [], gdal.ExtendedDataType.Create(gdal.GDT_Byte) + "subgroup_attr", [], gdal.ExtendedDataType.Create(gdal.GDT_UInt8) ) subgroup_ar = subgroup.CreateMDArray( - "subgroup_ar", [dim], gdal.ExtendedDataType.Create(gdal.GDT_Byte) + "subgroup_ar", [dim], gdal.ExtendedDataType.Create(gdal.GDT_UInt8) ) subgroup_ar_attr = subgroup_ar.CreateAttribute( - "subgroup_ar_attr", [], gdal.ExtendedDataType.Create(gdal.GDT_Byte) + "subgroup_ar_attr", [], gdal.ExtendedDataType.Create(gdal.GDT_UInt8) ) # Cannot rename root group @@ -3259,13 +3260,13 @@ def test(): subg = rg.CreateGroup("group") dim = rg.CreateDimension("dim", None, None, 2) ar = subg.CreateMDArray( - "ar", [dim], gdal.ExtendedDataType.Create(gdal.GDT_Byte) + "ar", [dim], gdal.ExtendedDataType.Create(gdal.GDT_UInt8) ) subg.CreateMDArray( - "other_array", [dim], gdal.ExtendedDataType.Create(gdal.GDT_Byte) + "other_array", [dim], gdal.ExtendedDataType.Create(gdal.GDT_UInt8) ) attr = ar.CreateAttribute( - "attr", [], gdal.ExtendedDataType.Create(gdal.GDT_Byte) + "attr", [], gdal.ExtendedDataType.Create(gdal.GDT_UInt8) ) # Empty name @@ -3330,7 +3331,7 @@ def test(): "subg_other_attr", [], gdal.ExtendedDataType.CreateString() ) assert subg_other_attr.Write("foo") == gdal.CE_None - ar = subg.CreateMDArray("ar", [], gdal.ExtendedDataType.Create(gdal.GDT_Byte)) + ar = subg.CreateMDArray("ar", [], gdal.ExtendedDataType.Create(gdal.GDT_UInt8)) attr = ar.CreateAttribute("attr", [], gdal.ExtendedDataType.CreateString()) assert attr.Write("foo") == gdal.CE_None other_attr = ar.CreateAttribute( @@ -3484,7 +3485,7 @@ def test(): ) assert subg_other_attr.Write("foo") == gdal.CE_None - ar = subg.CreateMDArray("ar", [], gdal.ExtendedDataType.Create(gdal.GDT_Byte)) + ar = subg.CreateMDArray("ar", [], gdal.ExtendedDataType.Create(gdal.GDT_UInt8)) attr = ar.CreateAttribute("attr", [], gdal.ExtendedDataType.CreateString()) assert attr.Write("foo") == gdal.CE_None other_attr = ar.CreateAttribute( @@ -4210,7 +4211,7 @@ def test_netcdf_multidim_enumeration(): types = rg.GetDataTypes() assert (len(types)) == 1 assert types[0].GetName() == "my_enum" - assert types[0].GetNumericDataType() == gdal.GDT_Byte + assert types[0].GetNumericDataType() == gdal.GDT_UInt8 rat = types[0].GetRAT() assert rat assert rat.GetRowCount() == 3 diff --git a/autotest/gdrivers/ngw.py b/autotest/gdrivers/ngw.py index 587d2c0f90f8..e4c07499c70d 100755 --- a/autotest/gdrivers/ngw.py +++ b/autotest/gdrivers/ngw.py @@ -118,7 +118,7 @@ def check_tms(sub): ] assert gt == pytest.approx(expected_gt, abs=0.00001), f"Wrong geotransform. {gt}" assert ds.GetRasterBand(1).GetOverviewCount() > 0, "No overviews!" - assert ds.GetRasterBand(1).DataType == gdal.GDT_Byte, "Wrong band data type." + assert ds.GetRasterBand(1).DataType == gdal.GDT_UInt8, "Wrong band data type." ############################################################################### diff --git a/autotest/gdrivers/nitf.py b/autotest/gdrivers/nitf.py index ed0845ff1573..e696cf0ffd32 100755 --- a/autotest/gdrivers/nitf.py +++ b/autotest/gdrivers/nitf.py @@ -90,9 +90,9 @@ def nitf_create( drv = gdal.GetDriverByName("NITF") if createcopy: - ds = gdal.GetDriverByName("MEM").Create("", 200, 100, nbands, gdal.GDT_Byte) + ds = gdal.GetDriverByName("MEM").Create("", 200, 100, nbands, gdal.GDT_UInt8) else: - ds = drv.Create(filename, 200, 100, nbands, gdal.GDT_Byte, creation_options) + ds = drv.Create(filename, 200, 100, nbands, gdal.GDT_UInt8, creation_options) ds.SetGeoTransform((100, 0.1, 0.0, 30.0, 0.0, -0.1)) if set_inverted_color_interp: @@ -379,7 +379,7 @@ def test_nitf_12(): def test_nitf_13(tmp_path): drv = gdal.GetDriverByName("NITF") gdal.ErrorReset() - ds = drv.Create(tmp_path / "test_13.ntf", 200, 100, 1, gdal.GDT_Byte, ["ICORDS=S"]) + ds = drv.Create(tmp_path / "test_13.ntf", 200, 100, 1, gdal.GDT_UInt8, ["ICORDS=S"]) assert gdal.GetLastErrorMsg() == "" ds.SetGeoTransform((400000, 10, 0.0, 6000000, 0.0, -10)) ds.SetProjection( @@ -1126,7 +1126,7 @@ def test_nitf_29(tmp_path): 1, 1, 1, - gdal.GDT_Byte, + gdal.GDT_UInt8, ["IREP=RGB/LUT", "LUT_SIZE=128"], ) @@ -1965,7 +1965,7 @@ def test_nitf_50(tmp_path): ) ds.WriteRaster( - 0, 0, 100, 100, " ", 1, 1, buf_type=gdal.GDT_Byte, band_list=[1, 2, 3] + 0, 0, 100, 100, " ", 1, 1, buf_type=gdal.GDT_UInt8, band_list=[1, 2, 3] ) ds.GetRasterBand(1).SetRasterColorInterpretation(gdal.GCI_BlueBand) @@ -6036,13 +6036,13 @@ def test_nitf_readSAR_IQ(tmp_vsimem): src_ds = gdal.Open("data/byte.tif") ds = gdal.Open("DERIVED_SUBDATASET:REAL:" + out_filename) assert ( - ds.ReadRaster(0, 0, 40, 20, 20, 20, buf_type=gdal.GDT_Byte) + ds.ReadRaster(0, 0, 40, 20, 20, 20, buf_type=gdal.GDT_UInt8) == src_ds.ReadRaster() ) ds = gdal.Open("DERIVED_SUBDATASET:IMAG:" + out_filename) mod_src_ds = gdal.Translate("", src_ds, options="-f MEM -scale 0 255 255 0") assert ( - ds.ReadRaster(0, 0, 40, 20, 20, 20, buf_type=gdal.GDT_Byte) + ds.ReadRaster(0, 0, 40, 20, 20, 20, buf_type=gdal.GDT_UInt8) == mod_src_ds.ReadRaster() ) diff --git a/autotest/gdrivers/nsidcbin.py b/autotest/gdrivers/nsidcbin.py index 7d1fa8652981..9a369004ce11 100644 --- a/autotest/gdrivers/nsidcbin.py +++ b/autotest/gdrivers/nsidcbin.py @@ -30,5 +30,5 @@ def test_nsidcbin_1(filename="data/nsidcbin/nt_20220409_f18_nrt_s.bin"): ds = gdal.Open(filename) band = ds.GetRasterBand(1) assert band.XSize == 316 - assert band.DataType == gdal.GDT_Byte + assert band.DataType == gdal.GDT_UInt8 assert int.from_bytes(band.ReadRaster(60, 44, 1, 1), "little") == 27 diff --git a/autotest/gdrivers/openfilegdb.py b/autotest/gdrivers/openfilegdb.py index 3ebc614b98d5..fe8964f659ea 100755 --- a/autotest/gdrivers/openfilegdb.py +++ b/autotest/gdrivers/openfilegdb.py @@ -50,8 +50,8 @@ def test_openfilegb_raster_subdatasets(): @pytest.mark.parametrize( "name,datatype,checksum", [ - ("byte_lz77", gdal.GDT_Byte, 4672), - ("byte_lzw", gdal.GDT_Byte, 4672), # no compression actually + ("byte_lz77", gdal.GDT_UInt8, 4672), + ("byte_lzw", gdal.GDT_UInt8, 4672), # no compression actually ("uint16_lz77", gdal.GDT_UInt16, 4672), ("uint16_lzw", gdal.GDT_UInt16, 4672), # no compression actually ("int16_lz77", gdal.GDT_Int16, 4672), diff --git a/autotest/gdrivers/pcidsk.py b/autotest/gdrivers/pcidsk.py index 7cf3ddbcff4a..f4d40f8dd8b1 100755 --- a/autotest/gdrivers/pcidsk.py +++ b/autotest/gdrivers/pcidsk.py @@ -88,7 +88,7 @@ def test_pcidsk_5(tmp_path): # Create testing file. pcidsk_ds = gdal.GetDriverByName("PCIDSK").Create( - testfile, 400, 600, 1, gdal.GDT_Byte + testfile, 400, 600, 1, gdal.GDT_UInt8 ) # Write out some metadata to the default and non-default domain and diff --git a/autotest/gdrivers/pds4.py b/autotest/gdrivers/pds4.py index f7e366aef382..38064fde4ec3 100755 --- a/autotest/gdrivers/pds4.py +++ b/autotest/gdrivers/pds4.py @@ -742,7 +742,7 @@ def test_pds4_11(): filename = "/vsimem/out.xml" for (dt, data) in [ - (gdal.GDT_Byte, struct.pack("B", 255)), + (gdal.GDT_UInt8, struct.pack("B", 255)), (gdal.GDT_Int8, struct.pack("b", -128)), (gdal.GDT_UInt16, struct.pack("H", 65535)), (gdal.GDT_Int16, struct.pack("h", -32768)), @@ -1902,7 +1902,7 @@ def test_pds4_read_hexadecimal_missing_constant(filename, expected_val): @pytest.mark.parametrize( "dt,val,serialized_val", [ - (gdal.GDT_Byte, 255, "255"), + (gdal.GDT_UInt8, 255, "255"), (gdal.GDT_Int64, (1 << 63) - 1, str((1 << 63) - 1)), (gdal.GDT_UInt64, (1 << 64) - 1, str((1 << 64) - 1)), (gdal.GDT_Float32, -3.4028226550889045e38, "0xFF7FFFFB"), diff --git a/autotest/gdrivers/png_profile.py b/autotest/gdrivers/png_profile.py index ba13d9bf1528..1898f040ae8b 100755 --- a/autotest/gdrivers/png_profile.py +++ b/autotest/gdrivers/png_profile.py @@ -54,7 +54,7 @@ def test_png_copy_icc(): driver = gdal.GetDriverByName("PNG") driver_tiff = gdal.GetDriverByName("GTiff") - ds = driver_tiff.Create("tmp/icc_test.tiff", 64, 64, 3, gdal.GDT_Byte, options) + ds = driver_tiff.Create("tmp/icc_test.tiff", 64, 64, 3, gdal.GDT_UInt8, options) # Check with dataset from CreateCopy() ds2 = driver.CreateCopy("tmp/icc_test.png", ds) @@ -111,7 +111,7 @@ def test_png_copy_options_icc(): driver = gdal.GetDriverByName("PNG") driver_tiff = gdal.GetDriverByName("GTiff") - ds = driver_tiff.Create("tmp/icc_test.tiff", 64, 64, 3, gdal.GDT_Byte) + ds = driver_tiff.Create("tmp/icc_test.tiff", 64, 64, 3, gdal.GDT_UInt8) # Check with dataset from CreateCopy() ds2 = driver.CreateCopy("tmp/icc_test.png", ds, options=options) @@ -152,7 +152,7 @@ def test_png_copy_options_colorimetric_data(): driver = gdal.GetDriverByName("PNG") driver_tiff = gdal.GetDriverByName("GTiff") - ds = driver_tiff.Create("tmp/icc_test.tiff", 64, 64, 3, gdal.GDT_Byte) + ds = driver_tiff.Create("tmp/icc_test.tiff", 64, 64, 3, gdal.GDT_UInt8) # Check with dataset from CreateCopy() ds2 = driver.CreateCopy("tmp/icc_test.png", ds, options=options) @@ -228,7 +228,7 @@ def test_png_copy_colorimetric_data(): driver = gdal.GetDriverByName("PNG") driver_tiff = gdal.GetDriverByName("GTiff") - ds = driver_tiff.Create("tmp/icc_test.tiff", 64, 64, 3, gdal.GDT_Byte, options) + ds = driver_tiff.Create("tmp/icc_test.tiff", 64, 64, 3, gdal.GDT_UInt8, options) ds = None ds = gdal.Open("tmp/icc_test.tiff") @@ -296,7 +296,7 @@ def test_png_sRGB(): driver = gdal.GetDriverByName("PNG") driver_tiff = gdal.GetDriverByName("GTiff") - ds = driver_tiff.Create("tmp/icc_test.tiff", 64, 64, 3, gdal.GDT_Byte) + ds = driver_tiff.Create("tmp/icc_test.tiff", 64, 64, 3, gdal.GDT_UInt8) # Check with dataset from CreateCopy() ds2 = driver.CreateCopy("tmp/icc_test.png", ds, options=options) diff --git a/autotest/gdrivers/rl2.py b/autotest/gdrivers/rl2.py index 48f02e75eb0d..b6009fe3abc4 100755 --- a/autotest/gdrivers/rl2.py +++ b/autotest/gdrivers/rl2.py @@ -178,7 +178,7 @@ def test_rl2_5(): assert subds == expected_subds tests = [ - ("RASTERLITE2:data/rasterlite2/multi_type.rl2:uint8", gdal.GDT_Byte, 4672), + ("RASTERLITE2:data/rasterlite2/multi_type.rl2:uint8", gdal.GDT_UInt8, 4672), ("RASTERLITE2:data/rasterlite2/multi_type.rl2:int8", gdal.GDT_Int8, 4575), ("RASTERLITE2:data/rasterlite2/multi_type.rl2:uint16", gdal.GDT_UInt16, 4457), ("RASTERLITE2:data/rasterlite2/multi_type.rl2:int16", gdal.GDT_Int16, 4457), @@ -186,7 +186,7 @@ def test_rl2_5(): ("RASTERLITE2:data/rasterlite2/multi_type.rl2:int32", gdal.GDT_Int32, 4457), ("RASTERLITE2:data/rasterlite2/multi_type.rl2:float", gdal.GDT_Float32, 4457), ("RASTERLITE2:data/rasterlite2/multi_type.rl2:double", gdal.GDT_Float64, 4457), - ("RASTERLITE2:data/rasterlite2/multi_type.rl2:1bit", gdal.GDT_Byte, 4873), + ("RASTERLITE2:data/rasterlite2/multi_type.rl2:1bit", gdal.GDT_UInt8, 4873), ] for (subds_name, dt, expected_cs) in tests: ds = gdal.Open(subds_name) @@ -354,28 +354,28 @@ def test_rl2_19(): def test_rl2_20(): tests = [ - ("MONOCHROME", 2, gdal.GDT_Byte, "NONE", None, None), + ("MONOCHROME", 2, gdal.GDT_UInt8, "NONE", None, None), ("MONOCHROME", 1, gdal.GDT_UInt16, "NONE", None, None), - ("PALETTE", 1, gdal.GDT_Byte, "NONE", None, None), + ("PALETTE", 1, gdal.GDT_UInt8, "NONE", None, None), ("PALETTE", 1, gdal.GDT_UInt16, "NONE", None, gdal.ColorTable()), - ("GRAYSCALE", 2, gdal.GDT_Byte, "NONE", None, None), + ("GRAYSCALE", 2, gdal.GDT_UInt8, "NONE", None, None), ("GRAYSCALE", 1, gdal.GDT_UInt16, "NONE", None, None), - ("RGB", 1, gdal.GDT_Byte, "NONE", None, None), + ("RGB", 1, gdal.GDT_UInt8, "NONE", None, None), ("RGB", 3, gdal.GDT_Int16, "NONE", None, None), - ("MULTIBAND", 1, gdal.GDT_Byte, "NONE", None, None), - ("MULTIBAND", 256, gdal.GDT_Byte, "NONE", None, None), + ("MULTIBAND", 1, gdal.GDT_UInt8, "NONE", None, None), + ("MULTIBAND", 256, gdal.GDT_UInt8, "NONE", None, None), ("MULTIBAND", 2, gdal.GDT_Int16, "NONE", None, None), - ("DATAGRID", 2, gdal.GDT_Byte, "NONE", None, None), + ("DATAGRID", 2, gdal.GDT_UInt8, "NONE", None, None), ("DATAGRID", 1, gdal.GDT_CFloat32, "NONE", None, None), - ("MONOCHROME", 1, gdal.GDT_Byte, "JPEG", None, None), - ("PALETTE", 1, gdal.GDT_Byte, "JPEG", None, gdal.ColorTable()), - ("GRAYSCALE", 1, gdal.GDT_Byte, "CCITTFAX4", None, None), - ("RGB", 3, gdal.GDT_Byte, "CCITTFAX4", None, None), + ("MONOCHROME", 1, gdal.GDT_UInt8, "JPEG", None, None), + ("PALETTE", 1, gdal.GDT_UInt8, "JPEG", None, gdal.ColorTable()), + ("GRAYSCALE", 1, gdal.GDT_UInt8, "CCITTFAX4", None, None), + ("RGB", 3, gdal.GDT_UInt8, "CCITTFAX4", None, None), ("RGB", 3, gdal.GDT_UInt16, "JPEG", None, None), - ("MULTIBAND", 3, gdal.GDT_Byte, "CCITTFAX4", None, None), + ("MULTIBAND", 3, gdal.GDT_UInt8, "CCITTFAX4", None, None), ("MULTIBAND", 3, gdal.GDT_UInt16, "CCITTFAX4", None, None), - ("MULTIBAND", 2, gdal.GDT_Byte, "CCITTFAX4", None, None), - ("DATAGRID", 1, gdal.GDT_Byte, "CCITTFAX4", None, None), + ("MULTIBAND", 2, gdal.GDT_UInt8, "CCITTFAX4", None, None), + ("DATAGRID", 1, gdal.GDT_UInt8, "CCITTFAX4", None, None), ("DATAGRID", 1, gdal.GDT_Int16, "CCITTFAX4", None, None), ] diff --git a/autotest/gdrivers/saga.py b/autotest/gdrivers/saga.py index 866303fce7e0..ccb3228c3bbe 100755 --- a/autotest/gdrivers/saga.py +++ b/autotest/gdrivers/saga.py @@ -124,7 +124,7 @@ def test_saga_5(): def test_saga_6(): gdal_types = [ - gdal.GDT_Byte, + gdal.GDT_UInt8, gdal.GDT_Int16, gdal.GDT_UInt16, gdal.GDT_Int32, diff --git a/autotest/gdrivers/sentinel2.py b/autotest/gdrivers/sentinel2.py index 84241a167f69..5ca3865022bb 100755 --- a/autotest/gdrivers/sentinel2.py +++ b/autotest/gdrivers/sentinel2.py @@ -309,7 +309,7 @@ def test_sentinel2_l1c_4(): band = ds.GetRasterBand(1) assert band.GetColorInterpretation() == gdal.GCI_RedBand - assert band.DataType == gdal.GDT_Byte + assert band.DataType == gdal.GDT_UInt8 ############################################################################### @@ -2648,7 +2648,7 @@ def test_sentinel2_l1c_safe_compact_3(): band = ds.GetRasterBand(1) assert band.GetColorInterpretation() == gdal.GCI_RedBand - assert band.DataType == gdal.GDT_Byte + assert band.DataType == gdal.GDT_UInt8 ############################################################################### diff --git a/autotest/gdrivers/srtmhgt.py b/autotest/gdrivers/srtmhgt.py index 35e8848dd0cd..1cc795067d14 100755 --- a/autotest/gdrivers/srtmhgt.py +++ b/autotest/gdrivers/srtmhgt.py @@ -204,7 +204,7 @@ def test_srtmhgt_all_supported_sizes(tmp_vsimem, width, height, nb_bytes): assert ds is not None assert ds.GetGeoTransform()[1] == pytest.approx(1.0 / (width - 1), rel=1e-8) assert ds.GetRasterBand(1).DataType == ( - gdal.GDT_Byte + gdal.GDT_UInt8 if nb_bytes == 1 else gdal.GDT_Int16 if nb_bytes == 2 diff --git a/autotest/gdrivers/stacta.py b/autotest/gdrivers/stacta.py index 0f157c34b410..82ed3b8a6b5f 100755 --- a/autotest/gdrivers/stacta.py +++ b/autotest/gdrivers/stacta.py @@ -300,7 +300,7 @@ def test_stacta_with_raster_extension_nominal(filename): assert band.GetMetadataItem("name") == "B1" if filename == "data/stacta/test_stac_1_1.json": assert band.GetMetadata_Dict() == {"common_name": "nir", "name": "B1"} - assert band.DataType == gdal.GDT_Byte + assert band.DataType == gdal.GDT_UInt8 assert band.GetNoDataValue() == 1 assert band.GetOffset() == 1.2 assert band.GetScale() == 10 diff --git a/autotest/gdrivers/tiff_profile.py b/autotest/gdrivers/tiff_profile.py index 2f3deff13cd8..758cb2aa271a 100755 --- a/autotest/gdrivers/tiff_profile.py +++ b/autotest/gdrivers/tiff_profile.py @@ -51,7 +51,7 @@ def test_tiff_write_icc(): options = ["SOURCE_ICC_PROFILE=" + icc] driver = gdal.GetDriverByName("GTiff") - ds = driver.Create("tmp/icc_test.tiff", 64, 64, 3, gdal.GDT_Byte, options) + ds = driver.Create("tmp/icc_test.tiff", 64, 64, 3, gdal.GDT_UInt8, options) # Check with dataset from Create() md = ds.GetMetadata("COLOR_PROFILE") @@ -100,7 +100,7 @@ def test_tiff_copy_icc(): options = ["SOURCE_ICC_PROFILE=" + icc] driver = gdal.GetDriverByName("GTiff") - ds = driver.Create("tmp/icc_test.tiff", 64, 64, 3, gdal.GDT_Byte, options) + ds = driver.Create("tmp/icc_test.tiff", 64, 64, 3, gdal.GDT_UInt8, options) ds2 = driver.CreateCopy("tmp/icc_test2.tiff", ds) # Check with dataset from CreateCopy() @@ -137,7 +137,7 @@ def test_tiff_copy_options_icc(): options = ["SOURCE_ICC_PROFILE=" + icc] driver = gdal.GetDriverByName("GTiff") - ds = driver.Create("tmp/icc_test.tiff", 64, 64, 3, gdal.GDT_Byte) + ds = driver.Create("tmp/icc_test.tiff", 64, 64, 3, gdal.GDT_UInt8) ds2 = driver.CreateCopy("tmp/icc_test2.tiff", ds, options=options) # Check with dataset from CreateCopy() @@ -189,7 +189,7 @@ def test_tiff_copy_options_colorimetric_data(): ] driver = gdal.GetDriverByName("GTiff") - ds = driver.Create("tmp/icc_test.tiff", 64, 64, 3, gdal.GDT_Byte) + ds = driver.Create("tmp/icc_test.tiff", 64, 64, 3, gdal.GDT_UInt8) # Check with dataset from CreateCopy() ds2 = driver.CreateCopy("tmp/icc_test2.tiff", ds, options=options) @@ -283,7 +283,7 @@ def test_tiff_copy_colorimetric_data(): ] driver = gdal.GetDriverByName("GTiff") - ds = driver.Create("tmp/icc_test.tiff", 64, 64, 3, gdal.GDT_Byte, options) + ds = driver.Create("tmp/icc_test.tiff", 64, 64, 3, gdal.GDT_UInt8, options) ds = None ds = gdal.Open("tmp/icc_test.tiff") @@ -364,7 +364,7 @@ def test_tiff_update_icc(): # Create dummy file driver = gdal.GetDriverByName("GTiff") - ds = driver.Create("tmp/icc_test.tiff", 64, 64, 3, gdal.GDT_Byte) + ds = driver.Create("tmp/icc_test.tiff", 64, 64, 3, gdal.GDT_UInt8) ds = None ds = gdal.Open("tmp/icc_test.tiff", gdal.GA_Update) @@ -400,7 +400,7 @@ def test_tiff_update_colorimetric(): # Create dummy file driver = gdal.GetDriverByName("GTiff") - ds = driver.Create("tmp/icc_test.tiff", 64, 64, 3, gdal.GDT_Byte) + ds = driver.Create("tmp/icc_test.tiff", 64, 64, 3, gdal.GDT_UInt8) ds = None ds = gdal.Open("tmp/icc_test.tiff", gdal.GA_Update) diff --git a/autotest/gdrivers/tiledb_multidim.py b/autotest/gdrivers/tiledb_multidim.py index 6a6cfa69e818..81e99fa133ec 100755 --- a/autotest/gdrivers/tiledb_multidim.py +++ b/autotest/gdrivers/tiledb_multidim.py @@ -58,24 +58,26 @@ def create(): rg.CreateGroup("group") with pytest.raises(Exception, match="Zero-dimension"): - group.CreateMDArray("ar", [], gdal.ExtendedDataType.Create(gdal.GDT_Byte)) + group.CreateMDArray("ar", [], gdal.ExtendedDataType.Create(gdal.GDT_UInt8)) dim0 = rg.CreateDimension("dim0", None, None, 2) with pytest.raises(Exception, match="Only numeric data types"): group.CreateMDArray("ar", [dim0], gdal.ExtendedDataType.CreateString()) with pytest.raises(Exception, match="Invalid array name"): - group.CreateMDArray("", [dim0], gdal.ExtendedDataType.Create(gdal.GDT_Byte)) + group.CreateMDArray( + "", [dim0], gdal.ExtendedDataType.Create(gdal.GDT_UInt8) + ) os.mkdir(filename + "/group/ar") with pytest.raises(Exception, match="Path .* already exists"): group.CreateMDArray( - "ar", [dim0], gdal.ExtendedDataType.Create(gdal.GDT_Byte) + "ar", [dim0], gdal.ExtendedDataType.Create(gdal.GDT_UInt8) ) os.rmdir(filename + "/group/ar") ar = group.CreateMDArray( - "ar", [dim0], gdal.ExtendedDataType.Create(gdal.GDT_Byte) + "ar", [dim0], gdal.ExtendedDataType.Create(gdal.GDT_UInt8) ) assert group.GetMDArrayNames() == ["ar"] assert ar.GetName() == "ar" @@ -87,7 +89,7 @@ def create(): group.CreateGroup("ar") with pytest.raises(Exception, match="A group named subgroup already exists"): group.CreateMDArray( - "subgroup", [dim0], gdal.ExtendedDataType.Create(gdal.GDT_Byte) + "subgroup", [dim0], gdal.ExtendedDataType.Create(gdal.GDT_UInt8) ) attr = group.CreateAttribute( @@ -167,7 +169,7 @@ def reopen_readonly(): with pytest.raises(Exception, match=r".*not .* in update mode.*"): group.CreateMDArray( - "new_ar", [dim0], gdal.ExtendedDataType.Create(gdal.GDT_Byte) + "new_ar", [dim0], gdal.ExtendedDataType.Create(gdal.GDT_UInt8) ) with pytest.raises(Exception, match=r".*not .* in update mode.*"): @@ -204,7 +206,7 @@ def reopen_readonly(): "gdal_data_type", [ gdal.GDT_Int8, - gdal.GDT_Byte, + gdal.GDT_UInt8, gdal.GDT_Int16, gdal.GDT_UInt16, gdal.GDT_Int32, diff --git a/autotest/gdrivers/tiledb_write.py b/autotest/gdrivers/tiledb_write.py index a4712043c78a..f3dc925229ac 100755 --- a/autotest/gdrivers/tiledb_write.py +++ b/autotest/gdrivers/tiledb_write.py @@ -83,7 +83,7 @@ def test_tiledb_write_update(tmp_path, mode): dsname = str(tmp_path / "tiledb_update") new_ds = gdaltest.tiledb_drv.Create( - dsname, 20, 20, 1, gdal.GDT_Byte, options=options + dsname, 20, 20, 1, gdal.GDT_UInt8, options=options ) new_ds.GetRasterBand(1).WriteArray(np.zeros((20, 20))) meta = new_ds.GetMetadata("IMAGE_STRUCTURE") @@ -252,7 +252,7 @@ def test_tiledb_write_history(tmp_path, mode): dsname = str(tmp_path / "tiledb_versioning") new_ds = gdaltest.tiledb_drv.Create( - dsname, 20, 20, 1, gdal.GDT_Byte, options=options + dsname, 20, 20, 1, gdal.GDT_UInt8, options=options ) new_ds.GetRasterBand(1).WriteArray(np.zeros((20, 20))) @@ -296,7 +296,7 @@ def test_tiledb_write_history(tmp_path, mode): @pytest.mark.parametrize( "outputType", [ - gdal.GDT_Byte, + gdal.GDT_UInt8, gdal.GDT_Int8, gdal.GDT_UInt16, gdal.GDT_Int16, @@ -335,10 +335,10 @@ def test_tiledb_read_arbitrary_array(outputType, tmp_path): @pytest.mark.parametrize( "outputType, nodata, expected_nodata", [ - (gdal.GDT_Byte, 1, 1), - (gdal.GDT_Byte, -1, 255), - (gdal.GDT_Byte, 256, 255), - (gdal.GDT_Byte, 1.5, 255), + (gdal.GDT_UInt8, 1, 1), + (gdal.GDT_UInt8, -1, 255), + (gdal.GDT_UInt8, 256, 255), + (gdal.GDT_UInt8, 1.5, 255), (gdal.GDT_Int8, -1, -1), (gdal.GDT_UInt16, 1, 1), (gdal.GDT_Int16, -1, -1), diff --git a/autotest/gdrivers/vicar.py b/autotest/gdrivers/vicar.py index 505cbe74e26f..4e004c951b7d 100755 --- a/autotest/gdrivers/vicar.py +++ b/autotest/gdrivers/vicar.py @@ -100,7 +100,7 @@ def test_vicar_1(): read_datatypes_lists = [ - ("vicar_byte", gdal.GDT_Byte, 129), + ("vicar_byte", gdal.GDT_UInt8, 129), ("vicar_int16", gdal.GDT_Int16, 129), ("vicar_bigendian_int16", gdal.GDT_Int16, 129), ("vicar_int32", gdal.GDT_Int32, 129), @@ -212,7 +212,7 @@ def test_vicar_create(): src_ds.RasterXSize, src_ds.RasterYSize, src_ds.RasterCount, - gdal.GDT_Byte, + gdal.GDT_UInt8, ) ds.SetMetadata([json.dumps(md)], "json:VICAR") ds.WriteRaster(0, 0, src_ds.RasterXSize, src_ds.RasterYSize, src_ds.ReadRaster()) @@ -288,7 +288,7 @@ def test_vicar_create_label_option_as_inline_value(): filename = "/vsimem/test.vic" assert gdal.GetDriverByName("VICAR").Create( - filename, 1, 1, 1, gdal.GDT_Byte, options=['LABEL={"BLTYPE":"foo"}'] + filename, 1, 1, 1, gdal.GDT_UInt8, options=['LABEL={"BLTYPE":"foo"}'] ) ds = gdal.Open(filename) lbl = ds.GetMetadata_List("json:VICAR")[0] @@ -303,7 +303,7 @@ def test_vicar_create_label_option_as_inline_value_error(): filename = "/vsimem/test.vic" with gdal.quiet_errors(): assert not gdal.GetDriverByName("VICAR").Create( - filename, 1, 1, 1, gdal.GDT_Byte, options=["LABEL={error"] + filename, 1, 1, 1, gdal.GDT_UInt8, options=["LABEL={error"] ) gdal.Unlink(filename) @@ -314,7 +314,7 @@ def test_vicar_create_label_option_as_filename(): json_filename = "/vsimem/test.json" gdal.FileFromMemBuffer(json_filename, '{"BLTYPE":"foo"}') assert gdal.GetDriverByName("VICAR").Create( - filename, 1, 1, 1, gdal.GDT_Byte, options=["LABEL=" + json_filename] + filename, 1, 1, 1, gdal.GDT_UInt8, options=["LABEL=" + json_filename] ) gdal.Unlink(json_filename) ds = gdal.Open(filename) @@ -333,7 +333,7 @@ def test_vicar_create_label_option_as_filename_error(): gdal.FileFromMemBuffer(json_filename, "error") with gdal.quiet_errors(): assert not gdal.GetDriverByName("VICAR").Create( - filename, 1, 1, 1, gdal.GDT_Byte, options=["LABEL=" + json_filename] + filename, 1, 1, 1, gdal.GDT_UInt8, options=["LABEL=" + json_filename] ) gdal.Unlink(json_filename) gdal.Unlink(filename) @@ -390,10 +390,10 @@ def test_vicar_create_georeferencing(georef_format): compressed_datasets_lists = [ - ("vicar_byte_basic", gdal.GDT_Byte, 4672), # BASIC compression - ("vicar_byte_basic2", gdal.GDT_Byte, 4672), # BASIC2 compression + ("vicar_byte_basic", gdal.GDT_UInt8, 4672), # BASIC compression + ("vicar_byte_basic2", gdal.GDT_UInt8, 4672), # BASIC2 compression ("vicar_int16_basic2", gdal.GDT_Int16, 4672), # BASIC2 compression - ("vicar_all_ones_basic2", gdal.GDT_Byte, 34464), # BASIC2 compression + ("vicar_all_ones_basic2", gdal.GDT_UInt8, 34464), # BASIC2 compression ] diff --git a/autotest/gdrivers/vrtderived.py b/autotest/gdrivers/vrtderived.py index cd94c9e37af1..97713ca8199c 100755 --- a/autotest/gdrivers/vrtderived.py +++ b/autotest/gdrivers/vrtderived.py @@ -75,7 +75,7 @@ def test_vrtderived_1(tmp_vsimem): options = [ "subClass=VRTDerivedRasterBand", ] - vrt_ds.AddBand(gdal.GDT_Byte, options) + vrt_ds.AddBand(gdal.GDT_UInt8, options) simpleSourceXML = """ data/byte.tif @@ -118,7 +118,7 @@ def test_vrtderived_2(tmp_vsimem): "PixelFunctionType=dummy", "PixelFunctionLanguage=Python", ] - vrt_ds.AddBand(gdal.GDT_Byte, options) + vrt_ds.AddBand(gdal.GDT_UInt8, options) simpleSourceXML = """ data/byte.tif @@ -162,7 +162,7 @@ def test_vrtderived_3(tmp_vsimem): "PixelFunctionType=dummy", "SourceTransferType=Byte", ] - vrt_ds.AddBand(gdal.GDT_Byte, options) + vrt_ds.AddBand(gdal.GDT_UInt8, options) simpleSourceXML = """ data/byte.tif @@ -198,7 +198,7 @@ def test_vrtderived_4(tmp_vsimem): "SourceTransferType=Invalid", ] with gdal.quiet_errors(): - ret = vrt_ds.AddBand(gdal.GDT_Byte, options) + ret = vrt_ds.AddBand(gdal.GDT_UInt8, options) assert ret != 0, "invalid SourceTransferType value not detected" @@ -1726,7 +1726,7 @@ def test_vrt_pixelfn_nodata( def test_vrt_pixelfn_mean_byte(tmp_vsimem, values): with gdal.GetDriverByName("GTiff").Create( - tmp_vsimem / "src.tif", 63, 1, len(values), gdal.GDT_Byte + tmp_vsimem / "src.tif", 63, 1, len(values), gdal.GDT_UInt8 ) as src: for i in range(len(values)): src.GetRasterBand(i + 1).Fill(values[i]) @@ -2191,12 +2191,12 @@ def test_vrt_split_in_halves(tmp_vsimem): height = 500 with gdal.GetDriverByName("GTiff").Create( - tmp_vsimem / "src1.tif", width, height, 1, gdal.GDT_Byte + tmp_vsimem / "src1.tif", width, height, 1, gdal.GDT_UInt8 ) as src: src.WriteRaster(0, 0, width, height, b"\x01" * (width * height)) with gdal.GetDriverByName("GTiff").Create( - tmp_vsimem / "src2.tif", width, height, 1, gdal.GDT_Byte + tmp_vsimem / "src2.tif", width, height, 1, gdal.GDT_UInt8 ) as src: src.WriteRaster(0, 0, width, height, b"\x02" * (width * height)) @@ -2226,12 +2226,12 @@ def test_vrt_derived_virtual_overviews(tmp_vsimem): height = 2 with gdal.GetDriverByName("GTiff").Create( - tmp_vsimem / "src1.tif", width, height, 1, gdal.GDT_Byte + tmp_vsimem / "src1.tif", width, height, 1, gdal.GDT_UInt8 ) as src: src.WriteRaster(0, 0, width, height, b"\x01" * (width * height)) with gdal.GetDriverByName("GTiff").Create( - tmp_vsimem / "src2.tif", width, height, 1, gdal.GDT_Byte + tmp_vsimem / "src2.tif", width, height, 1, gdal.GDT_UInt8 ) as src: src.WriteRaster(0, 0, width, height, b"\x02" * (width * height)) diff --git a/autotest/gdrivers/vrtpansharpen.py b/autotest/gdrivers/vrtpansharpen.py index 61099767cabc..1fa56b627e9d 100755 --- a/autotest/gdrivers/vrtpansharpen.py +++ b/autotest/gdrivers/vrtpansharpen.py @@ -847,7 +847,7 @@ def test_vrtpansharpen_1(): # Unsupported with gdal.quiet_errors(): - ret = vrt_ds.AddBand(gdal.GDT_Byte) + ret = vrt_ds.AddBand(gdal.GDT_UInt8) assert ret != 0 @@ -1296,7 +1296,7 @@ def test_vrtpansharpen_5(): ) vrt_ds = gdal.Open(xml) - data = vrt_ds.GetRasterBand(1).ReadRaster(buf_type=gdal.GDT_Byte) + data = vrt_ds.GetRasterBand(1).ReadRaster(buf_type=gdal.GDT_UInt8) tmp_ds = gdal.GetDriverByName("MEM").Create("", 800, 400, 1) tmp_ds.WriteRaster(0, 0, 800, 400, data) cs = tmp_ds.GetRasterBand(1).Checksum() @@ -1322,8 +1322,8 @@ def test_vrtpansharpen_6(): # i = 0: VRT has 7 # i = 1: bands have NBITS=7 and VRT 7 # i = 2: bands have NBITS=7 - for dt in [gdal.GDT_Byte, gdal.GDT_UInt16]: - if dt == gdal.GDT_Byte: + for dt in [gdal.GDT_UInt8, gdal.GDT_UInt16]: + if dt == gdal.GDT_UInt8: nbits = 7 elif dt == gdal.GDT_UInt16: nbits = 12 @@ -1385,7 +1385,7 @@ def test_vrtpansharpen_6(): ) == str(nbits) ar = vrt_ds.GetRasterBand(1).ReadAsArray() - if dt == gdal.GDT_Byte: + if dt == gdal.GDT_UInt8: expected_ar = [95, 111, 127, 127, 127, 127, 111, 95] elif dt == gdal.GDT_UInt16: expected_ar = [3040, 3560, 4095, 4095, 4095, 4095, 3560, 3040] @@ -2402,13 +2402,13 @@ def my_handler(typ, errno, msg): def test_vrtpansharpen_slightly_different_extent(tmp_vsimem): ds = gdal.GetDriverByName("GTiff").Create( - "/vsimem/pan.tif", 1000, 1000, 1, gdal.GDT_Byte + "/vsimem/pan.tif", 1000, 1000, 1, gdal.GDT_UInt8 ) ds.SetGeoTransform([0, 1.0 / 1000, 0, 0, 0, -1.0 / 1000]) ds.GetRasterBand(1).Fill(30) ds = None ds = gdal.GetDriverByName("GTiff").Create( - "/vsimem/ms.tif", 500, 500, 2, gdal.GDT_Byte + "/vsimem/ms.tif", 500, 500, 2, gdal.GDT_UInt8 ) ds.SetGeoTransform( [0, 1.0 / 500 - 1.0 / 300000, 0, 0, 0, -(1.0 / 500 - 1.0 / 300000)] diff --git a/autotest/gdrivers/vrtprocesseddataset.py b/autotest/gdrivers/vrtprocesseddataset.py index 4cb4be1a0ccd..5b026f32a8dc 100755 --- a/autotest/gdrivers/vrtprocesseddataset.py +++ b/autotest/gdrivers/vrtprocesseddataset.py @@ -173,7 +173,7 @@ def test_vrtprocesseddataset_affine_combination_nominal(tmp_vsimem, INTERLEAVE): assert ds.RasterCount == 3 assert ds.GetSpatialRef() is None assert ds.GetGeoTransform(can_return_null=True) is None - assert ds.GetRasterBand(1).DataType == gdal.GDT_Byte + assert ds.GetRasterBand(1).DataType == gdal.GDT_UInt8 np.testing.assert_equal(ds.GetRasterBand(1).ReadAsArray(), np.array([[15, 10 + 6]])) np.testing.assert_equal( ds.GetRasterBand(2).ReadAsArray(), np.array([[20 + 3, 20 + 3]]) @@ -227,7 +227,7 @@ def test_vrtprocesseddataset_several_steps(tmp_vsimem): assert ds.RasterCount == 3 assert ds.GetSpatialRef() is None assert ds.GetGeoTransform(can_return_null=True) is None - assert ds.GetRasterBand(1).DataType == gdal.GDT_Byte + assert ds.GetRasterBand(1).DataType == gdal.GDT_UInt8 assert ds.GetRasterBand(1).ComputeRasterMinMax(False) == (1, 1) assert ds.GetRasterBand(2).ComputeRasterMinMax(False) == (2, 2) assert ds.GetRasterBand(3).ComputeRasterMinMax(False) == (3, 3) @@ -262,7 +262,7 @@ def test_vrtprocesseddataset_affine_combination_nodata(tmp_vsimem): """ ) - assert ds.GetRasterBand(1).DataType == gdal.GDT_Byte + assert ds.GetRasterBand(1).DataType == gdal.GDT_UInt8 np.testing.assert_equal(ds.GetRasterBand(1).ReadAsArray(), np.array([[1, 5]])) # 0 should actually be 3-2=1, but this is the nodata value hence the replacement value np.testing.assert_equal(ds.GetRasterBand(2).ReadAsArray(), np.array([[1, 0]])) @@ -294,7 +294,7 @@ def test_vrtprocesseddataset_affine_combination_nodata_as_parameter(tmp_vsimem): """ ) - assert ds.GetRasterBand(1).DataType == gdal.GDT_Byte + assert ds.GetRasterBand(1).DataType == gdal.GDT_UInt8 np.testing.assert_equal(ds.GetRasterBand(1).ReadAsArray(), np.array([[255, 5]])) # 254 should actually be 256+1*2+(-1)*3=255, but this is the nodata value hence the replacement value np.testing.assert_equal(ds.GetRasterBand(2).ReadAsArray(), np.array([[255, 254]])) @@ -330,7 +330,7 @@ def test_vrtprocesseddataset_affine_combination_replacement_nodata(tmp_vsimem): """ ) - assert ds.GetRasterBand(1).DataType == gdal.GDT_Byte + assert ds.GetRasterBand(1).DataType == gdal.GDT_UInt8 np.testing.assert_equal(ds.GetRasterBand(1).ReadAsArray(), np.array([[255, 5]])) # 254 should actually be 256+1*2+(-1)*3=255, but this is the nodata value hence the replacement value np.testing.assert_equal(ds.GetRasterBand(2).ReadAsArray(), np.array([[255, 128]])) @@ -739,7 +739,7 @@ def test_vrtprocesseddataset_dehazing_edge_effects(tmp_vsimem): 257, 257, 1, - gdal.GDT_Byte, + gdal.GDT_UInt8, ["TILED=YES", "BLOCKXSIZE=256", "BLOCKYSIZE=256"], ) src_ds.GetRasterBand(1).Fill(10) diff --git a/autotest/gdrivers/vrtrawlink.py b/autotest/gdrivers/vrtrawlink.py index 587b8bf3ed4f..b884805b4dc3 100755 --- a/autotest/gdrivers/vrtrawlink.py +++ b/autotest/gdrivers/vrtrawlink.py @@ -73,7 +73,7 @@ def small_raw_vrt(tmp_path): "relativeToVRT=1", ] - result = ds.AddBand(gdal.GDT_Byte, options) + result = ds.AddBand(gdal.GDT_UInt8, options) assert result == gdal.CE_None, "AddBand() returned error code" band = ds.GetRasterBand(1) @@ -136,7 +136,7 @@ def test_vrtrawlink_4(tmp_path, small_raw_vrt): byte_data = band_1.ReadRaster(0, 0, 31, 35) band = rawlink_ds.GetRasterBand(2) - band.WriteRaster(0, 0, 31, 35, byte_data, 31, 35, gdal.GDT_Byte) + band.WriteRaster(0, 0, 31, 35, byte_data, 31, 35, gdal.GDT_UInt8) rawlink_ds.FlushCache() diff --git a/autotest/gdrivers/vrtwarp.py b/autotest/gdrivers/vrtwarp.py index c52825504755..7d21a21ae32f 100755 --- a/autotest/gdrivers/vrtwarp.py +++ b/autotest/gdrivers/vrtwarp.py @@ -761,11 +761,11 @@ def test_vrtwarp_autocreatewarpedvrt_int16_nodata_32767(): def test_vrtwarp_autocreatewarpedvrt_invalid_nodata(): - ds = gdal.GetDriverByName("MEM").Create("", 1, 1, 1, gdal.GDT_Byte) + ds = gdal.GetDriverByName("MEM").Create("", 1, 1, 1, gdal.GDT_UInt8) ds.SetGeoTransform([0, 1, 0, 0, 0, -1]) ds.GetRasterBand(1).SetNoDataValue(-9999) vrt_ds = gdal.AutoCreateWarpedVRT(ds) - assert vrt_ds.GetRasterBand(1).DataType == gdal.GDT_Byte + assert vrt_ds.GetRasterBand(1).DataType == gdal.GDT_UInt8 ############################################################################### @@ -773,7 +773,7 @@ def test_vrtwarp_autocreatewarpedvrt_invalid_nodata(): def test_vrtwarp_add_band_gdt_unknown(): - ds = gdal.GetDriverByName("MEM").Create("", 1, 1, 1, gdal.GDT_Byte) + ds = gdal.GetDriverByName("MEM").Create("", 1, 1, 1, gdal.GDT_UInt8) ds.SetGeoTransform([0, 1, 0, 0, 0, -1]) vrt_ds = gdal.AutoCreateWarpedVRT(ds) with pytest.raises(Exception, match="Illegal GDT_Unknown/GDT_TypeCount argument"): @@ -786,7 +786,7 @@ def test_vrtwarp_add_band_gdt_unknown(): @gdaltest.enable_exceptions() def test_vrtwarp_write_to_band(): - ds = gdal.GetDriverByName("MEM").Create("", 1, 1, 1, gdal.GDT_Byte) + ds = gdal.GetDriverByName("MEM").Create("", 1, 1, 1, gdal.GDT_UInt8) ds.SetGeoTransform([0, 1, 0, 0, 0, -1]) ds.GetRasterBand(1).SetNoDataValue(-9999) vrt_ds = gdal.AutoCreateWarpedVRT(ds) diff --git a/autotest/gdrivers/wcs.py b/autotest/gdrivers/wcs.py index 924d3a627b47..3913385e9f5b 100755 --- a/autotest/gdrivers/wcs.py +++ b/autotest/gdrivers/wcs.py @@ -79,7 +79,7 @@ def test_wcs_3(geoserver_ds): gdaltest.check_geotransform(gt, expected_gt) assert ( - geoserver_ds.GetRasterBand(1).DataType == gdal.GDT_Byte + geoserver_ds.GetRasterBand(1).DataType == gdal.GDT_UInt8 ), "wrong band data type" diff --git a/autotest/gdrivers/wms.py b/autotest/gdrivers/wms.py index 60a877a93ab7..e0d3af05cfe0 100755 --- a/autotest/gdrivers/wms.py +++ b/autotest/gdrivers/wms.py @@ -80,7 +80,7 @@ def test_wms_3(gpwv3_wms): assert gpwv3_wms.GetRasterBand(1).GetOverviewCount() >= 1, "no overviews!" - assert gpwv3_wms.GetRasterBand(1).DataType >= gdal.GDT_Byte, "wrong band data type" + assert gpwv3_wms.GetRasterBand(1).DataType >= gdal.GDT_UInt8, "wrong band data type" ############################################################################### diff --git a/autotest/gdrivers/xyz.py b/autotest/gdrivers/xyz.py index 0f1cc36c935c..a7b4fe4db844 100755 --- a/autotest/gdrivers/xyz.py +++ b/autotest/gdrivers/xyz.py @@ -446,7 +446,7 @@ def test_xyz_looks_like_organized_by_columns_but_is_not(): assert ds.GetGeoTransform() == pytest.approx( (371998.0, 1.0, 0.0, 5806917.0, 0.0, 1.0) ) - assert ds.GetRasterBand(1).DataType == gdal.GDT_Byte + assert ds.GetRasterBand(1).DataType == gdal.GDT_UInt8 assert struct.unpack("b" * (2 * 3), ds.ReadRaster()) == (0, 1, 0, 2, 3, 4) @@ -472,7 +472,7 @@ def test_xyz_looks_like_organized_by_columns_but_is_not_case2(): assert ds.GetGeoTransform() == pytest.approx( (395998.0, 1.0, 0.0, 5807443.0, 0.0, 1.0) ) - assert ds.GetRasterBand(1).DataType == gdal.GDT_Byte + assert ds.GetRasterBand(1).DataType == gdal.GDT_UInt8 assert struct.unpack("b" * (2 * 5), ds.ReadRaster()) == ( 0, 1, @@ -510,7 +510,7 @@ def test_xyz_looks_like_missing_lines(): ds = gdal.Open("/vsimem/grid.xyz") assert ds.RasterXSize == 3 and ds.RasterYSize == 9 assert ds.GetGeoTransform() == pytest.approx((97.0, 1.0, 0.0, 91.0, 0.0, 1.0)) - assert ds.GetRasterBand(1).DataType == gdal.GDT_Byte + assert ds.GetRasterBand(1).DataType == gdal.GDT_UInt8 assert struct.unpack("b" * (3 * 9), ds.ReadRaster()) == ( 0, 1, diff --git a/autotest/gdrivers/zarr_driver.py b/autotest/gdrivers/zarr_driver.py index a2cc1a9a7278..433e5c4326db 100644 --- a/autotest/gdrivers/zarr_driver.py +++ b/autotest/gdrivers/zarr_driver.py @@ -36,7 +36,7 @@ def module_disable_exceptions(): _gdal_data_type_to_array_type = { gdal.GDT_Int8: "b", - gdal.GDT_Byte: "B", + gdal.GDT_UInt8: "B", gdal.GDT_Int16: "h", gdal.GDT_UInt16: "H", gdal.GDT_Int32: "i", @@ -55,13 +55,13 @@ def module_disable_exceptions(): @pytest.mark.parametrize( "dtype,gdaltype,fill_value,nodata_value", [ - ["!b1", gdal.GDT_Byte, None, None], + ["!b1", gdal.GDT_UInt8, None, None], ["!i1", gdal.GDT_Int8, None, None], ["!i1", gdal.GDT_Int8, -1, -1], - ["!u1", gdal.GDT_Byte, None, None], + ["!u1", gdal.GDT_UInt8, None, None], [ "!u1", - gdal.GDT_Byte, + gdal.GDT_UInt8, "1", 1, ], # not really legit to have the fill_value as a str @@ -773,7 +773,7 @@ def test_zarr_read_fortran_order(name): ar = rg.OpenMDArray(rg.GetMDArrayNames()[0]) assert ar assert ar.Read( - buffer_datatype=gdal.ExtendedDataType.Create(gdal.GDT_Byte) + buffer_datatype=gdal.ExtendedDataType.Create(gdal.GDT_UInt8) ) == array.array("b", [i for i in range(16)]) @@ -814,7 +814,7 @@ def test_zarr_read_fortran_order_3d(): ar = rg.OpenMDArray(rg.GetMDArrayNames()[0]) assert ar assert ar.Read( - buffer_datatype=gdal.ExtendedDataType.Create(gdal.GDT_Byte) + buffer_datatype=gdal.ExtendedDataType.Create(gdal.GDT_UInt8) ) == array.array("b", [i for i in range(2 * 3 * 4)]) @@ -871,7 +871,7 @@ def test_zarr_read_compound_not_aligned(): assert comps[0].GetType().GetNumericDataType() == gdal.GDT_UInt16 assert comps[1].GetName() == "b" assert comps[1].GetOffset() == 2 - assert comps[1].GetType().GetNumericDataType() == gdal.GDT_Byte + assert comps[1].GetType().GetNumericDataType() == gdal.GDT_UInt8 assert comps[2].GetName() == "c" assert comps[2].GetOffset() == 4 assert comps[2].GetType().GetNumericDataType() == gdal.GDT_UInt16 @@ -907,7 +907,7 @@ def test_zarr_read_compound_complex(): assert len(comps) == 4 assert comps[0].GetName() == "a" assert comps[0].GetOffset() == 0 - assert comps[0].GetType().GetNumericDataType() == gdal.GDT_Byte + assert comps[0].GetType().GetNumericDataType() == gdal.GDT_UInt8 assert comps[1].GetName() == "b" assert comps[1].GetOffset() == 2 assert comps[1].GetType().GetClass() == gdal.GEDTC_COMPOUND @@ -1931,8 +1931,8 @@ def getCompoundDT(): @pytest.mark.parametrize( "datatype,nodata", [ - [gdal.ExtendedDataType.Create(gdal.GDT_Byte), None], - [gdal.ExtendedDataType.Create(gdal.GDT_Byte), 1], + [gdal.ExtendedDataType.Create(gdal.GDT_UInt8), None], + [gdal.ExtendedDataType.Create(gdal.GDT_UInt8), 1], [gdal.ExtendedDataType.Create(gdal.GDT_UInt16), None], [gdal.ExtendedDataType.Create(gdal.GDT_Int16), None], [gdal.ExtendedDataType.Create(gdal.GDT_UInt32), None], @@ -2070,14 +2070,14 @@ def at_creation(): rg = ds.GetRootGroup() assert rg assert ( - rg.CreateMDArray("foo", [], gdal.ExtendedDataType.Create(gdal.GDT_Byte)) + rg.CreateMDArray("foo", [], gdal.ExtendedDataType.Create(gdal.GDT_UInt8)) is not None ) gdal.Mkdir(tmp_vsimem / "test.zarr/directory_with_that_name", 0) with gdal.quiet_errors(): assert ( rg.CreateMDArray( - array_name, [], gdal.ExtendedDataType.Create(gdal.GDT_Byte) + array_name, [], gdal.ExtendedDataType.Create(gdal.GDT_UInt8) ) is None ) @@ -2093,7 +2093,7 @@ def after_reopen(): with gdal.quiet_errors(): assert ( rg.CreateMDArray( - array_name, [], gdal.ExtendedDataType.Create(gdal.GDT_Byte) + array_name, [], gdal.ExtendedDataType.Create(gdal.GDT_UInt8) ) is None ) @@ -2131,7 +2131,7 @@ def create(): rg.CreateMDArray( "test", [], - gdal.ExtendedDataType.Create(gdal.GDT_Byte), + gdal.ExtendedDataType.Create(gdal.GDT_UInt8), ["COMPRESS=" + compressor] + options, ) is not None @@ -2242,7 +2242,7 @@ def create(): ar = rg.CreateMDArray( "test", [dim], - gdal.ExtendedDataType.Create(gdal.GDT_Byte), + gdal.ExtendedDataType.Create(gdal.GDT_UInt8), ["COMPRESS=" + compressor] + options, ) assert ar.Write(array.array("b", [1, 2])) == gdal.CE_None @@ -2304,7 +2304,7 @@ def read(): "gdal_data_type", [ gdal.GDT_Int8, - gdal.GDT_Byte, + gdal.GDT_UInt8, gdal.GDT_Int16, gdal.GDT_UInt16, gdal.GDT_Int32, @@ -2833,7 +2833,7 @@ def test_zarr_create_array_bad_compressor(tmp_vsimem, format): rg.CreateMDArray( "test", [], - gdal.ExtendedDataType.Create(gdal.GDT_Byte), + gdal.ExtendedDataType.Create(gdal.GDT_UInt8), ["COMPRESS=invalid"], ) is None @@ -2849,7 +2849,7 @@ def create(): assert ds is not None rg = ds.GetRootGroup() assert rg - ar = rg.CreateMDArray("test", [], gdal.ExtendedDataType.Create(gdal.GDT_Byte)) + ar = rg.CreateMDArray("test", [], gdal.ExtendedDataType.Create(gdal.GDT_UInt8)) assert ar assert ar.GetFullName() == "/test" @@ -2913,7 +2913,7 @@ def create(): assert ds is not None rg = ds.GetRootGroup() assert rg - ar = rg.CreateMDArray("test", [], gdal.ExtendedDataType.Create(gdal.GDT_Byte)) + ar = rg.CreateMDArray("test", [], gdal.ExtendedDataType.Create(gdal.GDT_UInt8)) assert ar crs = osr.SpatialReference() crs.ImportFromEPSG(4326) @@ -2945,11 +2945,11 @@ def create(): dim0 = rg.CreateDimension("dim0", None, None, 2) dim0_ar = rg.CreateMDArray( - "dim0", [dim0], gdal.ExtendedDataType.Create(gdal.GDT_Byte) + "dim0", [dim0], gdal.ExtendedDataType.Create(gdal.GDT_UInt8) ) dim0.SetIndexingVariable(dim0_ar) - rg.CreateMDArray("test", [dim0], gdal.ExtendedDataType.Create(gdal.GDT_Byte)) + rg.CreateMDArray("test", [dim0], gdal.ExtendedDataType.Create(gdal.GDT_UInt8)) create() @@ -2965,11 +2965,11 @@ def create(): @pytest.mark.parametrize( "dtype,gdaltype,fill_value,nodata_value", [ - ["!b1", gdal.GDT_Byte, None, None], + ["!b1", gdal.GDT_UInt8, None, None], ["!i1", gdal.GDT_Int16, None, None], ["!i1", gdal.GDT_Int16, -1, -1], - ["!u1", gdal.GDT_Byte, None, None], - ["!u1", gdal.GDT_Byte, "1", 1], + ["!u1", gdal.GDT_UInt8, None, None], + ["!u1", gdal.GDT_UInt8, "1", 1], ["i2", gdal.GDT_Int16, None, None], [" 0 and < 255 -@pytest.mark.parametrize("dt", [gdal.GDT_Byte, gdal.GDT_Float32]) +@pytest.mark.parametrize("dt", [gdal.GDT_UInt8, gdal.GDT_Float32]) def test_gdalwarp_lib_132(tmp_vsimem, dt): src_ds = gdal.GetDriverByName("GTiff").Create( @@ -1767,7 +1767,7 @@ def test_gdalwarp_lib_132(tmp_vsimem, dt): for x in range(33): data = struct.unpack( "B" * 1, - ds.GetRasterBand(i + 1).ReadRaster(i, 0, 1, 1, buf_type=gdal.GDT_Byte), + ds.GetRasterBand(i + 1).ReadRaster(i, 0, 1, 1, buf_type=gdal.GDT_UInt8), )[0] if data != pytest.approx(expected_val[i], abs=1): print(dt) @@ -2171,7 +2171,7 @@ def test_gdalwarp_lib_135n(gdalwarp_135_grid_gtx): src_ds.GetRasterBand(1).SetUnitType("ft") ds = gdal.Warp( - "", src_ds, format="MEM", dstSRS="EPSG:4979", outputType=gdal.GDT_Byte + "", src_ds, format="MEM", dstSRS="EPSG:4979", outputType=gdal.GDT_UInt8 ) data = struct.unpack("B" * 1, ds.GetRasterBand(1).ReadRaster())[0] assert data == 120, "Bad value" @@ -2191,7 +2191,7 @@ def test_gdalwarp_lib_135o(gdalwarp_135_grid_gtx): src_ds.GetRasterBand(1).SetUnitType("US survey foot") ds = gdal.Warp( - "", src_ds, format="MEM", dstSRS="EPSG:4979", outputType=gdal.GDT_Byte + "", src_ds, format="MEM", dstSRS="EPSG:4979", outputType=gdal.GDT_UInt8 ) data = struct.unpack("B" * 1, ds.GetRasterBand(1).ReadRaster())[0] assert data == 120, "Bad value" diff --git a/doc/source/api/csharp/csharp_raster.rst b/doc/source/api/csharp/csharp_raster.rst index fde6af99db4b..8c4cfbb63dbe 100644 --- a/doc/source/api/csharp/csharp_raster.rst +++ b/doc/source/api/csharp/csharp_raster.rst @@ -93,7 +93,7 @@ In this case the interface implementation uses an internally created unmanaged a CPLErr retval; IntPtr ptr = Marshal.AllocHGlobal(buf_xSize * buf_ySize * Marshal.SizeOf(buffer[0])); try { - retval = ReadRaster(xOff, yOff, xSize, ySize, ptr, buf_xSize, buf_ySize, DataType.GDT_Byte, pixelSpace, lineSpace); + retval = ReadRaster(xOff, yOff, xSize, ySize, ptr, buf_xSize, buf_ySize, DataType.GDT_UInt8, pixelSpace, lineSpace); Marshal.Copy(ptr, buffer, 0, buf_xSize * buf_ySize); } finally { Marshal.FreeHGlobal(ptr); @@ -117,7 +117,7 @@ Raster data can be read into the C# bitmap directly using the following approach { int stride = bitmapData.Stride; IntPtr buf = bitmapData.Scan0; - band.ReadRaster(0, 0, width, height, buf, width, height, DataType.GDT_Byte, 1, stride); + band.ReadRaster(0, 0, width, height, buf, width, height, DataType.GDT_UInt8, 1, stride); } finally { @@ -181,7 +181,7 @@ When reading images with indexed color representations, the programmer might hav int stride = bitmapData.Stride; IntPtr buf = bitmapData.Scan0; - band.ReadRaster(0, 0, width, height, buf, width, height, DataType.GDT_Byte, 1, stride); + band.ReadRaster(0, 0, width, height, buf, width, height, DataType.GDT_UInt8, 1, stride); } finally { @@ -209,7 +209,7 @@ When reading grayscale images, the programmer should create a sufficient palette int stride = bitmapData.Stride; IntPtr buf = bitmapData.Scan0; - band.ReadRaster(0, 0, width, height, buf, width, height, DataType.GDT_Byte, 1, stride); + band.ReadRaster(0, 0, width, height, buf, width, height, DataType.GDT_UInt8, 1, stride); } finally { diff --git a/doc/source/development/rfc/rfc14_imagestructure.rst b/doc/source/development/rfc/rfc14_imagestructure.rst index 0fc62c8a0de1..c5433c5ef3e2 100644 --- a/doc/source/development/rfc/rfc14_imagestructure.rst +++ b/doc/source/development/rfc/rfc14_imagestructure.rst @@ -32,12 +32,12 @@ be used here as there. NBITS:: The actual number of bits used for this band, or the bands of this dataset. Normally only present when the number of bits is non-standard for the datatype, such as when a 1 bit TIFF is represented -through GDAL as GDT_Byte. +through GDAL as GDT_UInt8. INTERLEAVE:: This only applies on datasets, and the value should be one of PIXEL, LINE or BAND. It can be used as a data access hint. -PIXELTYPE:: This may appear on a GDT_Byte band (or the corresponding +PIXELTYPE:: This may appear on a GDT_UInt8 band (or the corresponding dataset) and have the value SIGNEDBYTE to indicate the unsigned byte values between 128 and 255 should be interpreted as being values between -128 and -1 for applications that recognise the SIGNEDBYTE type. diff --git a/doc/source/development/rfc/rfc15_nodatabitmask.rst b/doc/source/development/rfc/rfc15_nodatabitmask.rst index bd3005a0f71f..4676879c4759 100644 --- a/doc/source/development/rfc/rfc15_nodatabitmask.rst +++ b/doc/source/development/rfc/rfc15_nodatabitmask.rst @@ -24,7 +24,7 @@ values, and alpha bands). The basic approach is to treat such masks as raster bands, but not regular raster bands on the datasource. Instead they are freestanding raster bands in a manner similar to the overview raster band objects. -The masks are represented as GDT_Byte bands with a value of zero +The masks are represented as GDT_UInt8 bands with a value of zero indicating nodata and non-zero values indicating valid data. Normally the value 255 will be used for valid data pixels. @@ -82,7 +82,7 @@ GetMaskBand() that returns one of three default implementations. return GMF_NODATA. - If there is no nodata value, but the dataset has an alpha band that seems to apply to this band (specific rules yet to be determined) and - that is of type GDT_Byte then that alpha band will be returned, and + that is of type GDT_UInt8 then that alpha band will be returned, and the flags GMF_PER_DATASET and GMF_ALPHA will be returned in the flags. - If neither of the above apply, an instance of the new @@ -134,7 +134,7 @@ not copied since they are just derived information. Alpha Bands ----------- -When a dataset has a normal GDT_Byte alpha (transparency) band that +When a dataset has a normal GDT_UInt8 alpha (transparency) band that applies, it should be returned as the null mask, but the GetMaskFlags() method should include GMF_ALPHA. For processing purposes any value other than 0 should be treated as valid data, though some algorithms will diff --git a/doc/source/development/rfc/rfc59.1_utilities_as_a_library.rst b/doc/source/development/rfc/rfc59.1_utilities_as_a_library.rst index 202dfa7f4d4c..2822b5d14a63 100644 --- a/doc/source/development/rfc/rfc59.1_utilities_as_a_library.rst +++ b/doc/source/development/rfc/rfc59.1_utilities_as_a_library.rst @@ -352,7 +352,7 @@ keywords. So various combinations are possible : Keyword arguments are : options --- can be be an array of strings, a string or let empty and filled from other keywords. format --- output format ("GTiff", etc...) - outputType --- output type (gdal.GDT_Byte, etc...) + outputType --- output type (gdal.GDT_UInt8, etc...) bandList --- array of band numbers (index start at 1) maskBand --- mask band to generate or not ("none", "auto", "mask", 1, ...) width --- width of the output raster in pixel @@ -426,8 +426,8 @@ keywords. So various combinations are possible : dstSRS --- output SRS srcAlpha --- whether to force the last band of the input dataset to be considered as an alpha band dstAlpha --- whether to force the creation of an output alpha band - outputType --- output type (gdal.GDT_Byte, etc...) - workingType --- working type (gdal.GDT_Byte, etc...) + outputType --- output type (gdal.GDT_UInt8, etc...) + workingType --- working type (gdal.GDT_UInt8, etc...) warpOptions --- list of warping options errorThreshold --- error threshold for approximation transformer (in pixels) warpMemoryLimit --- size of working buffer in bytes @@ -604,7 +604,7 @@ keywords. So various combinations are possible : Keyword arguments are : options --- can be be an array of strings, a string or let empty and filled from other keywords. format --- output format ("GTiff", etc...) - outputType --- output type (gdal.GDT_Byte, etc...) + outputType --- output type (gdal.GDT_UInt8, etc...) width --- width of the output raster in pixel height --- height of the output raster in pixel creationOptions --- list of creation options diff --git a/doc/source/development/rfc/rfc87_signed_int8.rst b/doc/source/development/rfc/rfc87_signed_int8.rst index 9c0fdefe7891..ab65b0357182 100644 --- a/doc/source/development/rfc/rfc87_signed_int8.rst +++ b/doc/source/development/rfc/rfc87_signed_int8.rst @@ -22,7 +22,7 @@ Motivation ---------- :ref:`rfc-14` introduced in GDAL 1.5.0 a way of specifying that a 8-bit integer -should be interpreted as signed, by (ab)using the GDT_Byte type, with the +should be interpreted as signed, by (ab)using the GDT_UInt8 type, with the addition of the PIXELTYPE=SIGNEDBYTE metadata item in the IMAGE_STRUCTURE metadata domain of bands for which this is desired. @@ -57,7 +57,7 @@ specifically with a subset of types (e.g Byte, Float32) and promoted other types to the closest one will automatically have proper support for the new data type (e.g overview computation). -Existing drivers that, on reading, reported GDT_Byte + PIXELTYPE=SIGNEDBYTE are +Existing drivers that, on reading, reported GDT_UInt8 + PIXELTYPE=SIGNEDBYTE are modified to report GDT_Int8. This has backward compatibility impact to external code. This affects the EEDAI, ERS, GTA, GTiff, HFA, netCDF, PostGISRaster, EHDR, RRaster, Rasterlite2 and Zarr drivers. diff --git a/doc/source/development/rfc/rfc88_googletest.rst b/doc/source/development/rfc/rfc88_googletest.rst index 4ac2d0e10cf4..825fc0fdb068 100644 --- a/doc/source/development/rfc/rfc88_googletest.rst +++ b/doc/source/development/rfc/rfc88_googletest.rst @@ -126,9 +126,9 @@ all potential combinations of (datatype1, datatype2) // Test GDALDataTypeUnion() on all (GDALDataType, GDALDataType) combinations template<> template<> void object::test<6>() { - for(int i=GDT_Byte;i(i); GDALDataType eDT2 = static_cast(j); @@ -156,9 +156,9 @@ can be written in GoogleTest as static std::vector> GetTupleValues() { std::vector> ret; - for( GDALDataType eIn = GDT_Byte; eIn < GDT_TypeCount; eIn = static_cast(eIn + 1) ) + for( GDALDataType eIn = GDT_UInt8; eIn < GDT_TypeCount; eIn = static_cast(eIn + 1) ) { - for( GDALDataType eOut = GDT_Byte; eOut < GDT_TypeCount; eOut = static_cast(eOut + 1) ) + for( GDALDataType eOut = GDT_UInt8; eOut < GDT_TypeCount; eOut = static_cast(eOut + 1) ) { ret.emplace_back(std::make_tuple(eIn, eOut)); } diff --git a/doc/source/development/testing.rst b/doc/source/development/testing.rst index 72f5bdfca7a2..4bcabece5b1f 100644 --- a/doc/source/development/testing.rst +++ b/doc/source/development/testing.rst @@ -156,7 +156,7 @@ e.g.: .. code-block:: python - @pytest.mark.parametrize("dt,expected_size", [(gdal.GDT_Byte, 1), + @pytest.mark.parametrize("dt,expected_size", [(gdal.GDT_UInt8, 1), (gdal.GDT_UInt16, 2)] def test_datatypesize(dt,expected_size): assert gdal.GetDataTypeSizeBytes(dt) == expected_size @@ -166,7 +166,7 @@ instead of .. code-block:: python def test_datatypesize_DO_NOT_DO_THAT(): - for dt, expected_size in [(gdal.GDT_Byte, 1), (gdal.GDT_UInt16, 2)]: + for dt, expected_size in [(gdal.GDT_UInt8, 1), (gdal.GDT_UInt16, 2)]: assert gdal.GetDataTypeSizeBytes(dt) == expected_size @@ -243,9 +243,9 @@ GoogleTest also offers capabilities for parametrized tests. For example: static std::vector> GetTupleValues() { std::vector> ret; - for( GDALDataType eIn = GDT_Byte; eIn < GDT_TypeCount; eIn = static_cast(eIn + 1) ) + for( GDALDataType eIn = GDT_UInt8; eIn < GDT_TypeCount; eIn = static_cast(eIn + 1) ) { - for( GDALDataType eOut = GDT_Byte; eOut < GDT_TypeCount; eOut = static_cast(eOut + 1) ) + for( GDALDataType eOut = GDT_UInt8; eOut < GDT_TypeCount; eOut = static_cast(eOut + 1) ) { ret.emplace_back(std::make_tuple(eIn, eOut)); } diff --git a/doc/source/drivers/raster/pcraster.rst b/doc/source/drivers/raster/pcraster.rst index ce8dd8670302..285ff6c8b6fb 100644 --- a/doc/source/drivers/raster/pcraster.rst +++ b/doc/source/drivers/raster/pcraster.rst @@ -40,7 +40,7 @@ and cell representation is determined according to the following rules: =============== =================== ========================== Source type Target value scale Target cell representation -GDT_Byte VS_BOOLEAN CR_UINT1 +GDT_UInt8 VS_BOOLEAN CR_UINT1 GDT_Int32 VS_NOMINAL CR_INT4 GDT_Float32 VS_SCALAR CR_REAL4 GDT_Float64 VS_SCALAR CR_REAL4 diff --git a/doc/source/drivers/raster/rcm.rst b/doc/source/drivers/raster/rcm.rst index cbe6f2d89531..b109f8e0fb02 100644 --- a/doc/source/drivers/raster/rcm.rst +++ b/doc/source/drivers/raster/rcm.rst @@ -47,7 +47,7 @@ will fail. One caveat worth noting is that the RCM driver will supply the calibrated data as GDT_Float32 or GDT_CFloat32 depending on the type of calibration selected. -The uncalibrated data is provided as GDT_Int16/GDT_Byte/GDT_CInt16, also +The uncalibrated data is provided as GDT_Int16/GDT_UInt8/GDT_CInt16, also depending on the type of product selected. See Also diff --git a/doc/source/drivers/raster/rs2.rst b/doc/source/drivers/raster/rs2.rst index 33a89b84e974..384e2f6adf9d 100644 --- a/doc/source/drivers/raster/rs2.rst +++ b/doc/source/drivers/raster/rs2.rst @@ -61,7 +61,7 @@ the calibration LUT applied will fail. One caveat worth noting is that the RADARSAT-2 driver will supply the calibrated data as GDT_Float32 or GDT_CFloat32 depending on the type of calibration selected. The uncalibrated data is provided as -GDT_Int16/GDT_Byte/GDT_CInt16, also depending on the type of product +GDT_Int16/GDT_UInt8/GDT_CInt16, also depending on the type of product selected. See Also diff --git a/doc/source/drivers/raster/sdat.rst b/doc/source/drivers/raster/sdat.rst index d76509f49f53..a2606b92b522 100644 --- a/doc/source/drivers/raster/sdat.rst +++ b/doc/source/drivers/raster/sdat.rst @@ -16,13 +16,13 @@ The driver can read compressed .sg-grd-z files that are ZIP archives with .sgrd, .sdat and .prj files. The driver supports reading the following SAGA datatypes (in brackets -the corresponding GDAL types): BIT (GDT_Byte), BYTE_UNSIGNED (GDT_Byte), -BYTE (GDT_Byte), SHORTINT_UNSIGNED (GDT_UInt16), SHORTINT (GDT_Int16), +the corresponding GDAL types): BIT (GDT_UInt8), BYTE_UNSIGNED (GDT_UInt8), +BYTE (GDT_UInt8), SHORTINT_UNSIGNED (GDT_UInt16), SHORTINT (GDT_Int16), INTEGER_UNSIGNED (GDT_UInt32), INTEGER (GDT_Int32), FLOAT (GDT_Float32) and DOUBLE (GDT_Float64). The driver supports writing the following SAGA datatypes: BYTE_UNSIGNED -(GDT_Byte), SHORTINT_UNSIGNED (GDT_UInt16), SHORTINT (GDT_Int16), +(GDT_UInt8), SHORTINT_UNSIGNED (GDT_UInt16), SHORTINT (GDT_Int16), INTEGER_UNSIGNED (GDT_UInt32), INTEGER (GDT_Int32), FLOAT (GDT_Float32) and DOUBLE (GDT_Float64). diff --git a/doc/source/drivers/raster/vrt.rst b/doc/source/drivers/raster/vrt.rst index 97239b11f61f..7563b190a2b8 100644 --- a/doc/source/drivers/raster/vrt.rst +++ b/doc/source/drivers/raster/vrt.rst @@ -1063,7 +1063,7 @@ instead of using the simple source. ""; // Create the virtual dataset. - poVRTDS = poDriver->Create( "", 512, 512, 1, GDT_Byte, NULL ); + poVRTDS = poDriver->Create( "", 512, 512, 1, GDT_UInt8, NULL ); poVRTDS->GetRasterBand(1)->SetMetadataItem("source_0",pszFilterSourceXML, "new_vrt_sources"); @@ -1115,7 +1115,7 @@ should be specified with the above :cpp:func:`GDALRasterBand::SetMetadataItem` e GDALDriver *poDriver = (GDALDriver *) GDALGetDriverByName( "VRT" ); GDALDataset *poVRTDS; - poVRTDS = poDriver->Create( "out.vrt", 512, 512, 0, GDT_Byte, NULL ); + poVRTDS = poDriver->Create( "out.vrt", 512, 512, 0, GDT_UInt8, NULL ); char** papszOptions = NULL; papszOptions = CSLAddNameValue(papszOptions, "subclass", "VRTRawRasterBand"); // if not specified, default to VRTRasterBand papszOptions = CSLAddNameValue(papszOptions, "SourceFilename", "src.tif"); // mandatory @@ -1124,7 +1124,7 @@ should be specified with the above :cpp:func:`GDALRasterBand::SetMetadataItem` e papszOptions = CSLAddNameValue(papszOptions, "LineOffset", "1024"); // optional. default = size of band type * width papszOptions = CSLAddNameValue(papszOptions, "ByteOrder", "LSB"); // optional. default = machine order papszOptions = CSLAddNameValue(papszOptions, "relativeToVRT", "true"); // optional. default = false - poVRTDS->AddBand(GDT_Byte, papszOptions); + poVRTDS->AddBand(GDT_UInt8, papszOptions); CSLDestroy(papszOptions); delete poVRTDS; diff --git a/doc/source/tutorials/raster_api_tut.rst b/doc/source/tutorials/raster_api_tut.rst index e6958c535a84..24e4c62245be 100644 --- a/doc/source/tutorials/raster_api_tut.rst +++ b/doc/source/tutorials/raster_api_tut.rst @@ -279,7 +279,7 @@ The RasterIO call takes the following arguments. Note that the same RasterIO() call is used to read, or write based on the setting of eRWFlag (either GF_Read or GF_Write). The nXOff, nYOff, nXSize, nYSize argument describe the window of raster data on disk to read (or write). It doesn't have to fall on tile boundaries though access may be more efficient if it does. -The pData is the memory buffer the data is read into, or written from. It's real type must be whatever is passed as eBufType, such as GDT_Float32, or GDT_Byte. The RasterIO() call will take care of converting between the buffer's data type and the data type of the band. Note that when converting floating point data to integer RasterIO() rounds down, and when converting source values outside the legal range of the output the nearest legal value is used. This implies, for instance, that 16bit data read into a GDT_Byte buffer will map all values greater than 255 to 255, the data is not scaled! +The pData is the memory buffer the data is read into, or written from. It's real type must be whatever is passed as eBufType, such as GDT_Float32, or GDT_UInt8. The RasterIO() call will take care of converting between the buffer's data type and the data type of the band. Note that when converting floating point data to integer RasterIO() rounds down, and when converting source values outside the legal range of the output the nearest legal value is used. This implies, for instance, that 16bit data read into a GDT_UInt8 buffer will map all values greater than 255 to 255, the data is not scaled! The nBufXSize and nBufYSize values describe the size of the buffer. When loading data at full resolution this would be the same as the window size. However, to load a reduced resolution overview this could be set to smaller than the window on disk. In this case the RasterIO() will utilize overviews to do the IO more efficiently if the overviews are suitable. @@ -435,20 +435,20 @@ For situations in which you are not just exporting an existing file to a new fil GDALDataset *poDstDS; char **papszOptions = NULL; - poDstDS = poDriver->Create( pszDstFilename, 512, 512, 1, GDT_Byte, + poDstDS = poDriver->Create( pszDstFilename, 512, 512, 1, GDT_UInt8, papszOptions ); .. code-tab:: c GDALDatasetH hDstDS; char **papszOptions = NULL; - hDstDS = GDALCreate( hDriver, pszDstFilename, 512, 512, 1, GDT_Byte, + hDstDS = GDALCreate( hDriver, pszDstFilename, 512, 512, 1, GDT_UInt8, papszOptions ); .. code-tab:: python dst_ds = driver.Create(dst_filename, xsize=512, ysize=512, - bands=1, eType=gdal.GDT_Byte) + bands=1, eType=gdal.GDT_UInt8) Once the dataset is successfully created, all appropriate metadata and raster data must be written to the file. What this is will vary according to usage, but a simple case with a projection, geotransform and raster data is covered here. @@ -469,7 +469,7 @@ Once the dataset is successfully created, all appropriate metadata and raster da CPLFree( pszSRS_WKT ); poBand = poDstDS->GetRasterBand(1); poBand->RasterIO( GF_Write, 0, 0, 512, 512, - abyRaster, 512, 512, GDT_Byte, 0, 0 ); + abyRaster, 512, 512, GDT_UInt8, 0, 0 ); /* Once we're done, close properly the dataset */ GDALClose( (GDALDatasetH) poDstDS ); @@ -490,7 +490,7 @@ Once the dataset is successfully created, all appropriate metadata and raster da CPLFree( pszSRS_WKT ); hBand = GDALGetRasterBand( hDstDS, 1 ); GDALRasterIO( hBand, GF_Write, 0, 0, 512, 512, - abyRaster, 512, 512, GDT_Byte, 0, 0 ); + abyRaster, 512, 512, GDT_UInt8, 0, 0 ); /* Once we're done, close properly the dataset */ GDALClose( hDstDS ); diff --git a/doc/source/tutorials/raster_driver_tut.rst b/doc/source/tutorials/raster_driver_tut.rst index 48ea5ff6e0dd..88ad7bb5af0a 100644 --- a/doc/source/tutorials/raster_driver_tut.rst +++ b/doc/source/tutorials/raster_driver_tut.rst @@ -301,7 +301,7 @@ The following data members are inherited from GDALRasterBand, and should general nBlockXSize: The width of one block in this band. nBlockYSize: The height of one block in this band. -The full set of possible GDALDataType values are declared in gdal.h, and include GDT_Byte, GDT_UInt16, GDT_Int16, and GDT_Float32. The block size is used to establish a natural or efficient block size to access the data with. For tiled datasets this will be the size of a tile, while for most other datasets it will be one scanline, as in this case. +The full set of possible GDALDataType values are declared in gdal.h, and include GDT_UInt8, GDT_UInt16, GDT_Int16, and GDT_Float32. The block size is used to establish a natural or efficient block size to access the data with. For tiled datasets this will be the size of a tile, while for most other datasets it will be one scanline, as in this case. Next we see the implementation of the code that actually reads the image data, IReadBlock(). @@ -554,7 +554,7 @@ static GDALDataset * return NULL; } - if( poSrcDS->GetRasterBand(1)->GetRasterDataType() != GDT_Byte && bStrict ) + if( poSrcDS->GetRasterBand(1)->GetRasterDataType() != GDT_UInt8 && bStrict ) { CPLError(CE_Failure, CPLE_NotSupported, "JPEG driver doesn't support data type %s. " @@ -626,7 +626,7 @@ static GDALDataset * GDALRasterBand * poBand = poSrcDS->GetRasterBand(iBand + 1); const CPLErr eErr = poBand->RasterIO(GF_Read, 0, iLine, nXSize, 1, - pabyScanline + iBand, nXSize, 1, GDT_Byte, + pabyScanline + iBand, nXSize, 1, GDT_UInt8, nBands, nBands * nXSize); // TODO: Handle error. } @@ -655,7 +655,7 @@ The following sample implement PCI .aux labeled raw raster creation. It follows char ** /* papszParamList */ ) { // Verify input options. - if( eType != GDT_Byte && eType != GDT_Float32 && + if( eType != GDT_UInt8 && eType != GDT_Float32 && eType != GDT_UInt16 && eType != GDT_Int16 ) { CPLError( @@ -767,19 +767,19 @@ The Open() method for the dataset then instantiates raster bands passing all the { poDS->SetBand( 1, new RawRasterBand(poDS, 1, poDS->fpImage, - iIn, 1, nWidth, GDT_Byte, TRUE)); + iIn, 1, nWidth, GDT_UInt8, TRUE)); } else { poDS->SetBand( 1, new RawRasterBand(poDS, 1, poDS->fpImage, - iIn, 3, nWidth*3, GDT_Byte, TRUE)); + iIn, 3, nWidth*3, GDT_UInt8, TRUE)); poDS->SetBand( 2, new RawRasterBand(poDS, 2, poDS->fpImage, - iIn+1, 3, nWidth*3, GDT_Byte, TRUE)); + iIn+1, 3, nWidth*3, GDT_UInt8, TRUE)); poDS->SetBand( 3, new RawRasterBand(poDS, 3, poDS->fpImage, - iIn+2, 3, nWidth*3, GDT_Byte, TRUE)); + iIn+2, 3, nWidth*3, GDT_UInt8, TRUE)); } The RawRasterBand takes the following arguments. @@ -802,7 +802,7 @@ There are various other items in the GDAL data model, for which virtual methods - Metadata: Name/value text values about a dataset or band. The GDALMajorObject (base class for GDALRasterBand and GDALDataset) has built-in support for holding metadata, so for read access it only needs to be set with calls to SetMetadataItem() during the Open(). The SAR_CEOS (frmts/ceos2/sar_ceosdataset.cpp) and GeoTIFF drivers are examples of drivers implementing readable metadata. -- ColorTables: GDT_Byte raster bands can have color tables associated with them. The frmts/png/pngdataset.cpp driver contains an example of a format that supports colortables. +- ColorTables: GDT_UInt8 raster bands can have color tables associated with them. The frmts/png/pngdataset.cpp driver contains an example of a format that supports colortables. - ColorInterpretation: The PNG driver contains an example of a driver that returns an indication of whether a band should be treated as a Red, Green, Blue, Alpha or Greyscale band. diff --git a/doc/source/user/band_algebra.rst b/doc/source/user/band_algebra.rst index 72f805f24c80..317546e412c4 100644 --- a/doc/source/user/band_algebra.rst +++ b/doc/source/user/band_algebra.rst @@ -98,7 +98,7 @@ Examples auto& R = *(poDS->GetRasterBand(1)); auto& G = *(poDS->GetRasterBand(2)); auto& B = *(poDS->GetRasterBand(3)); - auto graylevel = (0.299 * R + 0.587 * G + 0.114 * B).AsType(GDT_Byte); + auto graylevel = (0.299 * R + 0.587 * G + 0.114 * B).AsType(GDT_UInt8); auto poGTiffDrv = GetGDALDriverManager()->GetDriverByName("GTiff"); std::unique_ptr( @@ -116,7 +116,7 @@ Examples R = ds.GetRasterBand(1) G = ds.GetRasterBand(2) B = ds.GetRasterBand(3) - graylevel = (0.299 * R + 0.587 * G + 0.114 * B).astype(gdal.GDT_Byte) + graylevel = (0.299 * R + 0.587 * G + 0.114 * B).astype(gdal.GDT_UInt8) gdal.GetDriverByName("GTiff").CreateCopy("graylevel.tif", graylevel) diff --git a/doc/source/user/multidim_raster_data_model.rst b/doc/source/user/multidim_raster_data_model.rst index 96521098cfb7..ddb5407c5a72 100644 --- a/doc/source/user/multidim_raster_data_model.rst +++ b/doc/source/user/multidim_raster_data_model.rst @@ -190,7 +190,7 @@ guaranteed to be serialized when all objects related to a dataset have been rele auto poDim = poRootGroup->CreateDimension( "my_dim", std::string(), std::string(), 10); auto poArray = poRootGroup->CreateMDArray( - "my_var", {poDim}, GDALExtendedDataType::Create(GDT_Byte), nullptr); + "my_var", {poDim}, GDALExtendedDataType::Create(GDT_UInt8), nullptr); // Can be closed in any order poArray.reset(); @@ -209,7 +209,7 @@ guaranteed to be serialized when all objects related to a dataset have been rele with gdal.GetDriverByName("netCDF").CreateMultiDimensional("new.nc") as ds: rg = ds.GetRootGroup() dim = rg.CreateDimension("my_dim", "", "", 10) - array = rg.CreateMDArray("my_var", [dim], gdal.ExtendedDataType.Create(gdal.GDT_Byte)) + array = rg.CreateMDArray("my_var", [dim], gdal.ExtendedDataType.Create(gdal.GDT_UInt8)) del array del dim diff --git a/doc/source/user/raster_data_model.rst b/doc/source/user/raster_data_model.rst index 3a087bed6b18..f3eafa4970cf 100644 --- a/doc/source/user/raster_data_model.rst +++ b/doc/source/user/raster_data_model.rst @@ -148,9 +148,9 @@ Metadata in the default domain is intended to be related to the image, and not p Currently the following items are defined by :ref:`rfc-14` as having specific semantics in the IMAGE_STRUCTURE domain. - COMPRESSION: The compression type used for this dataset or band. There is no fixed catalog of compression type names, but where a given format includes a COMPRESSION creation option, the same list of values should be used here as there. -- NBITS: The actual number of bits used for this band, or the bands of this dataset. Normally only present when the number of bits is non-standard for the datatype, such as when a 1 bit TIFF is represented through GDAL as GDT_Byte. +- NBITS: The actual number of bits used for this band, or the bands of this dataset. Normally only present when the number of bits is non-standard for the datatype, such as when a 1 bit TIFF is represented through GDAL as GDT_UInt8. - INTERLEAVE: This only applies on datasets, and the value should be one of PIXEL, LINE or BAND. It can be used as a data access hint. -- PIXELTYPE: This may appear on a GDT_Byte band (or the corresponding dataset) +- PIXELTYPE: This may appear on a GDT_UInt8 band (or the corresponding dataset) and have the value SIGNEDBYTE to indicate the unsigned byte values between 128 and 255 should be interpreted as being values between -128 and -1 for applications that recognise the SIGNEDBYTE type. @@ -219,7 +219,7 @@ A raster band is represented in GDAL with the :cpp:class:`GDALRasterBand` class. A raster band has the following properties: - A width and height in pixels and lines. This is the same as that defined for the dataset, if this is a full resolution band. -- A datatype (GDALDataType). One of Byte, Int8, UInt16, Int16, UInt32, Int32, UInt64, Int64, Float16, Float32, Float64, and the complex types CInt16, CInt32, CFloat16, CFloat32, and CFloat64. +- A datatype (GDALDataType). One of UInt8 (since 3.13, also available as Byte in all versions), Int8, UInt16, Int16, UInt32, Int32, UInt64, Int64, Float16, Float32, Float64, and the complex types CInt16, CInt32, CFloat16, CFloat32, and CFloat64. UInt64 and Int64 data types have been added in GDAL 3.5. Beyond reading and write pixel values, their support is limited. Some algorithms might use 64-bit floating-point internally (warping), as well as some methods returning only double values (GetMinimum(), GetMaximum(), etc.), or even 32-bit floating point (overview, RasterIO resampling). Hence the range where exact values are preserved can be [0, 2^53] (or less if 32-bit floating-point is used). diff --git a/frmts/aaigrid/aaigriddataset.cpp b/frmts/aaigrid/aaigriddataset.cpp index 7be5ccd9026c..f86c88fdb701 100644 --- a/frmts/aaigrid/aaigriddataset.cpp +++ b/frmts/aaigrid/aaigriddataset.cpp @@ -1402,7 +1402,7 @@ GDALDataset *AAIGDataset::CreateCopy(const char *pszFilename, // Handle nodata (optionally). GDALRasterBand *poBand = poSrcDS->GetRasterBand(1); - const bool bReadAsInt = poBand->GetRasterDataType() == GDT_Byte || + const bool bReadAsInt = poBand->GetRasterDataType() == GDT_UInt8 || poBand->GetRasterDataType() == GDT_Int16 || poBand->GetRasterDataType() == GDT_UInt16 || poBand->GetRasterDataType() == GDT_Int32; diff --git a/frmts/adrg/adrgdataset.cpp b/frmts/adrg/adrgdataset.cpp index 3a0de098feee..839d8df52c68 100644 --- a/frmts/adrg/adrgdataset.cpp +++ b/frmts/adrg/adrgdataset.cpp @@ -110,7 +110,7 @@ ADRGRasterBand::ADRGRasterBand(ADRGDataset *poDSIn, int nBandIn) poDS = poDSIn; nBand = nBandIn; - eDataType = GDT_Byte; + eDataType = GDT_UInt8; nBlockXSize = 128; nBlockYSize = 128; diff --git a/frmts/adrg/srpdataset.cpp b/frmts/adrg/srpdataset.cpp index 69b3059ae013..91af3c3ad167 100644 --- a/frmts/adrg/srpdataset.cpp +++ b/frmts/adrg/srpdataset.cpp @@ -118,7 +118,7 @@ SRPRasterBand::SRPRasterBand(SRPDataset *poDSIn, int nBandIn) poDS = poDSIn; nBand = nBandIn; - eDataType = GDT_Byte; + eDataType = GDT_UInt8; nBlockXSize = 128; nBlockYSize = 128; diff --git a/frmts/aigrid/aigdataset.cpp b/frmts/aigrid/aigdataset.cpp index 888013b05900..84465440e219 100644 --- a/frmts/aigrid/aigdataset.cpp +++ b/frmts/aigrid/aigdataset.cpp @@ -105,7 +105,7 @@ AIGRasterBand::AIGRasterBand(AIGDataset *poDSIn, int nBandIn) if (poDSIn->psInfo->nCellType == AIG_CELLTYPE_INT && poDSIn->psInfo->dfMin >= 0.0 && poDSIn->psInfo->dfMax <= 254.0) { - eDataType = GDT_Byte; + eDataType = GDT_UInt8; } else if (poDSIn->psInfo->nCellType == AIG_CELLTYPE_INT && poDSIn->psInfo->dfMin >= -32767 && poDSIn->psInfo->dfMax <= 32767) @@ -143,7 +143,7 @@ CPLErr AIGRasterBand::IReadBlock(int nBlockXOff, int nBlockYOff, void *pImage) return CE_Failure; } - if (eDataType == GDT_Byte) + if (eDataType == GDT_UInt8) { for (int i = 0; i < nBlockXSize * nBlockYSize; i++) { @@ -250,7 +250,7 @@ double AIGRasterBand::GetNoDataValue(int *pbSuccess) if (eDataType == GDT_Int16) return -32768; - if (eDataType == GDT_Byte) + if (eDataType == GDT_UInt8) return 255; return ESRI_GRID_NO_DATA; diff --git a/frmts/avif/avifdataset.cpp b/frmts/avif/avifdataset.cpp index 5a731f7bf10f..99c9b5751a9c 100644 --- a/frmts/avif/avifdataset.cpp +++ b/frmts/avif/avifdataset.cpp @@ -532,7 +532,7 @@ bool GDALAVIFDataset::Init(GDALOpenInfo *poOpenInfo) } const auto eDataType = - (m_decoder->image->depth <= 8) ? GDT_Byte : GDT_UInt16; + (m_decoder->image->depth <= 8) ? GDT_UInt8 : GDT_UInt16; const int l_nBands = m_decoder->image->yuvFormat == AVIF_PIXEL_FORMAT_YUV400 ? (m_decoder->alphaPresent ? 2 : 1) : m_decoder->alphaPresent ? 4 @@ -743,7 +743,7 @@ GDALDataset *GDALAVIFDataset::CreateCopy(const char *pszFilename, } const auto eDT = poFirstBand->GetRasterDataType(); - if (eDT != GDT_Byte && eDT != GDT_UInt16) + if (eDT != GDT_UInt8 && eDT != GDT_UInt16) { CPLError( CE_Failure, CPLE_NotSupported, @@ -751,7 +751,7 @@ GDALDataset *GDALAVIFDataset::CreateCopy(const char *pszFilename, return nullptr; } - int nBits = eDT == GDT_Byte ? 8 : 12; + int nBits = eDT == GDT_UInt8 ? 8 : 12; const char *pszNBITS = CSLFetchNameValue(papszOptions, "NBITS"); if (pszNBITS) { @@ -765,7 +765,7 @@ GDALDataset *GDALAVIFDataset::CreateCopy(const char *pszFilename, nBits = atoi(pszNBITS); } } - if ((eDT == GDT_Byte && nBits != 8) || + if ((eDT == GDT_UInt8 && nBits != 8) || (eDT == GDT_UInt16 && nBits != 10 && nBits != 12)) { CPLError(CE_Failure, CPLE_FileIO, diff --git a/frmts/basisu_ktx2/basisudataset.cpp b/frmts/basisu_ktx2/basisudataset.cpp index dd3ff11c76c5..59486b0f8745 100644 --- a/frmts/basisu_ktx2/basisudataset.cpp +++ b/frmts/basisu_ktx2/basisudataset.cpp @@ -177,7 +177,7 @@ BASISURasterBand::BASISURasterBand(BASISUDataset *poDSIn, int nBandIn) nRasterYSize = poDSIn->GetRasterYSize(); nBlockXSize = nRasterXSize; nBlockYSize = 1; - eDataType = GDT_Byte; + eDataType = GDT_UInt8; SetColorInterpretation( static_cast(GCI_RedBand + nBandIn - 1)); } @@ -197,7 +197,7 @@ CPLErr BASISURasterBand::IReadBlock(int /*nBlockXOff*/, int nBlockYOff, GDALCopyWords(static_cast(decoded_data) + nBlockYOff * nLineStride + nBand - 1, - GDT_Byte, 4, pImage, GDT_Byte, 1, nBlockXSize); + GDT_UInt8, 4, pImage, GDT_UInt8, 1, nBlockXSize); return CE_None; } diff --git a/frmts/basisu_ktx2/common.cpp b/frmts/basisu_ktx2/common.cpp index 2fa791205541..5007cc35b4a0 100644 --- a/frmts/basisu_ktx2/common.cpp +++ b/frmts/basisu_ktx2/common.cpp @@ -67,7 +67,7 @@ bool GDAL_KTX2_BASISU_CreateCopy(const char *pszFilename, GDALDataset *poSrcDS, "Only band count >= 1 and <= 4 is supported"); return false; } - if (poSrcDS->GetRasterBand(1)->GetRasterDataType() != GDT_Byte) + if (poSrcDS->GetRasterBand(1)->GetRasterDataType() != GDT_UInt8) { CPLError(CE_Failure, CPLE_NotSupported, "Only Byte data type supported"); @@ -81,7 +81,7 @@ bool GDAL_KTX2_BASISU_CreateCopy(const char *pszFilename, GDALDataset *poSrcDS, return false; if (poSrcDS->RasterIO(GF_Read, 0, 0, nXSize, nYSize, pSrcData, nXSize, - nYSize, GDT_Byte, nBands, nullptr, nBands, + nYSize, GDT_UInt8, nBands, nullptr, nBands, static_cast(nBands) * nXSize, 1, nullptr) != CE_None) { diff --git a/frmts/basisu_ktx2/ktx2dataset.cpp b/frmts/basisu_ktx2/ktx2dataset.cpp index ac55daa79814..5dd402449c64 100644 --- a/frmts/basisu_ktx2/ktx2dataset.cpp +++ b/frmts/basisu_ktx2/ktx2dataset.cpp @@ -174,7 +174,7 @@ KTX2RasterBand::KTX2RasterBand(KTX2Dataset *poDSIn, int nBandIn) nRasterYSize = poDSIn->GetRasterYSize(); nBlockXSize = nRasterXSize; nBlockYSize = 1; - eDataType = GDT_Byte; + eDataType = GDT_UInt8; SetColorInterpretation( static_cast(GCI_RedBand + nBandIn - 1)); } @@ -194,7 +194,7 @@ CPLErr KTX2RasterBand::IReadBlock(int /*nBlockXOff*/, int nBlockYOff, GDALCopyWords(static_cast(decoded_data) + nBlockYOff * nLineStride + nBand - 1, - GDT_Byte, 4, pImage, GDT_Byte, 1, nBlockXSize); + GDT_UInt8, 4, pImage, GDT_UInt8, 1, nBlockXSize); return CE_None; } diff --git a/frmts/bmp/bmpdataset.cpp b/frmts/bmp/bmpdataset.cpp index 6dec1de74eed..d597e2c3a5b7 100644 --- a/frmts/bmp/bmpdataset.cpp +++ b/frmts/bmp/bmpdataset.cpp @@ -289,7 +289,7 @@ BMPRasterBand::BMPRasterBand(BMPDataset *poDSIn, int nBandIn) { poDS = poDSIn; nBand = nBandIn; - eDataType = GDT_Byte; + eDataType = GDT_UInt8; // We will read one scanline per time. Scanlines in BMP aligned at 4-byte // boundary @@ -1413,7 +1413,7 @@ GDALDataset *BMPDataset::Create(const char *pszFilename, int nXSize, int nYSize, char **papszOptions) { - if (eType != GDT_Byte) + if (eType != GDT_UInt8) { CPLError(CE_Failure, CPLE_AppDefined, "Attempt to create BMP dataset with an illegal\n" diff --git a/frmts/bsb/bsbdataset.cpp b/frmts/bsb/bsbdataset.cpp index 6ebbbd6f265e..6d7e72c78de5 100644 --- a/frmts/bsb/bsbdataset.cpp +++ b/frmts/bsb/bsbdataset.cpp @@ -98,7 +98,7 @@ BSBRasterBand::BSBRasterBand(BSBDataset *poDSIn) poDS = poDSIn; nBand = 1; - eDataType = GDT_Byte; + eDataType = GDT_UInt8; nBlockXSize = poDS->GetRasterXSize(); nBlockYSize = 1; @@ -947,7 +947,7 @@ static GDALDataset *BSBCreateCopy(const char *pszFilename, GDALDataset *poSrcDS, return NULL; } - if (poSrcDS->GetRasterBand(1)->GetRasterDataType() != GDT_Byte && bStrict) + if (poSrcDS->GetRasterBand(1)->GetRasterDataType() != GDT_UInt8 && bStrict) { CPLError(CE_Failure, CPLE_NotSupported, "BSB driver doesn't support data type %s. " @@ -1163,7 +1163,7 @@ static GDALDataset *BSBCreateCopy(const char *pszFilename, GDALDataset *poSrcDS, { eErr = poBand->RasterIO(GF_Read, 0, iLine, nXSize, 1, pabyScanline, nXSize, - 1, GDT_Byte, nBands, nBands * nXSize, NULL); + 1, GDT_UInt8, nBands, nBands * nXSize, NULL); if (eErr == CE_None) { for (int i = 0; i < nXSize; i++) diff --git a/frmts/cals/calsdataset.cpp b/frmts/cals/calsdataset.cpp index 86700bb17781..1b353c669481 100644 --- a/frmts/cals/calsdataset.cpp +++ b/frmts/cals/calsdataset.cpp @@ -68,7 +68,7 @@ class CALSRasterBand final : public GDALPamRasterBand poUnderlyingBand = poDSIn->poUnderlyingDS->GetRasterBand(1); poUnderlyingBand->GetBlockSize(&nBlockXSize, &nBlockYSize); nBand = 1; - eDataType = GDT_Byte; + eDataType = GDT_UInt8; } CPLErr IReadBlock(int nBlockXOff, int nBlockYOff, void *pData) override; @@ -133,7 +133,7 @@ class CALSWrapperSrcBand final : public GDALPamRasterBand poSrcDS = poSrcDSIn; SetMetadataItem("NBITS", "1", "IMAGE_STRUCTURE"); poSrcDS->GetRasterBand(1)->GetBlockSize(&nBlockXSize, &nBlockYSize); - eDataType = GDT_Byte; + eDataType = GDT_UInt8; bInvertValues = true; GDALColorTable *poCT = poSrcDS->GetRasterBand(1)->GetColorTable(); if (poCT != nullptr && poCT->GetColorEntryCount() >= 2) @@ -480,7 +480,7 @@ GDALDataset *CALSDataset::CreateCopy(const char *pszFilename, papszOptions = CSLSetNameValue(papszOptions, "SPARSE_OK", "YES"); GDALDataset *poDS = poGTiffDrv->Create( osTmpFilename, poSrcDS->GetRasterXSize(), poSrcDS->GetRasterYSize(), 1, - GDT_Byte, papszOptions); + GDT_UInt8, papszOptions); if (poDS == nullptr) { // Should not happen normally (except if CCITTFAX4 not available). diff --git a/frmts/ceos/ceosdataset.cpp b/frmts/ceos/ceosdataset.cpp index d31ddbc9440c..7ed92f442e3c 100644 --- a/frmts/ceos/ceosdataset.cpp +++ b/frmts/ceos/ceosdataset.cpp @@ -67,7 +67,7 @@ CEOSRasterBand::CEOSRasterBand(CEOSDataset *poDSIn, int nBandIn) poDS = poDSIn; nBand = nBandIn; - eDataType = GDT_Byte; + eDataType = GDT_UInt8; nBlockXSize = poDS->GetRasterXSize(); nBlockYSize = 1; diff --git a/frmts/ceos2/sar_ceosdataset.cpp b/frmts/ceos2/sar_ceosdataset.cpp index b971ed569b27..b794f8ed03e1 100644 --- a/frmts/ceos2/sar_ceosdataset.cpp +++ b/frmts/ceos2/sar_ceosdataset.cpp @@ -1962,7 +1962,7 @@ GDALDataset *SAR_CEOSDataset::Open(GDALOpenInfo *poOpenInfo) { case CEOS_TYP_CHAR: case CEOS_TYP_UCHAR: - eType = GDT_Byte; + eType = GDT_UInt8; break; case CEOS_TYP_SHORT: diff --git a/frmts/daas/daasdataset.cpp b/frmts/daas/daasdataset.cpp index c5ba48ba8d38..327f623b439e 100644 --- a/frmts/daas/daasdataset.cpp +++ b/frmts/daas/daasdataset.cpp @@ -688,7 +688,7 @@ GetGDALDataTypeFromDAASPixelType(const CPLString &osPixelType) const char *pszName; GDALDataType eDT; } asDataTypes[] = { - {"Byte", GDT_Byte}, {"UInt16", GDT_UInt16}, + {"Byte", GDT_UInt8}, {"UInt16", GDT_UInt16}, {"Int16", GDT_Int16}, {"UInt32", GDT_UInt32}, {"Int32", GDT_Int32}, {"Float32", GDT_Float32}, {"Float64", GDT_Float64}, @@ -1229,7 +1229,7 @@ bool GDALDAASDataset::Open(GDALOpenInfo *poOpenInfo) { if ((m_aoBandDesc.size() == 1 || m_aoBandDesc.size() == 3 || m_aoBandDesc.size() == 4) && - m_eDT == GDT_Byte) + m_eDT == GDT_UInt8) { m_eFormat = Format::PNG; } @@ -1246,7 +1246,7 @@ bool GDALDAASDataset::Open(GDALOpenInfo *poOpenInfo) { if ((m_aoBandDesc.size() == 1 || m_aoBandDesc.size() == 3 || m_aoBandDesc.size() == 4) && - m_eDT == GDT_Byte) + m_eDT == GDT_UInt8) { m_eFormat = Format::PNG; } @@ -1261,7 +1261,7 @@ bool GDALDAASDataset::Open(GDALOpenInfo *poOpenInfo) else if (EQUAL(pszFormat, "JPEG")) { if ((m_aoBandDesc.size() == 1 || m_aoBandDesc.size() == 3) && - m_eDT == GDT_Byte) + m_eDT == GDT_UInt8) { m_eFormat = Format::JPEG; } @@ -2344,7 +2344,7 @@ CPLErr GDALDAASRasterBand::GetBlocks(int nBlockXOff, int nBlockYOff, // Get the actual data type of the buffer response GDALDataType eBufferDataType = anRequestedBands[0] == MAIN_MASK_BAND_NUMBER - ? GDT_Byte + ? GDT_UInt8 : poGDS->m_aoBandDesc[anRequestedBands[0] - 1].eDT; auto oBandArray = oDocRoot.GetArray("properties/bands"); if (oBandArray.IsValid() && oBandArray.Size() >= 1) diff --git a/frmts/dds/ddsdataset.cpp b/frmts/dds/ddsdataset.cpp index e668f8708a93..09c5c9979193 100644 --- a/frmts/dds/ddsdataset.cpp +++ b/frmts/dds/ddsdataset.cpp @@ -140,7 +140,7 @@ DDSRasterBand::DDSRasterBand(DDSDataset *poDSIn, int nBandIn) nBand = nBandIn; nBlockXSize = poDSIn->GetRasterXSize(); nBlockYSize = cDXTBlockSize; - eDataType = GDT_Byte; + eDataType = GDT_UInt8; } /************************************************************************/ @@ -366,7 +366,7 @@ DDSRasterBandAllDecoded::DDSRasterBandAllDecoded(DDSDatasetAllDecoded *poDSIn, nBand = nBandIn; nBlockXSize = poDSIn->GetRasterXSize(); nBlockYSize = 1; - eDataType = GDT_Byte; + eDataType = GDT_UInt8; } /************************************************************************/ @@ -470,7 +470,7 @@ GDALDataset *DDSDataset::CreateCopy(const char *pszFilename, return nullptr; } - if (poSrcDS->GetRasterBand(1)->GetRasterDataType() != GDT_Byte) + if (poSrcDS->GetRasterBand(1)->GetRasterDataType() != GDT_UInt8) { CPLError( (bStrict) ? CE_Failure : CE_Warning, CPLE_NotSupported, @@ -644,7 +644,7 @@ GDALDataset *DDSDataset::CreateCopy(const char *pszFilename, eErr = poSrcDS->RasterIO(GF_Read, 0, iLine * cDXTBlockSize, nXSize, size_y, - pabyScanlines, nXSize, size_y, GDT_Byte, nBands, + pabyScanlines, nXSize, size_y, GDT_UInt8, nBands, nullptr, nBands, nBands * nXSize, 1, nullptr); if (eErr != CE_None) diff --git a/frmts/ecw/ecwcreatecopy.cpp b/frmts/ecw/ecwcreatecopy.cpp index e78d79f5030b..cdc7d71d8583 100644 --- a/frmts/ecw/ecwcreatecopy.cpp +++ b/frmts/ecw/ecwcreatecopy.cpp @@ -510,7 +510,7 @@ CPLErr GDALECWCompressor::Initialize( switch (eWorkDT) { - case GDT_Byte: + case GDT_UInt8: #if ECWSDK_VERSION >= 50 psClient->nCellBitDepth = 8; #endif @@ -1131,7 +1131,7 @@ static GDALDataset *ECWCreateCopy(const char *pszFilename, GDALDataset *poSrcDS, } } #endif - if (!(eType == GDT_Byte || + if (!(eType == GDT_UInt8 || #if ECWSDK_VERSION >= 50 (bECWV3 && eType == GDT_UInt16) || #endif @@ -1171,7 +1171,7 @@ static GDALDataset *ECWCreateCopy(const char *pszFilename, GDALDataset *poSrcDS, "for %s. \n", GDALGetDataTypeName(eType)); - eType = GDT_Byte; + eType = GDT_UInt8; } } @@ -1322,7 +1322,7 @@ GDALDataset *ECWCreateCopyECW(const char *pszFilename, GDALDataset *poSrcDS, #endif GDALDataType eDataType = poSrcDS->GetRasterBand(1)->GetRasterDataType(); - if (eDataType != GDT_Byte + if (eDataType != GDT_UInt8 #if ECWSDK_VERSION >= 50 && !(bECWV3 && (eDataType == GDT_UInt16)) #endif @@ -1406,7 +1406,7 @@ GDALDataset *ECWCreateCopyJPEG2000(const char *pszFilename, } GDALDataType eDataType = poSrcDS->GetRasterBand(1)->GetRasterDataType(); - if (eDataType != GDT_Byte && eDataType != GDT_Int16 && + if (eDataType != GDT_UInt8 && eDataType != GDT_Int16 && eDataType != GDT_UInt16 && eDataType != GDT_Int32 && eDataType != GDT_UInt32 && eDataType != GDT_Float32 #if ECWSDK_VERSION >= 40 diff --git a/frmts/ecw/ecwdataset.cpp b/frmts/ecw/ecwdataset.cpp index 24616979845d..38f76a1050ba 100644 --- a/frmts/ecw/ecwdataset.cpp +++ b/frmts/ecw/ecwdataset.cpp @@ -875,7 +875,7 @@ CPLErr ECWRasterBand::OldIRasterIO(GDALRWFlag eRWFlag, int nXOff, int nYOff, /* -------------------------------------------------------------------- */ const int nRawPixelSize = GDALGetDataTypeSizeBytes(poGDS->eRasterDataType); - int bDirect = nPixelSpace == 1 && eBufType == GDT_Byte && + int bDirect = nPixelSpace == 1 && eBufType == GDT_UInt8 && nNewXSize == nBufXSize && nNewYSize == nBufYSize; if (!bDirect) pabyWorkBuffer = @@ -1093,7 +1093,7 @@ ECWDataset::ECWDataset(int bIsJPEG2000In) poFileView = nullptr; bWinActive = FALSE; panWinBandList = nullptr; - eRasterDataType = GDT_Byte; + eRasterDataType = GDT_UInt8; papszGMLMetadata = nullptr; bHdrDirty = FALSE; @@ -2829,7 +2829,7 @@ GDALDataset *ECWDataset::Open(GDALOpenInfo *poOpenInfo, int bIsJPEG2000) switch (poDS->psFileInfo->eCellType) { case NCSCT_UINT8: - poDS->eRasterDataType = GDT_Byte; + poDS->eRasterDataType = GDT_UInt8; break; case NCSCT_UINT16: diff --git a/frmts/eeda/eedacommon.cpp b/frmts/eeda/eedacommon.cpp index fb29b730b4c9..44a8841cf86f 100644 --- a/frmts/eeda/eedacommon.cpp +++ b/frmts/eeda/eedacommon.cpp @@ -50,7 +50,7 @@ BuildBandDescArray(json_object *poBands, const char *pszPrecision = json_object_get_string(poPrecision); if (pszPrecision == nullptr) continue; - GDALDataType eDT = GDT_Byte; + GDALDataType eDT = GDT_UInt8; if (EQUAL(pszPrecision, "INT")) { json_object *poRange = diff --git a/frmts/eeda/eedaidataset.cpp b/frmts/eeda/eedaidataset.cpp index 9fce4b63a3c0..4e84025a9cbf 100644 --- a/frmts/eeda/eedaidataset.cpp +++ b/frmts/eeda/eedaidataset.cpp @@ -1062,7 +1062,7 @@ bool GDALEEDAIDataset::ComputeQueryStrategy() m_osPixelEncoding = "PNG"; for (int i = 1; i <= nBands; i++) { - if (GetRasterBand(i)->GetRasterDataType() != GDT_Byte) + if (GetRasterBand(i)->GetRasterDataType() != GDT_UInt8) { m_osPixelEncoding = "GEO_TIFF"; } @@ -1079,7 +1079,7 @@ bool GDALEEDAIDataset::ComputeQueryStrategy() } for (int i = 1; i <= nBands; i++) { - if (GetRasterBand(i)->GetRasterDataType() != GDT_Byte) + if (GetRasterBand(i)->GetRasterDataType() != GDT_UInt8) { CPLError( CE_Failure, CPLE_NotSupported, diff --git a/frmts/envisat/envisatdataset.cpp b/frmts/envisat/envisatdataset.cpp index 35d235290d0d..38dab157d42f 100644 --- a/frmts/envisat/envisatdataset.cpp +++ b/frmts/envisat/envisatdataset.cpp @@ -956,7 +956,7 @@ GDALDataset *EnvisatDataset::Open(GDALOpenInfo *poOpenInfo) CPLError(CE_Warning, CPLE_AppDefined, "Envisat product format not recognised. Assuming 8bit\n" "with no per-record prefix data. Results may be useless!"); - eDataType = GDT_Byte; + eDataType = GDT_UInt8; poDS->nRasterXSize = dsr_size; } else @@ -964,7 +964,7 @@ GDALDataset *EnvisatDataset::Open(GDALOpenInfo *poOpenInfo) if (dsr_size >= 2 * poDS->nRasterXSize) eDataType = GDT_UInt16; else - eDataType = GDT_Byte; + eDataType = GDT_UInt8; } const int nPrefixBytes = @@ -1040,7 +1040,7 @@ GDALDataset *EnvisatDataset::Open(GDALOpenInfo *poOpenInfo) { auto poBand = RawRasterBand::Create( poDS.get(), iBand + 1, poDS->fpImage, - ds_offset + nPrefixBytes, 3, dsr_size, GDT_Byte, + ds_offset + nPrefixBytes, 3, dsr_size, GDT_UInt8, RawRasterBand::ByteOrder::ORDER_BIG_ENDIAN, RawRasterBand::OwnFP::NO); if (!poBand) @@ -1089,7 +1089,7 @@ GDALDataset *EnvisatDataset::Open(GDALOpenInfo *poOpenInfo) int nPrefixBytes2, nSubBands, nSubBandIdx, nSubBandOffset; int nPixelSize = 1; - GDALDataType eDataType2 = GDT_Byte; + GDALDataType eDataType2 = GDT_UInt8; nSubBands = dsr_size2 / poDS->nRasterXSize; if ((nSubBands < 1) || (nSubBands > 3)) diff --git a/frmts/ers/ersdataset.cpp b/frmts/ers/ersdataset.cpp index a7657015b096..5d96df9a435c 100644 --- a/frmts/ers/ersdataset.cpp +++ b/frmts/ers/ersdataset.cpp @@ -950,7 +950,7 @@ GDALDataset *ERSDataset::Open(GDALOpenInfo *poOpenInfo) poHeader->Find("RasterInfo.CellType", "Unsigned8BitInteger"); GDALDataType eType; if (EQUAL(osCellType, "Unsigned8BitInteger")) - eType = GDT_Byte; + eType = GDT_UInt8; else if (EQUAL(osCellType, "Signed8BitInteger")) eType = GDT_Int8; else if (EQUAL(osCellType, "Unsigned16BitInteger")) @@ -968,7 +968,7 @@ GDALDataset *ERSDataset::Open(GDALOpenInfo *poOpenInfo) else { CPLDebug("ERS", "Unknown CellType '%s'", osCellType.c_str()); - eType = GDT_Byte; + eType = GDT_UInt8; } /* -------------------------------------------------------------------- */ @@ -1332,7 +1332,7 @@ GDALDataset *ERSDataset::Create(const char *pszFilename, int nXSize, int nYSize, return nullptr; } - if (eType != GDT_Byte && eType != GDT_Int8 && eType != GDT_Int16 && + if (eType != GDT_UInt8 && eType != GDT_Int8 && eType != GDT_Int16 && eType != GDT_UInt16 && eType != GDT_Int32 && eType != GDT_UInt32 && eType != GDT_Float32 && eType != GDT_Float64) { @@ -1366,7 +1366,7 @@ GDALDataset *ERSDataset::Create(const char *pszFilename, int nXSize, int nYSize, const char *pszCellType = "Unsigned8BitInteger"; CPL_IGNORE_RET_VAL(pszCellType); // Make CSA happy - if (eType == GDT_Byte) + if (eType == GDT_UInt8) pszCellType = "Unsigned8BitInteger"; else if (eType == GDT_Int8) pszCellType = "Signed8BitInteger"; @@ -1391,7 +1391,7 @@ GDALDataset *ERSDataset::Create(const char *pszFilename, int nXSize, int nYSize, /* Handling for signed eight bit data. */ /* -------------------------------------------------------------------- */ const char *pszPixelType = CSLFetchNameValue(papszOptions, "PIXELTYPE"); - if (pszPixelType && EQUAL(pszPixelType, "SIGNEDBYTE") && eType == GDT_Byte) + if (pszPixelType && EQUAL(pszPixelType, "SIGNEDBYTE") && eType == GDT_UInt8) pszCellType = "Signed8BitInteger"; /* -------------------------------------------------------------------- */ diff --git a/frmts/esric/esric_dataset.cpp b/frmts/esric/esric_dataset.cpp index e3d33c4bfb5f..eed2025a6312 100644 --- a/frmts/esric/esric_dataset.cpp +++ b/frmts/esric/esric_dataset.cpp @@ -923,8 +923,8 @@ CPLErr ECBand::IReadBlock(int nBlockXOff, int nBlockYOff, void *pData) { // Expand color indexed to RGB(A) errcode = GDALDatasetRasterIO( - inds, GF_Read, 0, 0, TSZ, TSZ, buffer.data(), TSZ, TSZ, GDT_Byte, 1, - usebands, parent->nBands, parent->nBands * TSZ, 1); + inds, GF_Read, 0, 0, TSZ, TSZ, buffer.data(), TSZ, TSZ, GDT_UInt8, + 1, usebands, parent->nBands, parent->nBands * TSZ, 1); if (CE_None == errcode) { GByte abyCT[4 * 256]; @@ -981,7 +981,7 @@ CPLErr ECBand::IReadBlock(int nBlockXOff, int nBlockYOff, void *pData) else { errcode = GDALDatasetRasterIO( - inds, GF_Read, 0, 0, TSZ, TSZ, buffer.data(), TSZ, TSZ, GDT_Byte, + inds, GF_Read, 0, 0, TSZ, TSZ, buffer.data(), TSZ, TSZ, GDT_UInt8, bandcount, usebands, parent->nBands, parent->nBands * TSZ, 1); } GDALClose(inds); @@ -1001,16 +1001,16 @@ CPLErr ECBand::IReadBlock(int nBlockXOff, int nBlockYOff, void *pData) poBlock = band->GetLockedBlockRef(nBlockXOff, nBlockYOff, 1); if (poBlock != nullptr) { - GDALCopyWords(buffer.data() + iBand - 1, GDT_Byte, - parent->nBands, poBlock->GetDataRef(), GDT_Byte, + GDALCopyWords(buffer.data() + iBand - 1, GDT_UInt8, + parent->nBands, poBlock->GetDataRef(), GDT_UInt8, 1, TSZ * TSZ); poBlock->DropLock(); } } else { - GDALCopyWords(buffer.data() + iBand - 1, GDT_Byte, parent->nBands, - pData, GDT_Byte, 1, TSZ * TSZ); + GDALCopyWords(buffer.data() + iBand - 1, GDT_UInt8, parent->nBands, + pData, GDT_UInt8, 1, TSZ * TSZ); } } diff --git a/frmts/exr/exrdataset.cpp b/frmts/exr/exrdataset.cpp index 7db5086cf87e..ea0453f3a88d 100644 --- a/frmts/exr/exrdataset.cpp +++ b/frmts/exr/exrdataset.cpp @@ -242,7 +242,7 @@ GDALEXRPreviewRasterBand::GDALEXRPreviewRasterBand(GDALEXRDataset *poDSIn, nRasterYSize = poDSIn->GetRasterYSize(); nBlockXSize = nRasterXSize; nBlockYSize = 1; - eDataType = GDT_Byte; + eDataType = GDT_UInt8; } /************************************************************************/ @@ -259,7 +259,7 @@ CPLErr GDALEXRPreviewRasterBand::IReadBlock(int, int nBlockYOff, void *pImage) GDALCopyWords(reinterpret_cast( preview.pixels() + nBlockYOff * nRasterXSize) + nBand - 1, - GDT_Byte, 4, pImage, GDT_Byte, 1, nRasterXSize); + GDT_UInt8, 4, pImage, GDT_UInt8, 1, nRasterXSize); return CE_None; } catch (const std::exception &e) @@ -846,7 +846,7 @@ GDALDataset *GDALEXRDataset::Open(GDALOpenInfo *poOpenInfo) static PixelType getPixelType(GDALDataType eSrcDT, char **papszOptions) { PixelType pixelType = - (eSrcDT == GDT_Byte) ? HALF + (eSrcDT == GDT_UInt8) ? HALF : (eSrcDT == GDT_Int16 || eSrcDT == GDT_UInt16 || eSrcDT == GDT_UInt32) ? UINT : FLOAT; @@ -965,7 +965,7 @@ GDALDataset *GDALEXRDataset::CreateCopy(const char *pszFilename, CPLTestBool(CSLFetchNameValueDef(papszOptions, "PREVIEW", "NO")) && (nXSize > 100 || nYSize > 100); const GDALDataType eSrcDT = poSrcDS->GetRasterBand(1)->GetRasterDataType(); - if (bPreview && !(bRGB_or_RGBA && eSrcDT == GDT_Byte)) + if (bPreview && !(bRGB_or_RGBA && eSrcDT == GDT_UInt8)) { CPLError( CE_Failure, CPLE_NotSupported, @@ -974,7 +974,7 @@ GDALDataset *GDALEXRDataset::CreateCopy(const char *pszFilename, } const PixelType pixelType = getPixelType(eSrcDT, papszOptions); const bool bRescaleDiv255 = - pixelType == HALF && bRGB_or_RGBA && eSrcDT == GDT_Byte && + pixelType == HALF && bRGB_or_RGBA && eSrcDT == GDT_UInt8 && CPLTestBool(CSLFetchNameValueDef(papszOptions, "AUTO_RESCALE", "YES")); setNumThreads(); @@ -1019,8 +1019,8 @@ GDALDataset *GDALEXRDataset::CreateCopy(const char *pszFilename, nYSize / nXSize)); std::vector pixels(previewWidth * previewHeight); if (poSrcDS->RasterIO(GF_Read, 0, 0, nXSize, nYSize, &pixels[0], - previewWidth, previewHeight, GDT_Byte, nBands, - nullptr, 4, 4 * previewWidth, 1, + previewWidth, previewHeight, GDT_UInt8, + nBands, nullptr, 4, 4 * previewWidth, 1, nullptr) == CE_None) { header.setPreviewImage( @@ -1653,7 +1653,7 @@ void GDALEXRWritableDataset::WriteHeader() } } m_bRescaleDiv255 &= m_pixelType == HALF && bRGB_or_RGBA && - GetRasterBand(1)->GetRasterDataType() == GDT_Byte; + GetRasterBand(1)->GetRasterDataType() == GDT_UInt8; if (bRGB_or_RGBA) { diff --git a/frmts/fits/fitsdataset.cpp b/frmts/fits/fitsdataset.cpp index 1549de647835..3da8a811b781 100644 --- a/frmts/fits/fitsdataset.cpp +++ b/frmts/fits/fitsdataset.cpp @@ -2108,7 +2108,7 @@ CPLErr FITSDataset::Init(fitsfile *hFITS, bool isExistingFile, int hduNum) // Determine data type and nodata value if BLANK keyword is absent if (bitpix == BYTE_IMG) { - m_gdalDataType = GDT_Byte; + m_gdalDataType = GDT_UInt8; m_fitsDataType = TBYTE; } else if (bitpix == SHORT_IMG) @@ -2720,7 +2720,7 @@ GDALDataset *FITSDataset::Create(const char *pszFilename, int nXSize, // Determine FITS type of image int bitpix; - if (eType == GDT_Byte) + if (eType == GDT_UInt8) { bitpix = BYTE_IMG; } diff --git a/frmts/georaster/georaster_dataset.cpp b/frmts/georaster/georaster_dataset.cpp index 9fb06f2eaaae..74b0489f4a52 100644 --- a/frmts/georaster/georaster_dataset.cpp +++ b/frmts/georaster/georaster_dataset.cpp @@ -1169,7 +1169,7 @@ GDALDataset *GeoRasterDataset::Create(const char *pszFilename, int nXSize, { /* JPEG-F can only compress byte data type */ - if (eType != GDT_Byte) + if (eType != GDT_UInt8) { CPLError( CE_Failure, CPLE_IllegalArg, diff --git a/frmts/georaster/georaster_rasterband.cpp b/frmts/georaster/georaster_rasterband.cpp index 4f73a5108eb6..3d9d2e0c1a72 100644 --- a/frmts/georaster/georaster_rasterband.cpp +++ b/frmts/georaster/georaster_rasterband.cpp @@ -276,7 +276,7 @@ GDALColorInterp GeoRasterRasterBand::GetColorInterpretation() { GeoRasterDataset *poGDS = cpl::down_cast(poDS); - if (eDataType == GDT_Byte && poGDS->nBands > 2) + if (eDataType == GDT_UInt8 && poGDS->nBands > 2) { if (nBand == poGeoRaster->iDefaultRedBand) { @@ -964,7 +964,7 @@ void GeoRasterRasterBand::ApplyNoDataArray(void *pBuffer) const switch (eDataType) { - case GDT_Byte: + case GDT_UInt8: { GByte *pbBuffer = (GByte *)pBuffer; diff --git a/frmts/georaster/oci_wrapper.cpp b/frmts/georaster/oci_wrapper.cpp index 460f6c658bf9..d0abe27f1254 100644 --- a/frmts/georaster/oci_wrapper.cpp +++ b/frmts/georaster/oci_wrapper.cpp @@ -13,7 +13,7 @@ #include "oci_wrapper.h" -static const OW_CellDepth ahOW_CellDepth[] = {{"8BIT_U", GDT_Byte}, +static const OW_CellDepth ahOW_CellDepth[] = {{"8BIT_U", GDT_UInt8}, {"16BIT_U", GDT_UInt16}, {"16BIT_S", GDT_Int16}, {"32BIT_U", GDT_UInt32}, @@ -22,9 +22,9 @@ static const OW_CellDepth ahOW_CellDepth[] = {{"8BIT_U", GDT_Byte}, {"64BIT_REAL", GDT_Float64}, {"32BIT_COMPLEX", GDT_CFloat32}, {"64BIT_COMPLEX", GDT_CFloat64}, - {"1BIT", GDT_Byte}, - {"2BIT", GDT_Byte}, - {"4BIT", GDT_Byte}}; + {"1BIT", GDT_UInt8}, + {"2BIT", GDT_UInt8}, + {"4BIT", GDT_UInt8}}; /*****************************************************************************/ /* OWSessionPool */ diff --git a/frmts/gff/gff_dataset.cpp b/frmts/gff/gff_dataset.cpp index cc2f917ecf4d..8124f1b06b1a 100644 --- a/frmts/gff/gff_dataset.cpp +++ b/frmts/gff/gff_dataset.cpp @@ -249,7 +249,7 @@ GDALDataset *GFFDataset::Open(GDALOpenInfo *poOpenInfo) switch (poDS->nImageType) { case 0: - poDS->eDataType = GDT_Byte; + poDS->eDataType = GDT_UInt8; break; case 1: diff --git a/frmts/gif/biggifdataset.cpp b/frmts/gif/biggifdataset.cpp index 024db9bb1ca5..3204f2e898ad 100644 --- a/frmts/gif/biggifdataset.cpp +++ b/frmts/gif/biggifdataset.cpp @@ -94,7 +94,7 @@ CPLErr BIGGifRasterBand::IReadBlock(CPL_UNUSED int nBlockXOff, int nBlockYOff, if (poGDS->poWorkDS != nullptr && nBlockYOff <= poGDS->nLastLineRead) { return poGDS->poWorkDS->RasterIO(GF_Read, 0, nBlockYOff, nBlockXSize, 1, - pImage, nBlockXSize, 1, GDT_Byte, 1, + pImage, nBlockXSize, 1, GDT_UInt8, 1, nullptr, 0, 0, 0, nullptr); } @@ -127,7 +127,7 @@ CPLErr BIGGifRasterBand::IReadBlock(CPL_UNUSED int nBlockXOff, int nBlockYOff, { eErr = poGDS->poWorkDS->RasterIO( GF_Write, 0, poGDS->nLastLineRead, nBlockXSize, 1, pImage, - nBlockXSize, 1, GDT_Byte, 1, nullptr, 0, 0, 0, nullptr); + nBlockXSize, 1, GDT_UInt8, 1, nullptr, 0, 0, 0, nullptr); } } @@ -225,7 +225,7 @@ CPLErr BIGGIFDataset::ReOpen() osTempFilename += ".tif"; poWorkDS = poGTiffDriver->Create(osTempFilename, nRasterXSize, - nRasterYSize, 1, GDT_Byte, + nRasterYSize, 1, GDT_UInt8, const_cast(apszOptions)); } } diff --git a/frmts/gif/gifabstractdataset.cpp b/frmts/gif/gifabstractdataset.cpp index 0856d6e0905d..05c258098890 100644 --- a/frmts/gif/gifabstractdataset.cpp +++ b/frmts/gif/gifabstractdataset.cpp @@ -390,7 +390,7 @@ GIFAbstractRasterBand::GIFAbstractRasterBand(GIFAbstractDataset *poDSIn, poDS = poDSIn; nBand = nBandIn; - eDataType = GDT_Byte; + eDataType = GDT_UInt8; nBlockXSize = poDS->GetRasterXSize(); nBlockYSize = 1; diff --git a/frmts/gif/gifdataset.cpp b/frmts/gif/gifdataset.cpp index 40eb0d29958b..1dcccf2a2bfe 100644 --- a/frmts/gif/gifdataset.cpp +++ b/frmts/gif/gifdataset.cpp @@ -392,7 +392,7 @@ GDALDataset *GIFDataset::CreateCopy(const char *pszFilename, return nullptr; } - if (poSrcDS->GetRasterBand(1)->GetRasterDataType() != GDT_Byte && bStrict) + if (poSrcDS->GetRasterBand(1)->GetRasterDataType() != GDT_UInt8 && bStrict) { CPLError(CE_Failure, CPLE_NotSupported, "GIF driver doesn't support data type %s. " @@ -542,8 +542,9 @@ GDALDataset *GIFDataset::CreateCopy(const char *pszFilename, for (int iLine = 0; iLine < nYSize; iLine++) { const CPLErr eErr = poBand->RasterIO( - GF_Read, 0, iLine, nXSize, 1, pabyScanline, nXSize, 1, GDT_Byte, - nBands, static_cast(nBands) * nXSize, nullptr); + GF_Read, 0, iLine, nXSize, 1, pabyScanline, nXSize, 1, + GDT_UInt8, nBands, static_cast(nBands) * nXSize, + nullptr); if (eErr != CE_None || EGifPutLine(hGifFile, pabyScanline, nXSize) == GIF_ERROR) @@ -571,7 +572,7 @@ GDALDataset *GIFDataset::CreateCopy(const char *pszFilename, { const CPLErr eErr = poBand->RasterIO(GF_Read, 0, j, nXSize, 1, pabyScanline, - nXSize, 1, GDT_Byte, 1, nXSize, nullptr); + nXSize, 1, GDT_UInt8, 1, nXSize, nullptr); if (eErr != CE_None || EGifPutLine(hGifFile, pabyScanline, nXSize) == GIF_ERROR) diff --git a/frmts/grib/gribcreatecopy.cpp b/frmts/grib/gribcreatecopy.cpp index cf8c13f467ec..c4292bd297ab 100644 --- a/frmts/grib/gribcreatecopy.cpp +++ b/frmts/grib/gribcreatecopy.cpp @@ -1477,12 +1477,12 @@ bool GRIB2Section567Writer::WriteIEEE(GDALProgressFunc pfnProgress, static GDALDataset *WrapArrayAsMemDataset(int nXSize, int nYSize, GDALDataType eReducedDT, void *pData) { - CPLAssert(eReducedDT == GDT_Byte || eReducedDT == GDT_UInt16); + CPLAssert(eReducedDT == GDT_UInt8 || eReducedDT == GDT_UInt16); auto poMEMDS = MEMDataset::Create("", nXSize, nYSize, 0, eReducedDT, nullptr); GByte *pabyData = static_cast(pData); #ifdef CPL_MSB - if (eReducedDT == GDT_Byte) + if (eReducedDT == GDT_UInt8) pabyData++; #endif auto hBand = @@ -1637,7 +1637,7 @@ bool GRIB2Section567Writer::WritePNG() CPLStringList aosPNGOptions; aosPNGOptions.SetNameValue("NBITS", CPLSPrintf("%d", m_nBits)); - const GDALDataType eReducedDT = (m_nBits <= 8) ? GDT_Byte : GDT_UInt16; + const GDALDataType eReducedDT = (m_nBits <= 8) ? GDT_UInt8 : GDT_UInt16; GDALDataset *poMEMDS = WrapArrayAsMemDataset(m_nXSize, m_nYSize, eReducedDT, panData); @@ -1823,7 +1823,7 @@ bool GRIB2Section567Writer::WriteJPEG2000(char **papszOptions) } aosJ2KOptions.SetNameValue("NBITS", CPLSPrintf("%d", m_nBits)); - const GDALDataType eReducedDT = (m_nBits <= 8) ? GDT_Byte : GDT_UInt16; + const GDALDataType eReducedDT = (m_nBits <= 8) ? GDT_UInt8 : GDT_UInt16; GDALDataset *poMEMDS = WrapArrayAsMemDataset(m_nXSize, m_nYSize, eReducedDT, panData); @@ -1897,7 +1897,7 @@ bool GRIB2Section567Writer::Write(float fValOffset, char **papszOptions, JPEG2000 } GRIBDataEncoding; - if (m_eDT != GDT_Byte && m_eDT != GDT_UInt16 && m_eDT != GDT_Int16 && + if (m_eDT != GDT_UInt8 && m_eDT != GDT_UInt16 && m_eDT != GDT_Int16 && m_eDT != GDT_UInt32 && m_eDT != GDT_Int32 && m_eDT != GDT_Float32 && m_eDT != GDT_Float64) { diff --git a/frmts/gsg/gs7bgdataset.cpp b/frmts/gsg/gs7bgdataset.cpp index bcce72b8703c..0df19817d472 100644 --- a/frmts/gsg/gs7bgdataset.cpp +++ b/frmts/gsg/gs7bgdataset.cpp @@ -1058,7 +1058,7 @@ GDALDataset *GS7BGDataset::Create(const char *pszFilename, int nXSize, return nullptr; } - if (eType != GDT_Byte && eType != GDT_Float32 && eType != GDT_UInt16 && + if (eType != GDT_UInt8 && eType != GDT_Float32 && eType != GDT_UInt16 && eType != GDT_Int16 && eType != GDT_Float64) { CPLError( diff --git a/frmts/gsg/gsbgdataset.cpp b/frmts/gsg/gsbgdataset.cpp index af0a1acaae06..8683dd967c76 100644 --- a/frmts/gsg/gsbgdataset.cpp +++ b/frmts/gsg/gsbgdataset.cpp @@ -818,7 +818,7 @@ GDALDataset *GSBGDataset::Create(const char *pszFilename, int nXSize, return nullptr; } - if (eType != GDT_Byte && eType != GDT_Float32 && eType != GDT_UInt16 && + if (eType != GDT_UInt8 && eType != GDT_Float32 && eType != GDT_UInt16 && eType != GDT_Int16) { CPLError(CE_Failure, CPLE_AppDefined, diff --git a/frmts/gta/gtadataset.cpp b/frmts/gta/gtadataset.cpp index 6ef45afe36be..24479ed55710 100644 --- a/frmts/gta/gtadataset.cpp +++ b/frmts/gta/gtadataset.cpp @@ -323,7 +323,7 @@ GTARasterBand::GTARasterBand(GTADataset *poDSIn, int nBandIn) eDataType = GDT_Int8; break; case gta::uint8: - eDataType = GDT_Byte; + eDataType = GDT_UInt8; break; case gta::int16: eDataType = GDT_Int16; @@ -1350,7 +1350,7 @@ static GDALDataset *GTACreateCopy(const char *pszFilename, GDALDataset *poSrcDS, GDALDataType eDT = poSrcBand->GetRasterDataType(); switch (eDT) { - case GDT_Byte: + case GDT_UInt8: { const char *pszPixelType = poSrcBand->GetMetadataItem("PIXELTYPE", "IMAGE_STRUCTURE"); diff --git a/frmts/gti/gdaltileindexdataset.cpp b/frmts/gti/gdaltileindexdataset.cpp index e1406a1624b4..f3f15a91a649 100644 --- a/frmts/gti/gdaltileindexdataset.cpp +++ b/frmts/gti/gdaltileindexdataset.cpp @@ -1754,7 +1754,7 @@ bool GDALTileIndexDataset::Open(GDALOpenInfo *poOpenInfo) if (aeDataTypes.empty() && !pszDataType) { - aeDataTypes.resize(nBandCount, GDT_Byte); + aeDataTypes.resize(nBandCount, GDT_UInt8); } else if (pszDataType) { @@ -2249,7 +2249,7 @@ bool GDALTileIndexDataset::Open(GDALOpenInfo *poOpenInfo) if (bHasMaskBand) { m_poMaskBand = std::make_unique( - this, 0, GDT_Byte, nBlockXSize, nBlockYSize); + this, 0, GDT_UInt8, nBlockXSize, nBlockYSize); } if (dfOvrFactor == 1.0) @@ -4124,7 +4124,7 @@ CompositeSrcWithMaskIntoDest(const int nOutXSize, const int nOutYSize, const GByte *const pabyMask, GByte *const pabyDest) { size_t iMaskIdx = 0; - if (eBufType == GDT_Byte) + if (eBufType == GDT_UInt8) { // Optimization for byte case for (int iY = 0; iY < nOutYSize; iY++) @@ -4337,7 +4337,7 @@ CPLErr GDALTileIndexDataset::RenderSource( if (poTileDS->GetRasterCount() + 1 == nBandNrMax && papoBands[nBandNrMax - 1]->GetColorInterpretation() == GCI_AlphaBand && - papoBands[nBandNrMax - 1]->GetRasterDataType() == GDT_Byte) + papoBands[nBandNrMax - 1]->GetRasterDataType() == GDT_UInt8) { // Special case when there's typically a mix of RGB and RGBA source // datasets and we read a RGB one. @@ -4382,7 +4382,7 @@ CPLErr GDALTileIndexDataset::RenderSource( for (int iY = 0; iY < nOutYSize; iY++) { GDALCopyWords( - &n255, GDT_Byte, 0, + &n255, GDT_UInt8, 0, pabyOut + static_cast(iY * nLineSpace), eBufType, static_cast(nPixelSpace), nOutXSize); } @@ -4460,7 +4460,7 @@ CPLErr GDALTileIndexDataset::RenderSource( &nOutXSize, &nOutYSize, bError)) { int iMaskBandIdx = -1; - if (eBufType == GDT_Byte && nBandNrMax == 0) + if (eBufType == GDT_UInt8 && nBandNrMax == 0) { // when called from m_poMaskBand iMaskBandIdx = 0; @@ -4471,7 +4471,7 @@ CPLErr GDALTileIndexDataset::RenderSource( // one of the queried bands of this request, we can save // requesting it separately. const int nMaskBandNr = oSourceDesc.poMaskBand->GetBand(); - if (eBufType == GDT_Byte && nMaskBandNr >= 1 && + if (eBufType == GDT_UInt8 && nMaskBandNr >= 1 && nMaskBandNr <= poTileDS->GetRasterCount() && poTileDS->GetRasterBand(nMaskBandNr) == oSourceDesc.poMaskBand) @@ -4524,7 +4524,7 @@ CPLErr GDALTileIndexDataset::RenderSource( if (oSourceDesc.poMaskBand->RasterIO( GF_Read, nReqXOff, nReqYOff, nReqXSize, nReqYSize, oSourceDesc.abyMask.data(), nOutXSize, nOutYSize, - GDT_Byte, 0, 0, &sExtraArg) != CE_None) + GDT_UInt8, 0, 0, &sExtraArg) != CE_None) { oSourceDesc.abyMask.clear(); return CE_Failure; diff --git a/frmts/gtiff/generate_quant_table_md5sum.cpp b/frmts/gtiff/generate_quant_table_md5sum.cpp index d278c8c97f54..202c92ddf4a1 100644 --- a/frmts/gtiff/generate_quant_table_md5sum.cpp +++ b/frmts/gtiff/generate_quant_table_md5sum.cpp @@ -79,7 +79,7 @@ void generate(int nBands, uint16_t nPhotometric, uint16_t nBitsPerSample) GDALDriver::FromHandle(GDALGetDriverByName("GTiff")) ->Create( osTmpFilename.c_str(), 16, 16, (nBands <= 4) ? nBands : 1, - nBitsPerSample == 8 ? GDT_Byte : GDT_UInt16, papszOpts)); + nBitsPerSample == 8 ? GDT_UInt8 : GDT_UInt16, papszOpts)); assert(poDS); poDS.reset(); CPLPopErrorHandler(); diff --git a/frmts/gtiff/geotiff.cpp b/frmts/gtiff/geotiff.cpp index a676e69680d4..b91ad7d7225e 100644 --- a/frmts/gtiff/geotiff.cpp +++ b/frmts/gtiff/geotiff.cpp @@ -666,7 +666,7 @@ void GTiffWriteJPEGTables(TIFF *hTIFF, const char *pszPhotometric, TIFF *hTIFFTmp = GTiffDataset::CreateLL(osTmpFilenameIn, nInMemImageWidth, nInMemImageHeight, (nBands <= 4) ? nBands : 1, - (l_nBitsPerSample <= 8) ? GDT_Byte : GDT_UInt16, + (l_nBitsPerSample <= 8) ? GDT_UInt8 : GDT_UInt16, 0.0, 0, papszLocalParameters, &fpTmp, osTmp, /* bCreateCopy=*/false, bTileInterleaving); CSLDestroy(papszLocalParameters); diff --git a/frmts/gtiff/gt_jpeg_copy.cpp b/frmts/gtiff/gt_jpeg_copy.cpp index 13bfdd79a57f..bafbab720922 100644 --- a/frmts/gtiff/gt_jpeg_copy.cpp +++ b/frmts/gtiff/gt_jpeg_copy.cpp @@ -143,7 +143,7 @@ int GTIFF_CanDirectCopyFromJPEG(GDALDataset *poSrcDS, papszCreateOptions = CSLSetNameValue(papszCreateOptions, "PHOTOMETRIC", NULL); - if (poSrcDS->GetRasterBand(1)->GetRasterDataType() != GDT_Byte) + if (poSrcDS->GetRasterBand(1)->GetRasterDataType() != GDT_UInt8) papszCreateOptions = CSLSetNameValue(papszCreateOptions, "NBITS", "12"); else @@ -325,7 +325,7 @@ int GTIFF_CanCopyFromJPEG(GDALDataset *poSrcDS, char **&papszCreateOptions) if ((nBlockXSize == nXSize || (nBlockXSize % nMCUSize) == 0) && (nBlockYSize == nYSize || (nBlockYSize % nMCUSize) == 0) && - poSrcDS->GetRasterBand(1)->GetRasterDataType() == GDT_Byte && + poSrcDS->GetRasterBand(1)->GetRasterDataType() == GDT_UInt8 && CSLFetchNameValue(papszCreateOptions, "NBITS") == nullptr && CSLFetchNameValue(papszCreateOptions, "JPEG_QUALITY") == nullptr) { diff --git a/frmts/gtiff/gt_overview.cpp b/frmts/gtiff/gt_overview.cpp index d6b0787897b0..a8864a8377a9 100644 --- a/frmts/gtiff/gt_overview.cpp +++ b/frmts/gtiff/gt_overview.cpp @@ -331,7 +331,7 @@ CPLErr GTIFFBuildOverviewsEx(const char *pszFilename, int nBands, switch (hBand->GetRasterDataType()) { - case GDT_Byte: + case GDT_UInt8: nBandBits = 8; nBandFormat = SAMPLEFORMAT_UINT; break; @@ -568,7 +568,7 @@ CPLErr GTIFFBuildOverviewsEx(const char *pszFilename, int nBands, if (nBands == 3) nPhotometric = PHOTOMETRIC_RGB; else if (papoBandList[0]->GetColorTable() != nullptr && - (papoBandList[0]->GetRasterDataType() == GDT_Byte || + (papoBandList[0]->GetRasterDataType() == GDT_UInt8 || papoBandList[0]->GetRasterDataType() == GDT_UInt16) && !STARTS_WITH_CI(pszResampling, "AVERAGE_BIT2")) { diff --git a/frmts/gtiff/gtiffbitmapband.cpp b/frmts/gtiff/gtiffbitmapband.cpp index f649bbbcbcb5..9956940ff4c4 100644 --- a/frmts/gtiff/gtiffbitmapband.cpp +++ b/frmts/gtiff/gtiffbitmapband.cpp @@ -24,7 +24,7 @@ GTiffBitmapBand::GTiffBitmapBand(GTiffDataset *poDSIn, int nBandIn) : GTiffOddBitsBand(poDSIn, nBandIn) { - eDataType = GDT_Byte; + eDataType = GDT_UInt8; if (poDSIn->m_poColorTable != nullptr) { diff --git a/frmts/gtiff/gtiffdataset.cpp b/frmts/gtiff/gtiffdataset.cpp index 3c739612478f..53945dab8f35 100644 --- a/frmts/gtiff/gtiffdataset.cpp +++ b/frmts/gtiff/gtiffdataset.cpp @@ -1220,7 +1220,7 @@ void GTiffDataset::ScanDirectories() m_poMaskDS->GetRasterXSize() != GetRasterXSize() || m_poMaskDS->GetRasterYSize() != GetRasterYSize() || m_poMaskDS->GetRasterBand(1)->GetRasterDataType() != - GDT_Byte) + GDT_UInt8) { delete m_poMaskDS; m_poMaskDS = nullptr; @@ -1250,7 +1250,7 @@ void GTiffDataset::ScanDirectories() if (poDS->OpenOffset(VSI_TIFFOpenChild(m_hTIFF), nThisDir, eAccess) != CE_None || poDS->GetRasterCount() == 0 || - poDS->GetRasterBand(1)->GetRasterDataType() != GDT_Byte) + poDS->GetRasterBand(1)->GetRasterDataType() != GDT_UInt8) { delete poDS; } diff --git a/frmts/gtiff/gtiffdataset_read.cpp b/frmts/gtiff/gtiffdataset_read.cpp index 431e578a2fd6..b46566d91e35 100644 --- a/frmts/gtiff/gtiffdataset_read.cpp +++ b/frmts/gtiff/gtiffdataset_read.cpp @@ -1084,7 +1084,7 @@ CPLErr GTiffDataset::MultiThreadedRead(int nXOff, int nYOff, int nXSize, if (m_nPlanarConfig == PLANARCONFIG_CONTIG && (nBands == 3 || nBands == 4) && nBands == nBandCount && - (sContext.eDT == GDT_Byte || sContext.eDT == GDT_Int16 || + (sContext.eDT == GDT_UInt8 || sContext.eDT == GDT_Int16 || sContext.eDT == GDT_UInt16)) { if (sContext.bSkipBlockCache) @@ -1133,7 +1133,7 @@ CPLErr GTiffDataset::MultiThreadedRead(int nXOff, int nYOff, int nXSize, { sContext.bCacheAllBands = true; if ((nBands == 3 || nBands == 4) && - (sContext.eDT == GDT_Byte || sContext.eDT == GDT_Int16 || + (sContext.eDT == GDT_UInt8 || sContext.eDT == GDT_Int16 || sContext.eDT == GDT_UInt16)) { sContext.bUseDeinterleaveOptimBlockCache = true; @@ -3123,7 +3123,7 @@ int GTiffDataset::DirectIO(GDALRWFlag eRWFlag, int nXOff, int nYOff, int nXSize, // Other optimization: no resampling, no data type change, // data type is Byte/Int8. else if (nBufXSize == nXSize && eDataType == eBufType && - (eDataType == GDT_Byte || eDataType == GDT_Int8)) + (eDataType == GDT_UInt8 || eDataType == GDT_Int8)) { GByte *pabySrcData = static_cast(ppData[iSrcY]); GByte *pabyDstData = @@ -3141,8 +3141,8 @@ int GTiffDataset::DirectIO(GDALRWFlag eRWFlag, int nXOff, int nYOff, int nXSize, for (int iBand = 0; iBand < nBandCount; ++iBand) { GDALCopyWords( - pabySrcData + iBand, GDT_Byte, nSrcPixelSize, - pabyDstData + iBand * nBandSpace, GDT_Byte, + pabySrcData + iBand, GDT_UInt8, nSrcPixelSize, + pabyDstData + iBand * nBandSpace, GDT_UInt8, static_cast(nPixelSpace), nBufXSize); } } @@ -3155,7 +3155,7 @@ int GTiffDataset::DirectIO(GDALRWFlag eRWFlag, int nXOff, int nYOff, int nXSize, static_cast(ppData[iSrcY]) + iBand * nDTSize; GByte *pabyDstData = static_cast(pData) + iBand * nBandSpace + iY * nLineSpace; - if ((eDataType == GDT_Byte && eBufType == GDT_Byte) || + if ((eDataType == GDT_UInt8 && eBufType == GDT_UInt8) || (eDataType == GDT_Int8 && eBufType == GDT_Int8)) { double dfSrcX = 0.5 * dfSrcXInc; @@ -5425,7 +5425,7 @@ CPLErr GTiffDataset::OpenOffset(TIFF *hTIFFIn, toff_t nDirOffsetIn, else m_oGTiffMDMD.SetMetadataItem("INTERLEAVE", "BAND", "IMAGE_STRUCTURE"); - if ((GetRasterBand(1)->GetRasterDataType() == GDT_Byte && + if ((GetRasterBand(1)->GetRasterDataType() == GDT_UInt8 && m_nBitsPerSample != 8) || (GetRasterBand(1)->GetRasterDataType() == GDT_UInt16 && m_nBitsPerSample != 16) || diff --git a/frmts/gtiff/gtiffdataset_write.cpp b/frmts/gtiff/gtiffdataset_write.cpp index f5cb2df00556..f31f7b3b0b12 100644 --- a/frmts/gtiff/gtiffdataset_write.cpp +++ b/frmts/gtiff/gtiffdataset_write.cpp @@ -5596,7 +5596,7 @@ TIFF *GTiffDataset::CreateLL(const char *pszFilename, int nXSize, int nYSize, /* -------------------------------------------------------------------- */ /* How many bits per sample? We have a special case if NBITS */ - /* specified for GDT_Byte, GDT_UInt16, GDT_UInt32. */ + /* specified for GDT_UInt8, GDT_UInt16, GDT_UInt32. */ /* -------------------------------------------------------------------- */ int l_nBitsPerSample = GDALGetDataTypeSizeBits(eType); if (CSLFetchNameValue(papszParamList, "NBITS") != nullptr) @@ -5604,7 +5604,7 @@ TIFF *GTiffDataset::CreateLL(const char *pszFilename, int nXSize, int nYSize, int nMinBits = 0; int nMaxBits = 0; l_nBitsPerSample = atoi(CSLFetchNameValue(papszParamList, "NBITS")); - if (eType == GDT_Byte) + if (eType == GDT_UInt8) { nMinBits = 1; nMaxBits = 8; @@ -5663,7 +5663,7 @@ TIFF *GTiffDataset::CreateLL(const char *pszFilename, int nXSize, int nYSize, eType != GDT_Float16 && eType != GDT_Float32) { // Reflects tif_jxl's GetJXLDataType() - if (eType != GDT_Byte && eType != GDT_UInt16) + if (eType != GDT_UInt8 && eType != GDT_UInt16) { ReportError(pszFilename, CE_Failure, CPLE_NotSupported, "Data type %s not supported for JXL compression. Only " @@ -5677,7 +5677,7 @@ TIFF *GTiffDataset::CreateLL(const char *pszFilename, int nXSize, int nYSize, GDALDataType eDT; int nBitsPerSample; } asSupportedDTBitsPerSample[] = { - {GDT_Byte, 8}, + {GDT_UInt8, 8}, {GDT_UInt16, 16}, }; @@ -6071,7 +6071,7 @@ TIFF *GTiffDataset::CreateLL(const char *pszFilename, int nXSize, int nYSize, const char *pszPixelType = CSLFetchNameValue(papszParamList, "PIXELTYPE"); if (pszPixelType == nullptr) pszPixelType = ""; - if (eType == GDT_Byte && EQUAL(pszPixelType, "SIGNEDBYTE")) + if (eType == GDT_UInt8 && EQUAL(pszPixelType, "SIGNEDBYTE")) { CPLError(CE_Warning, CPLE_AppDefined, "Using PIXELTYPE=SIGNEDBYTE with Byte data type is deprecated " @@ -6087,7 +6087,7 @@ TIFF *GTiffDataset::CreateLL(const char *pszFilename, int nXSize, int nYSize, TIFFSetField(l_hTIFF, TIFFTAG_BITSPERSAMPLE, l_nBitsPerSample); uint16_t l_nSampleFormat = 0; - if ((eType == GDT_Byte && EQUAL(pszPixelType, "SIGNEDBYTE")) || + if ((eType == GDT_UInt8 && EQUAL(pszPixelType, "SIGNEDBYTE")) || eType == GDT_Int8 || eType == GDT_Int16 || eType == GDT_Int32 || eType == GDT_Int64) l_nSampleFormat = SAMPLEFORMAT_INT; @@ -6123,7 +6123,7 @@ TIFF *GTiffDataset::CreateLL(const char *pszFilename, int nXSize, int nYSize, } else if (EQUAL(pszValue, "PALETTE")) { - if (eType == GDT_Byte || eType == GDT_UInt16) + if (eType == GDT_UInt8 || eType == GDT_UInt16) { TIFFSetField(l_hTIFF, TIFFTAG_PHOTOMETRIC, PHOTOMETRIC_PALETTE); nSamplesAccountedFor = 1; @@ -6234,12 +6234,12 @@ TIFF *GTiffDataset::CreateLL(const char *pszFilename, int nXSize, int nYSize, { // If image contains 3 or 4 bands and datatype is Byte then we will // assume it is RGB. In all other cases assume it is MINISBLACK. - if (l_nBands == 3 && eType == GDT_Byte) + if (l_nBands == 3 && eType == GDT_UInt8) { TIFFSetField(l_hTIFF, TIFFTAG_PHOTOMETRIC, PHOTOMETRIC_RGB); nSamplesAccountedFor = 3; } - else if (l_nBands == 4 && eType == GDT_Byte) + else if (l_nBands == 4 && eType == GDT_UInt8) { uint16_t v[1] = { GTiffGetAlphaValue(CSLFetchNameValue(papszParamList, "ALPHA"), @@ -6388,7 +6388,7 @@ TIFF *GTiffDataset::CreateLL(const char *pszFilename, int nXSize, int nYSize, /* -------------------------------------------------------------------- */ if (bForceColorTable) { - const int nColors = eType == GDT_Byte ? 256 : 65536; + const int nColors = eType == GDT_UInt8 ? 256 : 65536; unsigned short *panTRed = static_cast( CPLMalloc(sizeof(unsigned short) * nColors)); @@ -6399,7 +6399,7 @@ TIFF *GTiffDataset::CreateLL(const char *pszFilename, int nXSize, int nYSize, for (int iColor = 0; iColor < nColors; ++iColor) { - if (eType == GDT_Byte) + if (eType == GDT_UInt8) { panTRed[iColor] = GTiffDataset::ClampCTEntry( iColor, 1, iColor, nColorTableMultiplier); @@ -7143,7 +7143,7 @@ CPLErr GTiffDataset::CopyImageryAndMask(GTiffDataset *poDstDS, } eErr = poSrcMaskBand->RasterIO( GF_Read, iX, iY, nReqXSize, nReqYSize, pBlockBuffer, - nReqXSize, nReqYSize, GDT_Byte, 1, + nReqXSize, nReqYSize, GDT_UInt8, 1, poDstDS->m_nBlockXSize, nullptr); if (eErr == CE_None) { @@ -7305,7 +7305,7 @@ CPLErr GTiffDataset::CopyImageryAndMask(GTiffDataset *poDstDS, } eErr = poSrcMaskBand->RasterIO( GF_Read, iX, iY, nReqXSize, nReqYSize, pBlockBuffer, - nReqXSize, nReqYSize, GDT_Byte, 1, + nReqXSize, nReqYSize, GDT_UInt8, 1, poDstDS->m_nBlockXSize, nullptr); if (eErr == CE_None) { @@ -7410,7 +7410,7 @@ GDALDataset *GTiffDataset::CreateCopy(const char *pszFilename, } if (CSLFetchNameValue(papszOptions, "PIXELTYPE") == nullptr && - eType == GDT_Byte) + eType == GDT_UInt8) { poPBand->EnablePixelTypeSignedByteWarning(false); const char *pszPixelType = @@ -7756,7 +7756,7 @@ GDALDataset *GTiffDataset::CreateCopy(const char *pszFilename, /* -------------------------------------------------------------------- */ if ((l_nBands == 1 || l_nBands == 2) && poSrcDS->GetRasterBand(1)->GetColorTable() != nullptr && - eType == GDT_Byte) + eType == GDT_UInt8) { unsigned short anTRed[256] = {0}; unsigned short anTGreen[256] = {0}; @@ -7860,7 +7860,7 @@ GDALDataset *GTiffDataset::CreateCopy(const char *pszFilename, if (l_nBands == 2 && poSrcDS->GetRasterBand(1)->GetColorTable() != nullptr && - (eType == GDT_Byte || eType == GDT_UInt16)) + (eType == GDT_UInt8 || eType == GDT_UInt16)) { uint16_t v[1] = {EXTRASAMPLE_UNASSALPHA}; @@ -8265,17 +8265,17 @@ GDALDataset *GTiffDataset::CreateCopy(const char *pszFilename, return nullptr; } - // Legacy... Patch back GDT_Int8 type to GDT_Byte if the user used + // Legacy... Patch back GDT_Int8 type to GDT_UInt8 if the user used // PIXELTYPE=SIGNEDBYTE const char *pszPixelType = CSLFetchNameValue(papszOptions, "PIXELTYPE"); if (pszPixelType == nullptr) pszPixelType = ""; - if (eType == GDT_Byte && EQUAL(pszPixelType, "SIGNEDBYTE")) + if (eType == GDT_UInt8 && EQUAL(pszPixelType, "SIGNEDBYTE")) { for (int i = 0; i < poDS->nBands; ++i) { auto poBand = static_cast(poDS->papoBands[i]); - poBand->eDataType = GDT_Byte; + poBand->eDataType = GDT_UInt8; poBand->EnablePixelTypeSignedByteWarning(false); poBand->SetMetadataItem("PIXELTYPE", "SIGNEDBYTE", "IMAGE_STRUCTURE"); @@ -8812,8 +8812,8 @@ GDALDataset *GTiffDataset::CreateCopy(const char *pszFilename, for (int j = 0; j < nYSize && eErr == CE_None; ++j) { eErr = poSrcDS->RasterIO(GF_Read, 0, j, nXSize, 1, pabyScanline, - nXSize, 1, GDT_Byte, l_nBands, nullptr, - poDS->nBands, 0, 1, nullptr); + nXSize, 1, GDT_UInt8, l_nBands, + nullptr, poDS->nBands, 0, 1, nullptr); if (eErr == CE_None && TIFFWriteScanline(l_hTIFF, pabyScanline, j, 0) == -1) { @@ -8841,7 +8841,7 @@ GDALDataset *GTiffDataset::CreateCopy(const char *pszFilename, { eErr = poSrcDS->GetRasterBand(iBand)->RasterIO( GF_Read, 0, j, nXSize, 1, pabyScanline, nXSize, 1, - GDT_Byte, 0, 0, nullptr); + GDT_UInt8, 0, 0, nullptr); if (poDS->m_bTreatAsSplitBitmap) { for (int i = 0; i < nXSize; ++i) diff --git a/frmts/gtiff/gtiffoddbitsband.cpp b/frmts/gtiff/gtiffoddbitsband.cpp index 9e2fab61fe42..a8e7e4ffbb7f 100644 --- a/frmts/gtiff/gtiffoddbitsband.cpp +++ b/frmts/gtiff/gtiffoddbitsband.cpp @@ -35,7 +35,7 @@ GTiffOddBitsBand::GTiffOddBitsBand(GTiffDataset *m_poGDSIn, int nBandIn) else if ((m_poGDS->m_nSampleFormat == SAMPLEFORMAT_UINT || m_poGDS->m_nSampleFormat == SAMPLEFORMAT_INT) && m_poGDS->m_nBitsPerSample < 8) - eDataType = GDT_Byte; + eDataType = GDT_UInt8; else if ((m_poGDS->m_nSampleFormat == SAMPLEFORMAT_UINT || m_poGDS->m_nSampleFormat == SAMPLEFORMAT_INT) && m_poGDS->m_nBitsPerSample > 8 && m_poGDS->m_nBitsPerSample < 16) @@ -221,7 +221,7 @@ CPLErr GTiffOddBitsBand::IWriteBlock(int nBlockXOff, int nBlockYOff, for (int iX = 0; iX < nBlockXSize; ++iX) { GUInt32 nInWord = 0; - if (eDataType == GDT_Byte) + if (eDataType == GDT_UInt8) { nInWord = static_cast(pImage)[iPixel++]; } @@ -416,7 +416,7 @@ CPLErr GTiffOddBitsBand::IWriteBlock(int nBlockXOff, int nBlockYOff, for (int iX = 0; iX < nBlockXSize; ++iX) { GUInt32 nInWord = 0; - if (eDataType == GDT_Byte) + if (eDataType == GDT_UInt8) { nInWord = static_cast(pabyThisImage)[iPixel++]; @@ -751,7 +751,7 @@ CPLErr GTiffOddBitsBand::IReadBlock(int nBlockXOff, int nBlockYOff, const unsigned nBitsPerSample = m_poGDS->m_nBitsPerSample; GPtrDiff_t iPixel = 0; - if (nBitsPerSample == 1 && eDataType == GDT_Byte) + if (nBitsPerSample == 1 && eDataType == GDT_UInt8) { for (unsigned iY = 0; iY < static_cast(nBlockYSize); ++iY) { @@ -791,7 +791,7 @@ CPLErr GTiffOddBitsBand::IReadBlock(int nBlockXOff, int nBlockYOff, iBitOffset = iBitOffset + iPixelBitSkip - nBitsPerSample; - if (eDataType == GDT_Byte) + if (eDataType == GDT_UInt8) { static_cast(pImage)[iPixel++] = static_cast(nOutWord); diff --git a/frmts/gtiff/gtiffrasterband.cpp b/frmts/gtiff/gtiffrasterband.cpp index 01521117300c..616bc9325007 100644 --- a/frmts/gtiff/gtiffrasterband.cpp +++ b/frmts/gtiff/gtiffrasterband.cpp @@ -44,7 +44,7 @@ GTiffRasterBand::GTiffRasterBand(GTiffDataset *poDSIn, int nBandIn) if (nSampleFormat == SAMPLEFORMAT_INT) eDataType = GDT_Int8; else - eDataType = GDT_Byte; + eDataType = GDT_UInt8; } else if (nBitsPerSample <= 16) { diff --git a/frmts/gtiff/gtiffrasterband_read.cpp b/frmts/gtiff/gtiffrasterband_read.cpp index 73aabcca5b69..2056a63b2e5e 100644 --- a/frmts/gtiff/gtiffrasterband_read.cpp +++ b/frmts/gtiff/gtiffrasterband_read.cpp @@ -292,7 +292,7 @@ int GTiffRasterBand::DirectIO(GDALRWFlag eRWFlag, int nXOff, int nYOff, { const bool bOneByteCopy = (eDataType == eBufType && - (eDataType == GDT_Byte || eDataType == GDT_Int8)); + (eDataType == GDT_UInt8 || eDataType == GDT_Int8)); for (int iY = 0; iY < nBufYSize; ++iY) { const int iSrcY = nBufYSize <= nYSize @@ -852,7 +852,7 @@ CPLErr GTiffRasterBand::IReadBlock(int nBlockXOff, int nBlockYOff, void *pImage) if (nBand == 1 && !m_poGDS->m_bLoadingOtherBands && eAccess == GA_ReadOnly && (m_poGDS->nBands == 3 || m_poGDS->nBands == 4) && - ((eDataType == GDT_Byte && m_poGDS->m_nBitsPerSample == 8) || + ((eDataType == GDT_UInt8 && m_poGDS->m_nBitsPerSample == 8) || (eDataType == GDT_Int16 && m_poGDS->m_nBitsPerSample == 16) || (eDataType == GDT_UInt16 && m_poGDS->m_nBitsPerSample == 16)) && static_cast(nBlockXSize) * nBlockYSize * @@ -1190,7 +1190,7 @@ const char *GTiffRasterBand::GetMetadataItem(const char *pszName, const char *pszRet = m_oGTiffMDMD.GetMetadataItem(pszName, pszDomain); - if (pszRet == nullptr && eDataType == GDT_Byte && pszName && pszDomain && + if (pszRet == nullptr && eDataType == GDT_UInt8 && pszName && pszDomain && EQUAL(pszDomain, "IMAGE_STRUCTURE") && EQUAL(pszName, "PIXELTYPE")) { // to get a chance of emitting the warning about this legacy usage diff --git a/frmts/gtiff/gtiffrasterband_write.cpp b/frmts/gtiff/gtiffrasterband_write.cpp index 1568b97cf241..9236003988ef 100644 --- a/frmts/gtiff/gtiffrasterband_write.cpp +++ b/frmts/gtiff/gtiffrasterband_write.cpp @@ -597,7 +597,7 @@ CPLErr GTiffRasterBand::SetColorTable(GDALColorTable *poCT) return CE_Failure; } - if (eDataType != GDT_Byte && eDataType != GDT_UInt16) + if (eDataType != GDT_UInt8 && eDataType != GDT_UInt16) { ReportError( CE_Failure, CPLE_NotSupported, @@ -640,7 +640,7 @@ CPLErr GTiffRasterBand::SetColorTable(GDALColorTable *poCT) { int nColors = 65536; - if (eDataType == GDT_Byte) + if (eDataType == GDT_UInt8) nColors = 256; unsigned short *panTRed = static_cast( diff --git a/frmts/gtiff/gtiffrgbaband.cpp b/frmts/gtiff/gtiffrgbaband.cpp index 814fa06b2151..fc09a75f5d3e 100644 --- a/frmts/gtiff/gtiffrgbaband.cpp +++ b/frmts/gtiff/gtiffrgbaband.cpp @@ -24,7 +24,7 @@ GTiffRGBABand::GTiffRGBABand(GTiffDataset *poDSIn, int nBandIn) : GTiffRasterBand(poDSIn, nBandIn) { - eDataType = GDT_Byte; + eDataType = GDT_UInt8; } /************************************************************************/ @@ -156,10 +156,10 @@ CPLErr GTiffRGBABand::IReadBlock(int nBlockXOff, int nBlockYOff, void *pImage) static_cast(nThisBlockYSize - iDestLine - 1) * nBlockXSize * 4; - GDALCopyWords(m_poGDS->m_pabyBlockBuf + nBO + nSrcOffset, GDT_Byte, 4, + GDALCopyWords(m_poGDS->m_pabyBlockBuf + nBO + nSrcOffset, GDT_UInt8, 4, static_cast(pImage) + static_cast(iDestLine) * nBlockXSize, - GDT_Byte, 1, nBlockXSize); + GDT_UInt8, 1, nBlockXSize); } if (eErr == CE_None) diff --git a/frmts/hdf4/hdf4dataset.cpp b/frmts/hdf4/hdf4dataset.cpp index cdccaaa4d7c8..3b8126aeb79a 100644 --- a/frmts/hdf4/hdf4dataset.cpp +++ b/frmts/hdf4/hdf4dataset.cpp @@ -113,7 +113,7 @@ char *SPrintArray(GDALDataType eDataType, const void *paDataArray, int nValues, { switch (eDataType) { - case GDT_Byte: + case GDT_UInt8: snprintf(pszField, iFieldSize + 1, "%d%s", reinterpret_cast( const_cast(paDataArray))[i], @@ -180,7 +180,7 @@ GDALDataType HDF4Dataset::GetDataType(int32 iNumType) case DFNT_CHAR8: // The same as DFNT_CHAR case DFNT_UCHAR8: // The same as DFNT_UCHAR case DFNT_UINT8: - return GDT_Byte; + return GDT_UInt8; case DFNT_INT8: return GDT_Int8; case DFNT_INT16: diff --git a/frmts/hdf4/hdf4imagedataset.cpp b/frmts/hdf4/hdf4imagedataset.cpp index 8ce51816e0b9..6802603c0955 100644 --- a/frmts/hdf4/hdf4imagedataset.cpp +++ b/frmts/hdf4/hdf4imagedataset.cpp @@ -3854,7 +3854,7 @@ GDALDataset *HDF4ImageDataset::Create(const char *pszFilename, int nXSize, return DFNT_INT32; case GDT_Int16: return DFNT_INT16; - case GDT_Byte: + case GDT_UInt8: return DFNT_UINT8; case GDT_Int8: return DFNT_INT8; diff --git a/frmts/hdf4/hdf4multidim.cpp b/frmts/hdf4/hdf4multidim.cpp index a6dae444c55d..15b5a646d364 100644 --- a/frmts/hdf4/hdf4multidim.cpp +++ b/frmts/hdf4/hdf4multidim.cpp @@ -979,7 +979,7 @@ class HDF4GRPalette final : public GDALAttribute std::shared_ptr m_poShared; std::shared_ptr m_poGRHandle; std::vector> m_dims{}; - GDALExtendedDataType m_dt = GDALExtendedDataType::Create(GDT_Byte); + GDALExtendedDataType m_dt = GDALExtendedDataType::Create(GDT_UInt8); int32 m_iPal = 0; int32 m_nValues = 0; @@ -3191,7 +3191,7 @@ bool HDF4GRPalette::IRead(const GUInt64 *arrayStartIdx, const size_t *count, GByte *pabyDstBuffer = static_cast(pDstBuffer); const size_t nBufferDataTypeSize = bufferDataType.GetSize(); - const auto srcDt(GDALExtendedDataType::Create(GDT_Byte)); + const auto srcDt(GDALExtendedDataType::Create(GDT_UInt8)); for (size_t i = 0; i < count[0]; ++i) { size_t idx = static_cast(arrayStartIdx[0] + i * arrayStep[0]); diff --git a/frmts/hdf5/bagdataset.cpp b/frmts/hdf5/bagdataset.cpp index 20d0842aaf12..14da06a44258 100644 --- a/frmts/hdf5/bagdataset.cpp +++ b/frmts/hdf5/bagdataset.cpp @@ -1052,7 +1052,7 @@ BAGResampledBand::BAGResampledBand(BAGDataset *poDSIn, int nBandIn, nBlockYSize = std::min(nBlockSize, poDS->GetRasterYSize()); if (poDSIn->m_bMask) { - eDataType = GDT_Byte; + eDataType = GDT_UInt8; } else if (poDSIn->m_ePopulation == BAGDataset::Population::COUNT) { @@ -2288,7 +2288,7 @@ BAGGeorefMDBand::BAGGeorefMDBand(const std::shared_ptr &poValues, } else { - eDataType = GDT_Byte; + eDataType = GDT_UInt8; m_poElevBand->GetBlockSize(&nBlockXSize, &nBlockYSize); } @@ -2399,7 +2399,7 @@ BAGGeorefMDSuperGridBand::BAGGeorefMDSuperGridBand( } else { - eDataType = GDT_Byte; + eDataType = GDT_UInt8; m_poElevBand->GetBlockSize(&nBlockXSize, &nBlockYSize); } } diff --git a/frmts/hdf5/gh5_convenience.cpp b/frmts/hdf5/gh5_convenience.cpp index 5ab0e1309595..8cbec97f74aa 100644 --- a/frmts/hdf5/gh5_convenience.cpp +++ b/frmts/hdf5/gh5_convenience.cpp @@ -242,11 +242,11 @@ bool GH5_FetchAttribute(hid_t loc_id, const char *pszAttrName, double &dfResult, GDALDataType GH5_GetDataType(hid_t TypeID) { if (H5Tequal(H5T_NATIVE_CHAR, TypeID)) - return GDT_Byte; + return GDT_UInt8; else if (H5Tequal(H5T_NATIVE_SCHAR, TypeID)) return GDT_Int8; else if (H5Tequal(H5T_NATIVE_UCHAR, TypeID)) - return GDT_Byte; + return GDT_UInt8; else if (H5Tequal(H5T_NATIVE_SHORT, TypeID)) return GDT_Int16; else if (H5Tequal(H5T_NATIVE_USHORT, TypeID)) diff --git a/frmts/hdf5/hdf5dataset.cpp b/frmts/hdf5/hdf5dataset.cpp index acbc479fdcca..c08eb413e3db 100644 --- a/frmts/hdf5/hdf5dataset.cpp +++ b/frmts/hdf5/hdf5dataset.cpp @@ -165,7 +165,7 @@ GDALDataType HDF5Dataset::GetDataType(hid_t TypeID) return GDT_Int8; else if (H5Tequal(H5T_NATIVE_CHAR, TypeID) || H5Tequal(H5T_NATIVE_UCHAR, TypeID)) - return GDT_Byte; + return GDT_UInt8; else if (H5Tequal(H5T_NATIVE_SHORT, TypeID)) return GDT_Int16; else if (H5Tequal(H5T_NATIVE_USHORT, TypeID)) diff --git a/frmts/hdf5/hdf5multidim.cpp b/frmts/hdf5/hdf5multidim.cpp index 420a78255cfb..001a93e3c29c 100644 --- a/frmts/hdf5/hdf5multidim.cpp +++ b/frmts/hdf5/hdf5multidim.cpp @@ -1247,7 +1247,7 @@ HDF5Array::HDF5Array(const std::string &osParentName, const std::string &osName, m_dt.GetComponents()[0]->GetType().GetNumericDataType() == GDT_Float32 && // In theory should be Byte, but 104US00_ches_dcf2_20190606T12Z.h5 uses Int32 - (m_dt.GetComponents()[1]->GetType().GetNumericDataType() == GDT_Byte || + (m_dt.GetComponents()[1]->GetType().GetNumericDataType() == GDT_UInt8 || m_dt.GetComponents()[1]->GetType().GetNumericDataType() == GDT_Int32)) { m_abyNoData.resize(m_dt.GetSize()); @@ -2505,7 +2505,7 @@ GetHDF5DataTypeFromGDALDataType(const GDALExtendedDataType &dt, hid_t hNativeDT, hid_t hBufferType = H5I_INVALID_HID; switch (bufferDataType.GetNumericDataType()) { - case GDT_Byte: + case GDT_UInt8: hBufferType = H5Tcopy(H5T_NATIVE_UCHAR); break; case GDT_Int8: diff --git a/frmts/hdf5/s104dataset.cpp b/frmts/hdf5/s104dataset.cpp index 53d6ab63d7e1..96ad57ebb7a2 100644 --- a/frmts/hdf5/s104dataset.cpp +++ b/frmts/hdf5/s104dataset.cpp @@ -457,7 +457,7 @@ GDALDataset *S104Dataset::Open(GDALOpenInfo *poOpenInfo) oComponents[0]->GetName() != "waterLevelHeight" || oComponents[0]->GetType().GetNumericDataType() != GDT_Float32 || oComponents[1]->GetName() != "waterLevelTrend" || - (oComponents[1]->GetType().GetNumericDataType() != GDT_Byte && + (oComponents[1]->GetType().GetNumericDataType() != GDT_UInt8 && // In theory should be Byte, but 104US00_ches_dcf2_20190606T12Z.h5 uses Int32 oComponents[1]->GetType().GetNumericDataType() != GDT_Int32)) { diff --git a/frmts/heif/heifdataset.cpp b/frmts/heif/heifdataset.cpp index 8122842a2e2f..c095ea212585 100644 --- a/frmts/heif/heifdataset.cpp +++ b/frmts/heif/heifdataset.cpp @@ -827,7 +827,7 @@ GDALHEIFRasterBand::GDALHEIFRasterBand(GDALHEIFDataset *poDSIn, int nBandIn) poDS = poDSIn; nBand = nBandIn; - eDataType = GDT_Byte; + eDataType = GDT_UInt8; #if LIBHEIF_NUMERIC_VERSION >= BUILD_LIBHEIF_VERSION(1, 4, 0) const int nBits = heif_image_handle_get_luma_bits_per_pixel(poDSIn->m_hImageHandle); @@ -890,7 +890,7 @@ CPLErr GDALHEIFRasterBand::IReadBlock(int nBlockXOff, int nBlockYOff, int nStride = 0; const uint8_t *pSrcData = heif_image_get_plane_readonly( hImage, heif_channel_interleaved, &nStride); - if (eDataType == GDT_Byte) + if (eDataType == GDT_UInt8) { for (int y = 0; y < nBlockYSize; y++) { @@ -975,7 +975,7 @@ CPLErr GDALHEIFRasterBand::IReadBlock(int, int nBlockYOff, void *pImage) const uint8_t *pSrcData = heif_image_get_plane_readonly( poGDS->m_hImage, heif_channel_interleaved, &nStride); pSrcData += static_cast(nBlockYOff) * nStride; - if (eDataType == GDT_Byte) + if (eDataType == GDT_UInt8) { for (int i = 0; i < nBlockXSize; i++) (static_cast(pImage))[i] = diff --git a/frmts/heif/heifdatasetcreatecopy.cpp b/frmts/heif/heifdatasetcreatecopy.cpp index ae3e7a6d59c0..99cb0c2fffe9 100644 --- a/frmts/heif/heifdatasetcreatecopy.cpp +++ b/frmts/heif/heifdatasetcreatecopy.cpp @@ -188,7 +188,7 @@ GDALHEIFDataset::CreateCopy(const char *pszFilename, GDALDataset *poSrcDS, int, for (auto &&poBand : poSrcDS->GetBands()) { - if (poBand->GetRasterDataType() != GDT_Byte) + if (poBand->GetRasterDataType() != GDT_UInt8) { heif_image_release(image); heif_encoder_release(encoder); @@ -223,7 +223,7 @@ GDALHEIFDataset::CreateCopy(const char *pszFilename, GDALDataset *poSrcDS, int, uint8_t *p = heif_image_get_plane(image, channel, &stride); auto eErr = poBand->RasterIO( GF_Read, 0, 0, poSrcDS->GetRasterXSize(), poSrcDS->GetRasterYSize(), - p, poSrcDS->GetRasterXSize(), poSrcDS->GetRasterYSize(), GDT_Byte, + p, poSrcDS->GetRasterXSize(), poSrcDS->GetRasterYSize(), GDT_UInt8, 0, stride, nullptr); if (eErr != CE_None) diff --git a/frmts/hf2/hf2dataset.cpp b/frmts/hf2/hf2dataset.cpp index 3904339b98f0..4229d7bb30aa 100644 --- a/frmts/hf2/hf2dataset.cpp +++ b/frmts/hf2/hf2dataset.cpp @@ -765,7 +765,7 @@ GDALDataset *HF2Dataset::CreateCopy(const char *pszFilename, GDALDataType eSrcDT = poSrcDS->GetRasterBand(1)->GetRasterDataType(); GDALDataType eReqDT; float fVertPres = (float)0.01; - if (eSrcDT == GDT_Byte || eSrcDT == GDT_Int16) + if (eSrcDT == GDT_UInt8 || eSrcDT == GDT_Int16) { fVertPres = 1; eReqDT = GDT_Int16; diff --git a/frmts/hfa/hfadataset.cpp b/frmts/hfa/hfadataset.cpp index 2704a110afc7..73c7d9cd2411 100644 --- a/frmts/hfa/hfadataset.cpp +++ b/frmts/hfa/hfadataset.cpp @@ -1906,7 +1906,7 @@ HFARasterBand::HFARasterBand(HFADataset *poDSIn, int nBandIn, int iOverview) case EPT_u2: case EPT_u4: case EPT_u8: - eDataType = GDT_Byte; + eDataType = GDT_UInt8; break; case EPT_s8: @@ -1946,7 +1946,7 @@ HFARasterBand::HFARasterBand(HFADataset *poDSIn, int nBandIn, int iOverview) break; default: - eDataType = GDT_Byte; + eDataType = GDT_UInt8; // This should really report an error, but this isn't // so easy from within constructors. CPLDebug("GDAL", "Unsupported pixel type in HFARasterBand: %d.", @@ -5007,7 +5007,7 @@ GDALDataset *HFADataset::Create(const char *pszFilenameIn, int nXSize, EPTType eHfaDataType; switch (eType) { - case GDT_Byte: + case GDT_UInt8: if (nBits == 1) eHfaDataType = EPT_u1; else if (nBits == 2) @@ -5229,7 +5229,7 @@ GDALDataset *HFADataset::CreateCopy(const char *pszFilename, // If we have PIXELTYPE metadata in the source, pass it // through as a creation option. if (CSLFetchNameValue(papszOptions, "PIXELTYPE") == nullptr && - nBandCount > 0 && eType == GDT_Byte) + nBandCount > 0 && eType == GDT_UInt8) { auto poSrcBand = poSrcDS->GetRasterBand(1); poSrcBand->EnablePixelTypeSignedByteWarning(false); diff --git a/frmts/idrisi/IdrisiDataset.cpp b/frmts/idrisi/IdrisiDataset.cpp index a80b0d3d2827..254ef4dd0917 100644 --- a/frmts/idrisi/IdrisiDataset.cpp +++ b/frmts/idrisi/IdrisiDataset.cpp @@ -623,7 +623,7 @@ GDALDataset *IdrisiDataset::Open(GDALOpenInfo *poOpenInfo) if (EQUAL(pszDataType, rstBYTE)) { poDS->nBands = 1; - poDS->SetBand(1, new IdrisiRasterBand(poDS, 1, GDT_Byte)); + poDS->SetBand(1, new IdrisiRasterBand(poDS, 1, GDT_UInt8)); } else if (EQUAL(pszDataType, rstINTEGER)) { @@ -638,9 +638,9 @@ GDALDataset *IdrisiDataset::Open(GDALOpenInfo *poOpenInfo) else if (EQUAL(pszDataType, rstRGB24)) { poDS->nBands = 3; - poDS->SetBand(1, new IdrisiRasterBand(poDS, 1, GDT_Byte)); - poDS->SetBand(2, new IdrisiRasterBand(poDS, 2, GDT_Byte)); - poDS->SetBand(3, new IdrisiRasterBand(poDS, 3, GDT_Byte)); + poDS->SetBand(1, new IdrisiRasterBand(poDS, 1, GDT_UInt8)); + poDS->SetBand(2, new IdrisiRasterBand(poDS, 2, GDT_UInt8)); + poDS->SetBand(3, new IdrisiRasterBand(poDS, 3, GDT_UInt8)); } else { @@ -863,7 +863,7 @@ GDALDataset *IdrisiDataset::Create(const char *pszFilename, int nXSize, return nullptr; } - if (nBandsIn == 3 && eType != GDT_Byte) + if (nBandsIn == 3 && eType != GDT_UInt8) { CPLError( CE_Failure, CPLE_AppDefined, @@ -881,7 +881,7 @@ GDALDataset *IdrisiDataset::Create(const char *pszFilename, int nXSize, switch (eType) { - case GDT_Byte: + case GDT_UInt8: if (nBandsIn == 1) pszLDataType = rstBYTE; else @@ -1020,9 +1020,9 @@ GDALDataset *IdrisiDataset::CreateCopy(const char *pszFilename, return nullptr; } if ((poSrcDS->GetRasterCount() == 3) && - ((poSrcDS->GetRasterBand(1)->GetRasterDataType() != GDT_Byte) || - (poSrcDS->GetRasterBand(2)->GetRasterDataType() != GDT_Byte) || - (poSrcDS->GetRasterBand(3)->GetRasterDataType() != GDT_Byte))) + ((poSrcDS->GetRasterBand(1)->GetRasterDataType() != GDT_UInt8) || + (poSrcDS->GetRasterBand(2)->GetRasterDataType() != GDT_UInt8) || + (poSrcDS->GetRasterBand(3)->GetRasterDataType() != GDT_UInt8))) { CPLError( CE_Failure, CPLE_AppDefined, @@ -1042,7 +1042,8 @@ GDALDataset *IdrisiDataset::CreateCopy(const char *pszFilename, if (bStrict) { - if (eType != GDT_Byte && eType != GDT_Int16 && eType != GDT_Float32) + if (eType != GDT_UInt8 && eType != GDT_Int16 && + eType != GDT_Float32) { CPLError(CE_Failure, CPLE_AppDefined, "Attempt to create IDRISI dataset in strict mode " @@ -1053,7 +1054,7 @@ GDALDataset *IdrisiDataset::CreateCopy(const char *pszFilename, } else { - if (eType != GDT_Byte && eType != GDT_Int16 && + if (eType != GDT_UInt8 && eType != GDT_Int16 && eType != GDT_UInt16 && eType != GDT_UInt32 && eType != GDT_Int32 && eType != GDT_Float32 && eType != GDT_Float64) @@ -1085,7 +1086,7 @@ GDALDataset *IdrisiDataset::CreateCopy(const char *pszFilename, poBand->GetStatistics(false, true, &dfMin, &dfMax, nullptr, nullptr); } - if (!((eType == GDT_Byte) || (eType == GDT_Int16) || + if (!((eType == GDT_UInt8) || (eType == GDT_Int16) || (eType == GDT_Float32))) { if (eType == GDT_Float64) diff --git a/frmts/ilwis/ilwisdataset.cpp b/frmts/ilwis/ilwisdataset.cpp index 328d80134b70..ed030e980f85 100644 --- a/frmts/ilwis/ilwisdataset.cpp +++ b/frmts/ilwis/ilwisdataset.cpp @@ -346,7 +346,7 @@ static GDALDataType ILWIS2GDALType(ilwisStoreType stStoreType) { case stByte: { - eDataType = GDT_Byte; + eDataType = GDT_UInt8; break; } case stInt: @@ -384,7 +384,7 @@ static std::string GDALType2ILWIS(GDALDataType type) std::string sStoreType = ""; switch (type) { - case GDT_Byte: + case GDT_UInt8: { sStoreType = "Byte"; break; @@ -891,7 +891,7 @@ GDALDataset *ILWISDataset::Create(const char *pszFilename, int nXSize, /* -------------------------------------------------------------------- */ /* Verify input options. */ /* -------------------------------------------------------------------- */ - if (eType != GDT_Byte && eType != GDT_Int16 && eType != GDT_Int32 && + if (eType != GDT_UInt8 && eType != GDT_Int16 && eType != GDT_Int32 && eType != GDT_Float32 && eType != GDT_Float64 && eType != GDT_UInt16 && eType != GDT_UInt32) { @@ -1338,7 +1338,7 @@ ILWISRasterBand::ILWISRasterBand(ILWISDataset *poDSIn, int nBandIn, if (poDSIn->bNewDataset) { // Called from Create(): - // eDataType is defaulted to GDT_Byte by GDALRasterBand::GDALRasterBand + // eDataType is defaulted to GDT_UInt8 by GDALRasterBand::GDALRasterBand // Here we set it to match the value of sStoreType (that was set in // ILWISDataset::Create) Unfortunately we can't take advantage of the // ILWIS "ValueRange" object that would use the most compact storeType @@ -1356,7 +1356,7 @@ ILWISRasterBand::ILWISRasterBand(ILWISDataset *poDSIn, int nBandIn, switch (psInfo.stStoreType) { case stByte: - nSizePerPixel = GDALGetDataTypeSizeBytes(GDT_Byte); + nSizePerPixel = GDALGetDataTypeSizeBytes(GDT_UInt8); break; case stInt: nSizePerPixel = GDALGetDataTypeSizeBytes(GDT_Int16); @@ -1422,7 +1422,7 @@ void ILWISRasterBand::ReadValueDomainProperties(const std::string &pszFileName) rStep - (int)rStep == 0.0) // Integer values { if (rMin >= 0 && rMax <= UCHAR_MAX) - eDataType = GDT_Byte; + eDataType = GDT_UInt8; else if (rMin >= SHRT_MIN && rMax <= SHRT_MAX) eDataType = GDT_Int16; else if (rMin >= 0 && rMax <= USHRT_MAX) @@ -1505,7 +1505,7 @@ CPLErr ILWISRasterBand::GetILWISInfo(const std::string &pszFileName) EQUAL(osBaseName.c_str(), "hortonratio") || EQUAL(osBaseName.c_str(), "yesno")) { - eDataType = GDT_Byte; + eDataType = GDT_UInt8; if (EQUAL(osBaseName.c_str(), "image") || EQUAL(osBaseName.c_str(), "colorcmp")) psInfo.stDomain = std::move(osBaseName); @@ -1681,7 +1681,7 @@ void ILWISRasterBand::SetValue(void *pImage, int i, double rV) { switch (eDataType) { - case GDT_Byte: + case GDT_UInt8: ((GByte *)pImage)[i] = (GByte)rV; break; case GDT_UInt16: @@ -1712,7 +1712,7 @@ double ILWISRasterBand::GetValue(void *pImage, int i) double rV = 0; // Does GDAL have an official nodata value? switch (eDataType) { - case GDT_Byte: + case GDT_UInt8: rV = ((GByte *)pImage)[i]; break; case GDT_UInt16: diff --git a/frmts/jp2kak/jp2kakdataset.cpp b/frmts/jp2kak/jp2kakdataset.cpp index 315595347906..daa06fccfef3 100644 --- a/frmts/jp2kak/jp2kakdataset.cpp +++ b/frmts/jp2kak/jp2kakdataset.cpp @@ -82,7 +82,7 @@ JP2KAKRasterBand::JP2KAKRasterBand(int nBandIn, kdu_codestream oCodeStreamIn, !oCodeStream.get_signed(nBand - 1)) eDataType = GDT_UInt32; else - eDataType = GDT_Byte; + eDataType = GDT_UInt8; oCodeStream.apply_input_restrictions(0, 0, poBaseDSIn->m_nDiscardLevels, 0, nullptr); @@ -1240,7 +1240,7 @@ CPLErr JP2KAKDataset::DirectRasterIO( nBandSpace, psExtraArg); } - CPLAssert(eBufType == GDT_Byte || eBufType == GDT_Int16 || + CPLAssert(eBufType == GDT_UInt8 || eBufType == GDT_Int16 || eBufType == GDT_UInt16 || eBufType == GDT_Int32 || eBufType == GDT_UInt32); @@ -1370,7 +1370,7 @@ CPLErr JP2KAKDataset::DirectRasterIO( row_gaps[i] = static_cast(nLineSpace) / nBufDTSize; } - if (eBufType == GDT_Byte) + if (eBufType == GDT_UInt8) decompressor.pull_stripe(static_cast(pData), &stripe_heights[0], &sample_offsets[0], &sample_gaps[0], &row_gaps[0], @@ -1420,7 +1420,7 @@ CPLErr JP2KAKDataset::DirectRasterIO( } } - if (eBufType == GDT_Byte) + if (eBufType == GDT_UInt8) decompressor.pull_stripe( reinterpret_cast(pabyIntermediate), &stripe_heights[0], nullptr, nullptr, nullptr, @@ -1459,7 +1459,7 @@ CPLErr JP2KAKDataset::DirectRasterIO( for (int i = 0; i < nBandCount; i++) { // TODO(schwehr): Cleanup this block. - if (eBufType == GDT_Byte) + if (eBufType == GDT_UInt8) static_cast( pData)[iX * nPixelSpace + iY * nLineSpace + i * nBandSpace] = pabyIntermediate @@ -1541,7 +1541,7 @@ bool JP2KAKDataset::TestUseBlockIO(int nXSize, int nYSize, int nBufXSize, { if (eDataType != GetRasterBand(1)->GetRasterDataType() || - (eDataType != GDT_Byte && eDataType != GDT_Int16 && + (eDataType != GDT_UInt8 && eDataType != GDT_Int16 && eDataType != GDT_UInt16 && eDataType != GDT_Int32 && eDataType != GDT_UInt32)) return true; @@ -1713,7 +1713,7 @@ static bool JP2KAKCreateCopy_WriteTile( anCurLine[c]++; const bool bIsAbsolute = apoLines[c]->is_absolute(); - if (eType == GDT_Byte) + if (eType == GDT_UInt8) { const kdu_byte *sp = static_cast(pabyBuffer); const kdu_int16 nOffset = 1 << (nBits - 1); @@ -2051,7 +2051,7 @@ static GDALDataset *JP2KAKCreateCopy(const char *pszFilename, GDALRasterBand *poPrototypeBand = poSrcDS->GetRasterBand(1); GDALDataType eType = poPrototypeBand->GetRasterDataType(); - if (eType != GDT_Byte && eType != GDT_Int16 && eType != GDT_UInt16 && + if (eType != GDT_UInt8 && eType != GDT_Int16 && eType != GDT_UInt16 && eType != GDT_Int32 && eType != GDT_UInt32 && eType != GDT_Float32) { if (bStrict) @@ -2931,7 +2931,7 @@ static GDALDataset *JP2KAKCreateCopy(const char *pszFilename, break; } - if (eType == GDT_Byte) + if (eType == GDT_UInt8) compressor.push_stripe(stripe_bufs.data(), stripe_heights.data(), /*const int *sample_gaps=*/nullptr, diff --git a/frmts/jpeg/jpgdataset.cpp b/frmts/jpeg/jpgdataset.cpp index 3b5c6913f639..2b2d5d0db4bc 100644 --- a/frmts/jpeg/jpgdataset.cpp +++ b/frmts/jpeg/jpgdataset.cpp @@ -1512,7 +1512,7 @@ JPGMaskBand::JPGMaskBand(JPGDatasetCommon *poDSIn) nRasterXSize = poDS->GetRasterXSize(); nRasterYSize = poDS->GetRasterYSize(); - eDataType = GDT_Byte; + eDataType = GDT_UInt8; nBlockXSize = nRasterXSize; nBlockYSize = 1; } @@ -1574,7 +1574,7 @@ JPGRasterBand::JPGRasterBand(JPGDatasetCommon *poDSIn, int nBandIn) if (poDSIn->GetDataPrecision() == 12) eDataType = GDT_UInt16; else - eDataType = GDT_Byte; + eDataType = GDT_UInt8; nBlockXSize = poDSIn->nRasterXSize; nBlockYSize = 1; @@ -1633,7 +1633,7 @@ CPLErr JPGRasterBand::IReadBlock(int nBlockXOff, int nBlockYOff, void *pImage) pImage, eDataType, nWordSize, nXSize); #else if (poGDS->eGDALColorSpace == JCS_RGB && - poGDS->GetOutColorSpace() == JCS_CMYK && eDataType == GDT_Byte) + poGDS->GetOutColorSpace() == JCS_CMYK && eDataType == GDT_UInt8) { GByte *const pbyImage = static_cast(pImage); if (nBand == 1) @@ -2833,7 +2833,7 @@ CPLErr JPGDatasetCommon::IRasterIO( if ((eRWFlag == GF_Read) && (nBandCount == 3) && (nBands == 3) && (nXOff == 0) && (nYOff == 0) && (nXSize == nBufXSize) && (nXSize == nRasterXSize) && (nYSize == nBufYSize) && - (nYSize == nRasterYSize) && (eBufType == GDT_Byte) && + (nYSize == nRasterYSize) && (eBufType == GDT_UInt8) && (GetDataPrecision() != 12) && (pData != nullptr) && IsAllBands(nBandCount, panBandMap) && // These color spaces need to be transformed to RGB. @@ -4058,7 +4058,7 @@ CPLErr JPGAppendMask(const char *pszJPGFilename, GDALRasterBand *poMask, for (int iY = 0; eErr == CE_None && iY < nYSize; iY++) { eErr = poMask->RasterIO(GF_Read, 0, iY, nXSize, 1, pabyMaskLine, nXSize, - 1, GDT_Byte, 0, 0, nullptr); + 1, GDT_UInt8, 0, 0, nullptr); if (eErr != CE_None) break; @@ -4651,7 +4651,7 @@ GDALDataset *JPGDataset::CreateCopy(const char *pszFilename, GDALDataType eDT = poSrcDS->GetRasterBand(1)->GetRasterDataType(); #if defined(JPEG_LIB_MK1_OR_12BIT) || defined(JPEG_DUAL_MODE_8_12) - if (eDT != GDT_Byte && eDT != GDT_UInt16) + if (eDT != GDT_UInt8 && eDT != GDT_UInt16) { CPLError(bStrict ? CE_Failure : CE_Warning, CPLE_NotSupported, "JPEG driver doesn't support data type %s. " @@ -4675,11 +4675,11 @@ GDALDataset *JPGDataset::CreateCopy(const char *pszFilename, } else { - eDT = GDT_Byte; + eDT = GDT_UInt8; } #else // !(defined(JPEG_LIB_MK1_OR_12BIT) || defined(JPEG_DUAL_MODE_8_12)) - if (eDT != GDT_Byte) + if (eDT != GDT_UInt8) { CPLError(bStrict ? CE_Failure : CE_Warning, CPLE_NotSupported, "JPEG driver doesn't support data type %s. " @@ -4691,7 +4691,7 @@ GDALDataset *JPGDataset::CreateCopy(const char *pszFilename, return nullptr; } - eDT = GDT_Byte; // force to 8bit. + eDT = GDT_UInt8; // force to 8bit. #endif // !(defined(JPEG_LIB_MK1_OR_12BIT) || defined(JPEG_DUAL_MODE_8_12)) // What options has the caller selected? diff --git a/frmts/jpegxl/jpegxl.cpp b/frmts/jpegxl/jpegxl.cpp index adc89c40301e..333482fa638f 100644 --- a/frmts/jpegxl/jpegxl.cpp +++ b/frmts/jpegxl/jpegxl.cpp @@ -174,7 +174,7 @@ JPEGXLRasterBand::JPEGXLRasterBand(JPEGXLDataset *poDSIn, int nBandIn, nBlockXSize = poDS->GetRasterXSize(); nBlockYSize = 1; SetColorInterpretation(eInterp); - if ((eDataType == GDT_Byte && nBitsPerSample < 8) || + if ((eDataType == GDT_UInt8 && nBitsPerSample < 8) || (eDataType == GDT_UInt16 && nBitsPerSample < 16)) { SetMetadataItem("NBITS", CPLSPrintf("%d", nBitsPerSample), @@ -495,7 +495,7 @@ bool JPEGXLDataset::Open(GDALOpenInfo *poOpenInfo) if (info.exponent_bits_per_sample == 0) { if (info.bits_per_sample <= 8) - eDT = GDT_Byte; + eDT = GDT_UInt8; else if (info.bits_per_sample <= 16) eDT = GDT_UInt16; } @@ -607,7 +607,7 @@ bool JPEGXLDataset::Open(GDALOpenInfo *poOpenInfo) #ifdef HAVE_JxlDecoderDefaultPixelFormat JxlPixelFormat format = { static_cast(nBands), - eDT == GDT_Byte ? JXL_TYPE_UINT8 + eDT == GDT_UInt8 ? JXL_TYPE_UINT8 : eDT == GDT_UInt16 ? JXL_TYPE_UINT16 : JXL_TYPE_FLOAT, JXL_NATIVE_ENDIAN, 0 /* alignment */ @@ -1429,7 +1429,7 @@ void JPEGXLDataset::GetDecodedImage(void *pabyOutputData, { JxlPixelFormat format = { static_cast(nBands - m_nNonAlphaExtraChannels), - eDT == GDT_Byte ? JXL_TYPE_UINT8 + eDT == GDT_UInt8 ? JXL_TYPE_UINT8 : eDT == GDT_UInt16 ? JXL_TYPE_UINT16 : JXL_TYPE_FLOAT, JXL_NATIVE_ENDIAN, 0 /* alignment */ @@ -1517,7 +1517,7 @@ void JPEGXLDataset::GetDecodedImage(void *pabyOutputData, const size_t nSamples = static_cast(nRasterXSize) * nRasterYSize * nChannels; const int nMaxVal = (1 << m_nBits) - 1; - if (eDT == GDT_Byte) + if (eDT == GDT_UInt8) { const int nHalfMaxWidth = 127; GByte *panData = static_cast(pBuffer); @@ -2097,7 +2097,7 @@ GDALDataset *JPEGXLDataset::CreateCopy(const char *pszFilename, const auto eDT = poSrcDS->GetRasterBand(1)->GetRasterDataType(); switch (eDT) { - case GDT_Byte: + case GDT_UInt8: format.data_type = JXL_TYPE_UINT8; break; case GDT_UInt16: @@ -2209,7 +2209,7 @@ GDALDataset *JPEGXLDataset::CreateCopy(const char *pszFilename, pszNBits = poSrcDS->GetRasterBand(1)->GetMetadataItem( "NBITS", "IMAGE_STRUCTURE"); const int nBits = - ((eDT == GDT_Byte || eDT == GDT_UInt16) && pszNBits != nullptr) + ((eDT == GDT_UInt8 || eDT == GDT_UInt16) && pszNBits != nullptr) ? atoi(pszNBits) : GDALGetDataTypeSizeBits(eDT); @@ -2874,7 +2874,7 @@ GDALDataset *JPEGXLDataset::CreateCopy(const char *pszFilename, const auto Rescale = [eDT, nBits, poSrcDS](void *pBuffer, int nChannels) { // Rescale to 8-bits/16-bits - if ((eDT == GDT_Byte && nBits < 8) || + if ((eDT == GDT_UInt8 && nBits < 8) || (eDT == GDT_UInt16 && nBits < 16)) { const size_t nSamples = @@ -2882,7 +2882,7 @@ GDALDataset *JPEGXLDataset::CreateCopy(const char *pszFilename, poSrcDS->GetRasterYSize() * nChannels; const int nMaxVal = (1 << nBits) - 1; const int nMavValHalf = nMaxVal / 2; - if (eDT == GDT_Byte) + if (eDT == GDT_UInt8) { uint8_t *panData = static_cast(pBuffer); for (size_t i = 0; i < nSamples; ++i) diff --git a/frmts/jpipkak/jpipkakdataset.cpp b/frmts/jpipkak/jpipkakdataset.cpp index d553351c58b1..f2134e6356fb 100644 --- a/frmts/jpipkak/jpipkakdataset.cpp +++ b/frmts/jpipkak/jpipkakdataset.cpp @@ -633,7 +633,7 @@ int JPIPKAKDataset::Initialize(const char *pszDatasetName, int bReinitializing) eDT = GDT_UInt16; } else - eDT = GDT_Byte; + eDT = GDT_UInt8; if ((poCodestream->get_bit_depth(0) % 8) != 0 && poCodestream->get_bit_depth(0) < 16) diff --git a/frmts/kea/keaband.cpp b/frmts/kea/keaband.cpp index a62c86acc0ed..927b940233d6 100644 --- a/frmts/kea/keaband.cpp +++ b/frmts/kea/keaband.cpp @@ -616,7 +616,7 @@ CPLErr KEARasterBand::SetNoDataValue(double dfNoData) GDALDataType dtype = this->GetRasterDataType(); switch (dtype) { - case GDT_Byte: + case GDT_UInt8: bSet = (dfNoData >= 0) && (dfNoData <= UCHAR_MAX); break; case GDT_UInt16: diff --git a/frmts/kea/keadataset.cpp b/frmts/kea/keadataset.cpp index b289c1dcba65..543a01f70ae9 100644 --- a/frmts/kea/keadataset.cpp +++ b/frmts/kea/keadataset.cpp @@ -36,7 +36,7 @@ GDALDataType KEA_to_GDAL_Type(kealib::KEADataType ekeaType) egdalType = GDT_Int8; break; case kealib::kea_8uint: - egdalType = GDT_Byte; + egdalType = GDT_UInt8; break; case kealib::kea_16int: egdalType = GDT_Int16; @@ -78,7 +78,7 @@ kealib::KEADataType GDAL_to_KEA_Type(GDALDataType egdalType) case GDT_Int8: ekeaType = kealib::kea_8int; break; - case GDT_Byte: + case GDT_UInt8: ekeaType = kealib::kea_8uint; break; case GDT_Int16: diff --git a/frmts/kea/keamaskband.cpp b/frmts/kea/keamaskband.cpp index 04a079503db5..0a6a88460b60 100644 --- a/frmts/kea/keamaskband.cpp +++ b/frmts/kea/keamaskband.cpp @@ -23,7 +23,7 @@ KEAMaskBand::KEAMaskBand(GDALRasterBand *pParent, kealib::KEAImageIO *pImageIO, nRasterXSize = pParent->GetXSize(); nRasterYSize = pParent->GetYSize(); - eDataType = GDT_Byte; + eDataType = GDT_UInt8; pParent->GetBlockSize(&nBlockXSize, &nBlockYSize); eAccess = pParent->GetAccess(); diff --git a/frmts/kmlsuperoverlay/kmlsuperoverlaydataset.cpp b/frmts/kmlsuperoverlay/kmlsuperoverlaydataset.cpp index d06da3e23270..3f33882177fa 100644 --- a/frmts/kmlsuperoverlay/kmlsuperoverlaydataset.cpp +++ b/frmts/kmlsuperoverlay/kmlsuperoverlaydataset.cpp @@ -50,14 +50,14 @@ static void GenerateTiles(const std::string &filename, CPL_UNUSED int zoom, bands = 3; auto poTmpDataset = std::unique_ptr( - MEMDataset::Create("", dxsize, dysize, bands, GDT_Byte, nullptr)); + MEMDataset::Create("", dxsize, dysize, bands, GDT_UInt8, nullptr)); if (!isJpegDriver) // Jpeg dataset only has one or three bands { if (bands < 4) // add transparency to files with one band or three // bands { - poTmpDataset->AddBand(GDT_Byte); + poTmpDataset->AddBand(GDT_UInt8); alphaBand = poTmpDataset->GetRasterBand(poTmpDataset->GetRasterCount()); } @@ -84,7 +84,7 @@ static void GenerateTiles(const std::string &filename, CPL_UNUSED int zoom, int yOffset = ry + row * rowOffset; CPLErr errTest = poBand->RasterIO( GF_Read, rx, yOffset, rxsize, rowOffset, abyScanline.data(), - dxsize, 1, GDT_Byte, 0, 0, nullptr); + dxsize, 1, GDT_UInt8, 0, 0, nullptr); const bool bReadFailed = (errTest == CE_Failure); if (bReadFailed) @@ -114,7 +114,7 @@ static void GenerateTiles(const std::string &filename, CPL_UNUSED int zoom, GDALRasterBand *poBandtmp = poTmpDataset->GetRasterBand(band); CPL_IGNORE_RET_VAL(poBandtmp->RasterIO( GF_Write, 0, row, dxsize, 1, abyScanline.data(), dxsize, 1, - GDT_Byte, 0, 0, nullptr)); + GDT_UInt8, 0, 0, nullptr)); } } @@ -137,7 +137,7 @@ static void GenerateTiles(const std::string &filename, CPL_UNUSED int zoom, CPL_IGNORE_RET_VAL(alphaBand->RasterIO( GF_Write, 0, row, dxsize, 1, abyScanline.data(), dxsize, 1, - GDT_Byte, 0, 0, nullptr)); + GDT_UInt8, 0, 0, nullptr)); } } } @@ -485,7 +485,7 @@ int KmlSuperOverlayReadDataset::DetectTransparency(int rxsize, int rysize, int yOffset = ry + row * rowOffset; CPL_IGNORE_RET_VAL(poBand->RasterIO( GF_Read, rx, yOffset, rxsize, rowOffset, abyScanline.data(), - dxsize, 1, GDT_Byte, 0, 0, nullptr)); + dxsize, 1, GDT_UInt8, 0, 0, nullptr)); for (int i = 0; i < dxsize; i++) { if (abyScanline[i] == noDataValue) @@ -514,7 +514,7 @@ int KmlSuperOverlayReadDataset::DetectTransparency(int rxsize, int rysize, int yOffset = ry + row * rowOffset; CPL_IGNORE_RET_VAL(poBand->RasterIO( GF_Read, rx, yOffset, rxsize, rowOffset, abyScanline.data(), - dxsize, 1, GDT_Byte, 0, 0, nullptr)); + dxsize, 1, GDT_UInt8, 0, 0, nullptr)); for (int i = 0; i < dxsize; i++) { if (abyScanline[i] == 255) @@ -1091,7 +1091,7 @@ KmlSuperOverlayRasterBand::KmlSuperOverlayRasterBand( { nRasterXSize = poDSIn->nRasterXSize; nRasterYSize = poDSIn->nRasterYSize; - eDataType = GDT_Byte; + eDataType = GDT_UInt8; nBlockXSize = 256; nBlockYSize = 256; } @@ -1470,7 +1470,7 @@ CPLErr KmlSuperOverlayReadDataset::IRasterIO( for (int iBandIdx = 0; iBandIdx < 4; iBandIdx++) { - poVRTDS->AddBand(GDT_Byte, nullptr); + poVRTDS->AddBand(GDT_UInt8, nullptr); auto poVRTBand = static_cast( poVRTDS->GetRasterBand(iBandIdx + 1)); @@ -1574,7 +1574,7 @@ CPLErr KmlSuperOverlayReadDataset::IRasterIO( GByte nVal = (nBand == 4) ? 255 : 0; for (int j = 0; j < nBufYSize; j++) { - GDALCopyWords(&nVal, GDT_Byte, 0, + GDALCopyWords(&nVal, GDT_UInt8, 0, static_cast(pData) + j * nLineSpace + iBandIdx * nBandSpace, eBufType, static_cast(nPixelSpace), @@ -2132,7 +2132,7 @@ KmlSingleDocRasterRasterBand::KmlSingleDocRasterRasterBand( nBand = nBandIn; nBlockXSize = poDSIn->nTileSize; nBlockYSize = poDSIn->nTileSize; - eDataType = GDT_Byte; + eDataType = GDT_UInt8; } /************************************************************************/ @@ -2194,8 +2194,8 @@ CPLErr KmlSingleDocRasterRasterBand::IReadBlock(int nBlockXOff, int nBlockYOff, else { eErr = poImageDS->GetRasterBand(1)->RasterIO( - GF_Read, 0, 0, nXSize, nYSize, pImage, nXSize, nYSize, GDT_Byte, - 1, nBlockXSize, nullptr); + GF_Read, 0, 0, nXSize, nYSize, pImage, nXSize, nYSize, + GDT_UInt8, 1, nBlockXSize, nullptr); /* Expand color table */ if (eErr == CE_None && poColorTable != nullptr) @@ -2232,7 +2232,7 @@ CPLErr KmlSingleDocRasterRasterBand::IReadBlock(int nBlockXOff, int nBlockYOff, else if (nBand <= poImageDS->GetRasterCount()) { eErr = poImageDS->GetRasterBand(nBand)->RasterIO( - GF_Read, 0, 0, nXSize, nYSize, pImage, nXSize, nYSize, GDT_Byte, 1, + GF_Read, 0, 0, nXSize, nYSize, pImage, nXSize, nYSize, GDT_UInt8, 1, nBlockXSize, nullptr); } else if (nBand == 4 && poImageDS->GetRasterCount() == 3) @@ -2576,7 +2576,7 @@ GDALDataset *KmlSingleOverlayRasterDataset::Open(const char *pszFilename, poImageDS->GetRasterXSize(), poImageDS->GetRasterYSize()); for (int i = 1; i <= poImageDS->GetRasterCount(); ++i) { - poDS->AddBand(GDT_Byte, nullptr); + poDS->AddBand(GDT_UInt8, nullptr); auto poImageBand = poImageDS->GetRasterBand(i); auto poVRTBand = diff --git a/frmts/l1b/l1bdataset.cpp b/frmts/l1b/l1bdataset.cpp index 9d7b9789d240..06d202950b15 100644 --- a/frmts/l1b/l1bdataset.cpp +++ b/frmts/l1b/l1bdataset.cpp @@ -395,7 +395,7 @@ L1BMaskBand::L1BMaskBand(L1BDataset *poDSIn) poDSIn->eL1BFormat == L1B_NOAA15_NOHDR); poDS = poDSIn; - eDataType = GDT_Byte; + eDataType = GDT_UInt8; nRasterXSize = poDS->GetRasterXSize(); nRasterYSize = poDS->GetRasterYSize(); @@ -3091,7 +3091,7 @@ L1BCloudsRasterBand::L1BCloudsRasterBand(L1BCloudsDataset *poDSIn, int nBandIn) nBand = nBandIn; nRasterXSize = poDSIn->nRasterXSize; nRasterYSize = poDSIn->nRasterYSize; - eDataType = GDT_Byte; + eDataType = GDT_UInt8; nBlockXSize = nRasterXSize; nBlockYSize = 1; } diff --git a/frmts/libertiff/libertiffdataset.cpp b/frmts/libertiff/libertiffdataset.cpp index 6ca6a7d4b568..c727d3d680ad 100644 --- a/frmts/libertiff/libertiffdataset.cpp +++ b/frmts/libertiff/libertiffdataset.cpp @@ -1881,10 +1881,10 @@ GDALDataType LIBERTIFFDataset::ComputeGDALDataType() const m_image->planarConfiguration() == LIBERTIFF_NS::PlanarConfiguration::Separate)) { - eDT = GDT_Byte; + eDT = GDT_UInt8; } else if (m_image->bitsPerSample() == 8) - eDT = GDT_Byte; + eDT = GDT_UInt8; else if (m_image->bitsPerSample() == 16) eDT = GDT_UInt16; else if (m_image->bitsPerSample() == 32) @@ -2388,7 +2388,7 @@ bool LIBERTIFFDataset::Open(std::unique_ptr image) "IMAGE_STRUCTURE"); } - if (l_nBands == 1 && eDT == GDT_Byte) + if (l_nBands == 1 && eDT == GDT_UInt8) { poBand->ReadColorMap(); } @@ -2621,7 +2621,7 @@ bool LIBERTIFFDataset::Open(GDALOpenInfo *poOpenInfo) poMaskDS->GetRasterYSize() == poLastNonMaskDS->nRasterYSize && poMaskDS->GetRasterBand(1)->GetRasterDataType() == - GDT_Byte) + GDT_UInt8) { poMaskDS->m_bExpand1To255 = true; poLastNonMaskDS->m_poMaskDS = std::move(poMaskDS); diff --git a/frmts/mbtiles/mbtilesdataset.cpp b/frmts/mbtiles/mbtilesdataset.cpp index 668052c1c177..fdb16bc21585 100644 --- a/frmts/mbtiles/mbtilesdataset.cpp +++ b/frmts/mbtiles/mbtilesdataset.cpp @@ -2543,7 +2543,7 @@ static int MBTilesGetBandCountAndTileSize(bool bIsVSICURL, GDALDatasetH &hDS, if ((nBands != 1 && nBands != 2 && nBands != 3 && nBands != 4) || GDALGetRasterXSize(hDSTile) != GDALGetRasterYSize(hDSTile) || - GDALGetRasterDataType(GDALGetRasterBand(hDSTile, 1)) != GDT_Byte) + GDALGetRasterDataType(GDALGetRasterBand(hDSTile, 1)) != GDT_UInt8) { CPLError(CE_Failure, CPLE_NotSupported, "Unsupported tile characteristics"); @@ -2965,7 +2965,7 @@ bool MBTilesDataset::CreateInternal(const char *pszFilename, int nXSize, int nYSize, int nBandsIn, GDALDataType eDT, char **papszOptions) { - if (eDT != GDT_Byte) + if (eDT != GDT_UInt8) { CPLError(CE_Failure, CPLE_NotSupported, "Only Byte supported"); return false; @@ -3349,7 +3349,7 @@ GDALDataset *MBTilesDataset::CreateCopy(const char *pszFilename, } GDALDataset *poDS = Create(pszFilename, nXSize, nYSize, nTargetBands, - GDT_Byte, papszOptions); + GDT_UInt8, papszOptions); if (poDS == nullptr) { CSLDestroy(papszTO); @@ -3386,7 +3386,7 @@ GDALDataset *MBTilesDataset::CreateCopy(const char *pszFilename, GDALWarpOptions *psWO = GDALCreateWarpOptions(); psWO->papszWarpOptions = CSLSetNameValue(nullptr, "OPTIMIZE_SIZE", "YES"); - psWO->eWorkingDataType = GDT_Byte; + psWO->eWorkingDataType = GDT_UInt8; psWO->eResampleAlg = eResampleAlg; diff --git a/frmts/mem/memdataset.cpp b/frmts/mem/memdataset.cpp index e877be5a2908..01a541f10fec 100644 --- a/frmts/mem/memdataset.cpp +++ b/frmts/mem/memdataset.cpp @@ -519,7 +519,7 @@ CPLErr MEMRasterBand::CreateMaskBand(int nFlagsIn) nMaskFlags = nFlagsIn; auto poMemMaskBand = std::unique_ptr( - new MEMRasterBand(pabyMaskData, GDT_Byte, nRasterXSize, nRasterYSize, + new MEMRasterBand(pabyMaskData, GDT_UInt8, nRasterXSize, nRasterYSize, /* bOwnData= */ true)); poMemMaskBand->m_bIsMask = true; poMask.reset(std::move(poMemMaskBand)); @@ -1185,7 +1185,7 @@ std::unique_ptr MEMDataset::Clone(int nScopeFlags, { auto poMaskBand = std::unique_ptr(new MEMRasterBand( - poSrcMaskBand->pabyData, GDT_Byte, nRasterXSize, + poSrcMaskBand->pabyData, GDT_UInt8, nRasterXSize, nRasterYSize, /* bOwnData = */ false)); poMaskBand->m_bIsMask = true; poNewBand->poMask.reset(std::move(poMaskBand)); @@ -1277,7 +1277,7 @@ GDALDataset *MEMDataset::Open(GDALOpenInfo *poOpenInfo) } pszOption = CSLFetchNameValue(papszOptions, "DATATYPE"); - GDALDataType eType = GDT_Byte; + GDALDataType eType = GDT_UInt8; if (pszOption != nullptr) { if (atoi(pszOption) > 0 && atoi(pszOption) < GDT_TypeCount) diff --git a/frmts/miramon/miramon_rasterband.cpp b/frmts/miramon/miramon_rasterband.cpp index b61f0cbde26a..902993a7afc2 100644 --- a/frmts/miramon/miramon_rasterband.cpp +++ b/frmts/miramon/miramon_rasterband.cpp @@ -65,7 +65,7 @@ void MMRRasterBand::UpdateDataType() case MMDataType::DATATYPE_AND_COMPR_BIT: case MMDataType::DATATYPE_AND_COMPR_BYTE: case MMDataType::DATATYPE_AND_COMPR_BYTE_RLE: - eDataType = GDT_Byte; + eDataType = GDT_UInt8; break; case MMDataType::DATATYPE_AND_COMPR_UINTEGER: @@ -96,7 +96,7 @@ void MMRRasterBand::UpdateDataType() break; default: - eDataType = GDT_Byte; + eDataType = GDT_UInt8; // This should really report an error, but this isn't // so easy from within constructors. CPLDebug("GDAL", "Unsupported pixel type in MMRRasterBand: %d.", diff --git a/frmts/mrf/JPEG_band.cpp b/frmts/mrf/JPEG_band.cpp index b60426884b35..c09dc4bc8fa7 100644 --- a/frmts/mrf/JPEG_band.cpp +++ b/frmts/mrf/JPEG_band.cpp @@ -829,7 +829,7 @@ static size_t brunsli_fun_callback(void *out, const GByte *data, size_t size) CPLErr JPEG_Band::Decompress(buf_mgr &dst, buf_mgr &src) { #if defined(JPEG12_SUPPORTED) - if (GDT_Byte != img.dt) + if (GDT_UInt8 != img.dt) return codec.DecompressJPEG12(dst, src); #endif if (!isbrunsli(src)) @@ -862,7 +862,7 @@ CPLErr JPEG_Band::Decompress(buf_mgr &dst, buf_mgr &src) CPLErr JPEG_Band::Compress(buf_mgr &dst, buf_mgr &src) { #if defined(JPEG12_SUPPORTED) - if (GDT_Byte != img.dt) + if (GDT_UInt8 != img.dt) return codec.CompressJPEG12(dst, src); #endif #if !defined(BRUNSLI) @@ -902,9 +902,9 @@ JPEG_Band::JPEG_Band(MRFDataset *pDS, const ILImage &image, int b, int level) const int nbands = image.pagesize.c; // Check behavior on signed 16bit. Does the libjpeg sign extend? #if defined(JPEG12_SUPPORTED) - if (GDT_Byte != image.dt && GDT_UInt16 != image.dt) + if (GDT_UInt8 != image.dt && GDT_UInt16 != image.dt) #else - if (GDT_Byte != image.dt) + if (GDT_UInt8 != image.dt) #endif { CPLError(CE_Failure, CPLE_NotSupported, @@ -924,7 +924,7 @@ JPEG_Band::JPEG_Band(MRFDataset *pDS, const ILImage &image, int b, int level) codec.sameres = TRUE; } - if (GDT_Byte == image.dt) + if (GDT_UInt8 == image.dt) { codec.optimize = GetOptlist().FetchBoolean("OPTIMIZE", FALSE) != FALSE; codec.JFIF = GetOptlist().FetchBoolean("JFIF", FALSE) != FALSE; diff --git a/frmts/mrf/JPNG_band.cpp b/frmts/mrf/JPNG_band.cpp index 5d1fcad0a01c..f93e59028680 100644 --- a/frmts/mrf/JPNG_band.cpp +++ b/frmts/mrf/JPNG_band.cpp @@ -185,7 +185,7 @@ JPNG_Band::JPNG_Band(MRFDataset *pDS, const ILImage &image, int b, int level) : MRFRasterBand(pDS, image, b, level), rgb(FALSE), sameres(FALSE), optimize(false), JFIF(false) { // Check error conditions - if (image.dt != GDT_Byte) + if (image.dt != GDT_UInt8) { CPLError(CE_Failure, CPLE_NotSupported, "Data type not supported by MRF JPNG"); diff --git a/frmts/mrf/LERC_band.cpp b/frmts/mrf/LERC_band.cpp index 1d8408125059..368c6633d247 100644 --- a/frmts/mrf/LERC_band.cpp +++ b/frmts/mrf/LERC_band.cpp @@ -250,7 +250,7 @@ static CPLErr CompressLERC1(buf_mgr &dst, buf_mgr &src, const ILImage &img, Lerc1ImgFill(zImg, reinterpret_cast(src.buffer) + c, img, stride) switch (img.dt) { - case GDT_Byte: + case GDT_UInt8: FILL(GByte); break; case GDT_UInt16: @@ -325,7 +325,7 @@ static CPLErr DecompressLERC1(buf_mgr &dst, const buf_mgr &src, stride) switch (img.dt) { - case GDT_Byte: + case GDT_UInt8: UFILL(GByte); break; case GDT_Int8: @@ -393,7 +393,7 @@ static GDALDataType L2toGDT(L2NS::DataType L2type) dt = GDT_Int8; break; default: // Unsigned byte - dt = GDT_Byte; + dt = GDT_UInt8; } return dt; } @@ -504,7 +504,7 @@ static CPLErr CompressLERC2(buf_mgr &dst, buf_mgr &src, const ILImage &img, #define MASK(T) nndv = MaskFill(bm, reinterpret_cast(src.buffer), img) - case GDT_Byte: + case GDT_UInt8: MASK(GByte); break; case GDT_UInt16: @@ -606,7 +606,7 @@ CPLErr LERC_Band::Decompress(buf_mgr &dst, buf_mgr &src) switch (img.dt) { #define UNMASK(T) UnMask(bm, reinterpret_cast(dst.buffer), img) - case GDT_Byte: + case GDT_UInt8: UNMASK(GByte); break; case GDT_UInt16: diff --git a/frmts/mrf/PNG_band.cpp b/frmts/mrf/PNG_band.cpp index 4e890d3beefd..dc24c9a247b0 100644 --- a/frmts/mrf/PNG_band.cpp +++ b/frmts/mrf/PNG_band.cpp @@ -180,7 +180,7 @@ CPLErr PNG_Codec::DecompressPNG(buf_mgr &dst, buf_mgr &src) if (poDS->RasterIO( GF_Read, 0, 0, poDS->GetRasterXSize(), poDS->GetRasterYSize(), dst.buffer, poDS->GetRasterXSize(), - poDS->GetRasterYSize(), GDT_Byte, poDS->GetRasterCount(), + poDS->GetRasterYSize(), GDT_UInt8, poDS->GetRasterCount(), nullptr, poDS->GetRasterCount(), 0, 1, nullptr) == CE_None) { png_destroy_read_struct(&pngp, &infop, nullptr); @@ -334,7 +334,7 @@ CPLErr PNG_Codec::CompressPNG(buf_mgr &dst, const buf_mgr &src) png_write_info(pngp, infop); #if defined(CPL_LSB) - if (img.dt != GDT_Byte) + if (img.dt != GDT_UInt8) png_set_swap(pngp); #endif @@ -431,7 +431,8 @@ CPLErr PNG_Band::Compress(buf_mgr &dst, buf_mgr &src) PNG_Band::PNG_Band(MRFDataset *pDS, const ILImage &image, int b, int level) : MRFRasterBand(pDS, image, b, level), codec(image) { // Check error conditions - if (image.dt != GDT_Byte && image.dt != GDT_Int16 && image.dt != GDT_UInt16) + if (image.dt != GDT_UInt8 && image.dt != GDT_Int16 && + image.dt != GDT_UInt16) { CPLError(CE_Failure, CPLE_NotSupported, "Data type not supported by MRF PNG"); diff --git a/frmts/mrf/QB3_band.cpp b/frmts/mrf/QB3_band.cpp index e379db7348bd..a9df2ee5d909 100644 --- a/frmts/mrf/QB3_band.cpp +++ b/frmts/mrf/QB3_band.cpp @@ -28,7 +28,7 @@ CPLErr QB3_Band::Compress(buf_mgr &dst, buf_mgr &src) switch (img.dt) { - case (GDT_Byte): + case (GDT_UInt8): pQB3 = CREATE_QB3(QB3_U8); break; case (GDT_Int16): diff --git a/frmts/mrf/marfa_dataset.cpp b/frmts/mrf/marfa_dataset.cpp index f94247156b7e..de40f9e12d62 100644 --- a/frmts/mrf/marfa_dataset.cpp +++ b/frmts/mrf/marfa_dataset.cpp @@ -1306,7 +1306,7 @@ CPLXMLNode *MRFDataset::BuildConfig() CPLCreateXMLElementAndValue(raster, "Compression", CompName(full.comp)); } - if (full.dt != GDT_Byte) + if (full.dt != GDT_UInt8) CPLCreateXMLElementAndValue(raster, "DataType", GDALGetDataTypeName(full.dt)); @@ -1408,7 +1408,7 @@ CPLErr MRFDataset::Initialize(CPLXMLNode *config) { // We only need a basic initialization here, usually gets overwritten by the // image params - full.dt = GDT_Byte; + full.dt = GDT_UInt8; full.hasNoData = false; full.NoDataValue = 0; Quality = 85; @@ -2034,7 +2034,7 @@ CPLErr MRFDataset::ZenCopy(GDALDataset *poSrc, GDALProgressFunc pfnProgress, // Get the data mask as byte eErr = poSrcMask->RasterIO(GF_Read, col, row, nCols, nRows, - buffer_mask, nCols, nRows, GDT_Byte, 0, + buffer_mask, nCols, nRows, GDT_UInt8, 0, 0, nullptr); if (eErr != CE_None) @@ -2058,7 +2058,7 @@ CPLErr MRFDataset::ZenCopy(GDALDataset *poSrc, GDALProgressFunc pfnProgress, // valid switch (eDT) { - case GDT_Byte: + case GDT_UInt8: ZenFilter(reinterpret_cast(buffer), buffer_mask, nPixelCount, nBandCount, bFirstBandOnly); break; diff --git a/frmts/mrf/mrf_band.cpp b/frmts/mrf/mrf_band.cpp index 7ddec3d73a9b..0e5cf2778876 100644 --- a/frmts/mrf/mrf_band.cpp +++ b/frmts/mrf/mrf_band.cpp @@ -129,7 +129,7 @@ static int isAllVal(GDALDataType gt, void *b, size_t bytecount, double ndv) switch (gt) { - TEST_T(GDT_Byte, GByte); + TEST_T(GDT_UInt8, GByte); TEST_T(GDT_Int8, GInt8); TEST_T(GDT_UInt16, GUInt16); TEST_T(GDT_Int16, GInt16); @@ -577,7 +577,7 @@ CPLErr MRFRasterBand::FillBlock(void *buffer) size_t bsb = blockSizeBytes(); // use memset for speed for bytes, or if nodata is zeros - if (0.0 == ndv || eDataType == GDT_Byte || eDataType == GDT_Int8) + if (0.0 == ndv || eDataType == GDT_UInt8 || eDataType == GDT_Int8) { memset(buffer, int(ndv), bsb); return CE_None; diff --git a/frmts/mrf/mrf_overview.cpp b/frmts/mrf/mrf_overview.cpp index 3c9e6ff7d0a4..865f324fd00e 100644 --- a/frmts/mrf/mrf_overview.cpp +++ b/frmts/mrf/mrf_overview.cpp @@ -479,7 +479,7 @@ CPLErr MRFDataset::PatchOverview(int BlockX, int BlockY, int Width, int Height, switch (eDataType) { - case GDT_Byte: + case GDT_UInt8: resample(GByte); case GDT_Int8: resample(GInt8); @@ -524,7 +524,7 @@ CPLErr MRFDataset::PatchOverview(int BlockX, int BlockY, int Width, int Height, break; switch (eDataType) { - case GDT_Byte: + case GDT_UInt8: resample(GByte); case GDT_Int8: resample(GInt8); diff --git a/frmts/mrsid/mrsiddataset.cpp b/frmts/mrsid/mrsiddataset.cpp index 099c57633be2..acdadafd532c 100644 --- a/frmts/mrsid/mrsiddataset.cpp +++ b/frmts/mrsid/mrsiddataset.cpp @@ -735,7 +735,7 @@ GDALRasterBand *MrSIDRasterBand::GetOverview(int i) MrSIDDataset::MrSIDDataset(int bIsJPEG2000) : nBlockXSize(0), nBlockYSize(0), eSampleType(LTI_DATATYPE_UINT8), - eDataType(GDT_Byte), eColorSpace(LTI_COLORSPACE_INVALID) + eDataType(GDT_UInt8), eColorSpace(LTI_COLORSPACE_INVALID) { poStream = nullptr; poImageReader = nullptr; @@ -1257,7 +1257,7 @@ CPLErr MrSIDDataset::OpenZoomLevel(lt_int32 iZoom) case LTI_DATATYPE_UINT8: case LTI_DATATYPE_SINT8: default: - eDataType = GDT_Byte; + eDataType = GDT_UInt8; break; } @@ -3078,7 +3078,7 @@ LT_STATUS MrSIDDummyImageReader::initialize() case GDT_Float64: eSampleType = LTI_DATATYPE_FLOAT64; break; - case GDT_Byte: + case GDT_UInt8: default: eSampleType = LTI_DATATYPE_UINT8; break; diff --git a/frmts/msg/msgdataset.cpp b/frmts/msg/msgdataset.cpp index 814224dddcfe..e8a44abcabec 100644 --- a/frmts/msg/msgdataset.cpp +++ b/frmts/msg/msgdataset.cpp @@ -385,14 +385,14 @@ MSGRasterBand::MSGRasterBand(MSGDataset *poDSIn, int nBandIn) if (xhp.isValid()) { // Data type is either 8 or 16 bits .. we tell this to GDAL here - eDataType = GDT_Byte; // default .. always works + eDataType = GDT_UInt8; // default .. always works if (xhp.nrBitsPerPixel() > 8) { if (poDSIn->command.cDataConversion == 'N') eDataType = GDT_UInt16; // normal case: MSG 10 bits data else if (poDSIn->command.cDataConversion == 'B') - eDataType = GDT_Byte; // output data type Byte + eDataType = GDT_UInt8; // output data type Byte else eDataType = GDT_Float32; // Radiometric calibration } @@ -422,7 +422,7 @@ MSGRasterBand::MSGRasterBand(MSGDataset *poDSIn, int nBandIn) if (poDSIn->command.cDataConversion == 'N') eDataType = GDT_UInt16; // normal case: MSG 10 bits data else if (poDSIn->command.cDataConversion == 'B') - eDataType = GDT_Byte; // output data type Byte + eDataType = GDT_UInt8; // output data type Byte else eDataType = GDT_Float32; // Radiometric calibration @@ -604,7 +604,7 @@ CPLErr MSGRasterBand::IReadBlock(int /*nBlockXOff*/, int nBlockYOff, // cases: // combination of the following: // - scan direction can be north or south - // - eDataType can be GDT_Byte, GDT_UInt16 or GDT_Float32 + // - eDataType can be GDT_UInt8, GDT_UInt16 or GDT_Float32 // - nBlockXSize == chunk_width or nBlockXSize > chunk_width // - when nBlockXSize > chunk_width, fSplitStrip can be true or // false we won't distinguish the following cases: @@ -623,7 +623,7 @@ CPLErr MSGRasterBand::IReadBlock(int /*nBlockXOff*/, int nBlockYOff, } COMP::CImage cimg(img_uncompressed); // unpack - if (eDataType == GDT_Byte) + if (eDataType == GDT_UInt8) { if (nBlockXSize == chunk_width) // optimized version { diff --git a/frmts/netcdf/netcdfdataset.cpp b/frmts/netcdf/netcdfdataset.cpp index 785bfb4ef3c5..93a359b7827d 100644 --- a/frmts/netcdf/netcdfdataset.cpp +++ b/frmts/netcdf/netcdfdataset.cpp @@ -399,9 +399,9 @@ netCDFRasterBand::netCDFRasterBand(const netCDFRasterBand::CONSTRUCTOR_OPEN &, else { if (nc_datatype == NC_BYTE) - eDataType = GDT_Byte; + eDataType = GDT_UInt8; else if (nc_datatype == NC_CHAR) - eDataType = GDT_Byte; + eDataType = GDT_UInt8; else if (nc_datatype == NC_SHORT) eDataType = GDT_Int16; else if (nc_datatype == NC_INT) @@ -411,7 +411,7 @@ netCDFRasterBand::netCDFRasterBand(const netCDFRasterBand::CONSTRUCTOR_OPEN &, else if (nc_datatype == NC_DOUBLE) eDataType = GDT_Float64; else if (nc_datatype == NC_UBYTE) - eDataType = GDT_Byte; + eDataType = GDT_UInt8; else if (nc_datatype == NC_USHORT) eDataType = GDT_UInt16; else if (nc_datatype == NC_UINT) @@ -922,7 +922,7 @@ netCDFRasterBand::netCDFRasterBand( switch (eDataType) { - case GDT_Byte: + case GDT_UInt8: nc_datatype = NC_BYTE; // NC_UBYTE (unsigned byte) is only available for NC4. if (poNCDFDS->eFormat == NCDF_FORMAT_NC4) @@ -1055,7 +1055,7 @@ netCDFRasterBand::netCDFRasterBand( } // For Byte data add signed/unsigned info. - if (eDataType == GDT_Byte || eDataType == GDT_Int8) + if (eDataType == GDT_UInt8 || eDataType == GDT_Int8) { if (bDefineVar) { @@ -1470,7 +1470,7 @@ CPLErr netCDFRasterBand::SetNoDataValue(double dfNoData) cpl::down_cast(poDS)->SetDefineMode(true); int status; - if (eDataType == GDT_Byte) + if (eDataType == GDT_UInt8) { if (bSignedData) { @@ -2355,7 +2355,7 @@ bool netCDFRasterBand::FetchNetcdfChunk(size_t xstart, size_t ystart, // Read data according to type. int status; - if (eDataType == GDT_Byte) + if (eDataType == GDT_UInt8) { if (bSignedData) { @@ -2723,7 +2723,7 @@ CPLErr netCDFRasterBand::IWriteBlock(CPL_UNUSED int nBlockXOff, int nBlockYOff, // Copy data according to type. int status = 0; - if (eDataType == GDT_Byte) + if (eDataType == GDT_UInt8) { if (bSignedData) status = nc_put_vara_schar(cdfid, nZId, start, edge, @@ -9484,7 +9484,7 @@ GDALDataset *netCDFDataset::Create(const char *pszFilename, int nXSize, // TODO should this only be done in Create() poDS->bSignedData = true; const char *pszValue = CSLFetchNameValueDef(papszOptions, "PIXELTYPE", ""); - if (eType == GDT_Byte && !EQUAL(pszValue, "SIGNEDBYTE")) + if (eType == GDT_UInt8 && !EQUAL(pszValue, "SIGNEDBYTE")) poDS->bSignedData = false; // Add Conventions, GDAL info and history. @@ -9942,7 +9942,7 @@ netCDFDataset::CreateCopy(const char *pszFilename, GDALDataset *poSrcDS, GDALRasterBand *poDstBand = poDS->GetRasterBand(iBand); // Copy band data. - if (eDT == GDT_Byte) + if (eDT == GDT_UInt8) { CPLDebug("GDAL_netCDF", "GByte Band#%d", iBand); eErr = NCDFCopyBand(poSrcBand, poDstBand, nXSize, nYSize, diff --git a/frmts/netcdf/netcdfmultidim.cpp b/frmts/netcdf/netcdfmultidim.cpp index d8cb51fad086..a5c6e546071a 100644 --- a/frmts/netcdf/netcdfmultidim.cpp +++ b/frmts/netcdf/netcdfmultidim.cpp @@ -1011,7 +1011,7 @@ static int CreateOrGetType(int gid, const GDALExtendedDataType &oType) { switch (oType.GetNumericDataType()) { - case GDT_Byte: + case GDT_UInt8: nTypeId = NC_UBYTE; break; case GDT_Int8: @@ -2514,7 +2514,7 @@ static bool BuildDataType(int gid, int varid, const int nVarTypeIn, } if (!bSignedData) { - eDataType = GDT_Byte; + eDataType = GDT_UInt8; bPerfectDataTypeMatch = true; } else @@ -2527,7 +2527,7 @@ static bool BuildDataType(int gid, int varid, const int nVarTypeIn, { // Not sure of this bPerfectDataTypeMatch = true; - eDataType = GDT_Byte; + eDataType = GDT_UInt8; } else if (nVarType == NC_SHORT) { @@ -2570,7 +2570,7 @@ static bool BuildDataType(int gid, int varid, const int nVarTypeIn, else if (nVarType == NC_UBYTE) { bPerfectDataTypeMatch = true; - eDataType = GDT_Byte; + eDataType = GDT_UInt8; } else if (nVarType == NC_USHORT) { @@ -4527,7 +4527,7 @@ netCDFAttribute::netCDFAttribute( { m_nAttType = NC_CHAR; } - else if (oDataType.GetNumericDataType() == GDT_Byte && + else if (oDataType.GetNumericDataType() == GDT_UInt8 && EQUAL(CSLFetchNameValueDef(papszOptions, "NC_TYPE", ""), "NC_BYTE")) { @@ -4607,9 +4607,9 @@ std::shared_ptr netCDFAttribute::Create( const char *apszOptions[2] = {nullptr, nullptr}; if (!poShared->IsNC4() && oDataType.GetClass() == GEDTC_NUMERIC && - oDataType.GetNumericDataType() == GDT_Byte && !papszOptions) + oDataType.GetNumericDataType() == GDT_UInt8 && !papszOptions) { - // GDT_Byte would map to a NC_UBYTE datatype, which is not available in + // GDT_UInt8 would map to a NC_UBYTE datatype, which is not available in // NC3 datasets apszOptions[0] = "NC_TYPE=NC_BYTE"; papszOptions = apszOptions; diff --git a/frmts/nitf/ecrgtocdataset.cpp b/frmts/nitf/ecrgtocdataset.cpp index d60af2234742..8e2e10d60f65 100644 --- a/frmts/nitf/ecrgtocdataset.cpp +++ b/frmts/nitf/ecrgtocdataset.cpp @@ -458,7 +458,7 @@ bool ECRGTOCSource::ValidateOpenedBand(GDALRasterBand *poBand) const WARN_CHECK_DS( EQUAL(poSourceDS->GetProjectionRef(), SRS_WKT_WGS84_LAT_LONG)); WARN_CHECK_DS(poSourceDS->GetRasterBand(1)->GetRasterDataType() == - GDT_Byte); + GDT_UInt8); return checkOK; } @@ -537,7 +537,7 @@ GDALDataset *ECRGTOCSubDataset::Build( for (int i = 0; i < 3; i++) { - poVirtualDS->AddBand(GDT_Byte, nullptr); + poVirtualDS->AddBand(GDT_UInt8, nullptr); GDALRasterBand *poBand = poVirtualDS->GetRasterBand(i + 1); poBand->SetColorInterpretation( static_cast(GCI_RedBand + i)); diff --git a/frmts/nitf/nitfdataset.cpp b/frmts/nitf/nitfdataset.cpp index 8f8935b03710..af6e6dbd0572 100644 --- a/frmts/nitf/nitfdataset.cpp +++ b/frmts/nitf/nitfdataset.cpp @@ -4083,7 +4083,7 @@ static const char *GDALToNITFDataType(GDALDataType eType) switch (eType) { - case GDT_Byte: + case GDT_UInt8: case GDT_UInt16: case GDT_UInt32: pszPVType = "INT"; @@ -4817,7 +4817,7 @@ GDALDataset *NITFDataset::NITFCreateCopy(const char *pszFilename, papszFullOptions = CSLSetNameValue(papszFullOptions, "IREPBAND", osIREPBAND.c_str()); } - else if (poSrcDS->GetRasterCount() == 1 && eType == GDT_Byte && + else if (poSrcDS->GetRasterCount() == 1 && eType == GDT_UInt8 && poBand1->GetColorTable() != nullptr) { papszFullOptions = @@ -6843,7 +6843,7 @@ static bool NITFWriteJPEGImage(GDALDataset *poSrcDS, VSILFILE *fp, GDALDataType eDT = poSrcDS->GetRasterBand(1)->GetRasterDataType(); #if defined(JPEG_LIB_MK1) || defined(JPEG_DUAL_MODE_8_12) - if (eDT != GDT_Byte && eDT != GDT_UInt16) + if (eDT != GDT_UInt8 && eDT != GDT_UInt16) { CPLError(CE_Failure, CPLE_NotSupported, "JPEG driver doesn't support data type %s. " @@ -6857,10 +6857,10 @@ static bool NITFWriteJPEGImage(GDALDataset *poSrcDS, VSILFILE *fp, if (eDT == GDT_UInt16 || eDT == GDT_Int16) eDT = GDT_UInt16; else - eDT = GDT_Byte; + eDT = GDT_UInt8; #else - if (eDT != GDT_Byte) + if (eDT != GDT_UInt8) { CPLError(CE_Failure, CPLE_NotSupported, "JPEG driver doesn't support data type %s. " @@ -6871,7 +6871,7 @@ static bool NITFWriteJPEGImage(GDALDataset *poSrcDS, VSILFILE *fp, return false; } - eDT = GDT_Byte; // force to 8bit. + eDT = GDT_UInt8; // force to 8bit. #endif /* -------------------------------------------------------------------- */ diff --git a/frmts/nitf/nitfrasterband.cpp b/frmts/nitf/nitfrasterband.cpp index fd0a327bb986..3df1351cd21f 100644 --- a/frmts/nitf/nitfrasterband.cpp +++ b/frmts/nitf/nitfrasterband.cpp @@ -376,7 +376,7 @@ NITFRasterBand::NITFRasterBand(NITFDataset *poDSIn, int nBandIn) /* Translate data type(s). */ /* -------------------------------------------------------------------- */ if (psImage->nBitsPerSample <= 8) - eDataType = GDT_Byte; + eDataType = GDT_UInt8; else if (psImage->nBitsPerSample == 16 && EQUAL(psImage->szPVType, "SI")) eDataType = GDT_Int16; else if (psImage->nBitsPerSample == 16) diff --git a/frmts/nitf/rpftocdataset.cpp b/frmts/nitf/rpftocdataset.cpp index c0953c416099..a9ef78f5b589 100644 --- a/frmts/nitf/rpftocdataset.cpp +++ b/frmts/nitf/rpftocdataset.cpp @@ -296,7 +296,7 @@ class RPFTOCProxyRasterBandRGBA final : public GDALPamRasterBand nRasterYSize = poDSIn->GetRasterYSize(); this->nBlockXSize = nBlockXSizeIn; this->nBlockYSize = nBlockYSizeIn; - eDataType = GDT_Byte; + eDataType = GDT_UInt8; this->nBand = nBandIn; blockByteSize = nBlockXSize * nBlockYSize; } @@ -473,7 +473,7 @@ class RPFTOCProxyRasterBandPalette final : public GDALPamRasterBand nRasterYSize = poDSIn->GetRasterYSize(); this->nBlockXSize = nBlockXSizeIn; this->nBlockYSize = nBlockYSizeIn; - eDataType = GDT_Byte; + eDataType = GDT_UInt8; this->nBand = nBandIn; memset(remapLUT, 0, sizeof(remapLUT)); } @@ -649,7 +649,7 @@ int RPFTOCProxyRasterDataSet::SanityCheckOK(GDALDataset *sourceDS) ERROR_ON_FAIL(src_nBlockYSize == nBlockYSize); WARN_ON_FAIL(sourceDS->GetRasterBand(1)->GetColorInterpretation() == GCI_PaletteIndex); - WARN_ON_FAIL(sourceDS->GetRasterBand(1)->GetRasterDataType() == GDT_Byte); + WARN_ON_FAIL(sourceDS->GetRasterBand(1)->GetRasterDataType() == GDT_UInt8); return checkOK; } @@ -842,7 +842,7 @@ GDALDataset *RPFTOCSubDataset::CreateDataSetFromTocEntry( poSrcDS->GetRasterBand(1)->GetColorInterpretation() == GCI_PaletteIndex); ASSERT_CREATE_VRT(poSrcDS->GetRasterBand(1)->GetRasterDataType() == - GDT_Byte); + GDT_UInt8); GDALClose(poSrcDS); } @@ -883,7 +883,7 @@ GDALDataset *RPFTOCSubDataset::CreateDataSetFromTocEntry( /* option through the config option RPFTOC_FORCE_RGBA */ if (isRGBA == FALSE) { - poVirtualDS->AddBand(GDT_Byte, nullptr); + poVirtualDS->AddBand(GDT_UInt8, nullptr); GDALRasterBand *poBand = poVirtualDS->GetRasterBand(1); poBand->SetColorInterpretation(GCI_PaletteIndex); nBands = 1; @@ -952,7 +952,7 @@ GDALDataset *RPFTOCSubDataset::CreateDataSetFromTocEntry( { for (int i = 0; i < 4; i++) { - poVirtualDS->AddBand(GDT_Byte, nullptr); + poVirtualDS->AddBand(GDT_UInt8, nullptr); GDALRasterBand *poBand = poVirtualDS->GetRasterBand(i + 1); poBand->SetColorInterpretation( static_cast(GCI_RedBand + i)); diff --git a/frmts/northwood/grcdataset.cpp b/frmts/northwood/grcdataset.cpp index 605e23be01a7..3f5dbc8f1d27 100644 --- a/frmts/northwood/grcdataset.cpp +++ b/frmts/northwood/grcdataset.cpp @@ -89,7 +89,7 @@ NWT_GRCRasterBand::NWT_GRCRasterBand(NWT_GRCDataset *poDSIn, int nBandIn) NWT_GRCDataset *poGDS = cpl::down_cast(poDS); if (poGDS->pGrd->nBitsPerPixel == 8) - eDataType = GDT_Byte; + eDataType = GDT_UInt8; else if (poGDS->pGrd->nBitsPerPixel == 16) eDataType = GDT_UInt16; else /* if( poGDS->pGrd->nBitsPerPixel == 32 ) */ diff --git a/frmts/northwood/grddataset.cpp b/frmts/northwood/grddataset.cpp index e1cf60f65010..cff5c25894c2 100644 --- a/frmts/northwood/grddataset.cpp +++ b/frmts/northwood/grddataset.cpp @@ -170,7 +170,7 @@ NWT_GRDRasterBand::NWT_GRDRasterBand(NWT_GRDDataset *poDSIn, int nBandIn, bHaveOffsetScale = FALSE; dfOffset = 0; dfScale = 1.0; - eDataType = GDT_Byte; + eDataType = GDT_UInt8; } nBlockXSize = poDS->GetRasterXSize(); nBlockYSize = 1; diff --git a/frmts/null/nulldataset.cpp b/frmts/null/nulldataset.cpp index d7fbaf09c392..9bf7b1a3cf0b 100644 --- a/frmts/null/nulldataset.cpp +++ b/frmts/null/nulldataset.cpp @@ -288,7 +288,7 @@ GDALDataset *GDALNullDataset::Open(GDALOpenInfo *poOpenInfo) int nYSize = atoi(CSLFetchNameValueDef(papszTokens, "height", "512")); int nBands = atoi(CSLFetchNameValueDef(papszTokens, "bands", "1")); const char *pszDTName = CSLFetchNameValueDef(papszTokens, "type", "Byte"); - GDALDataType eDT = GDT_Byte; + GDALDataType eDT = GDT_UInt8; for (int iType = 1; iType < GDT_TypeCount; iType++) { if (GDALGetDataTypeName(static_cast(iType)) != nullptr && diff --git a/frmts/ogcapi/gdalogcapidataset.cpp b/frmts/ogcapi/gdalogcapidataset.cpp index b93bb04fd313..da2f6a119849 100644 --- a/frmts/ogcapi/gdalogcapidataset.cpp +++ b/frmts/ogcapi/gdalogcapidataset.cpp @@ -1330,7 +1330,7 @@ bool OGCAPIDataset::InitWithCoverageAPI(GDALOpenInfo *poOpenInfo, } static const std::map oMapTypes = { // https://edc-oapi.dev.hub.eox.at/oapi/collections/S2L2A - {"UINT8", GDT_Byte}, + {"UINT8", GDT_UInt8}, {"INT16", GDT_Int16}, {"UINT16", GDT_UInt16}, {"INT32", GDT_Int32}, @@ -1338,7 +1338,7 @@ bool OGCAPIDataset::InitWithCoverageAPI(GDALOpenInfo *poOpenInfo, {"FLOAT32", GDT_Float32}, {"FLOAT64", GDT_Float64}, // https://test.cubewerx.com/cubewerx/cubeserv/demo/ogcapi/Daraa/collections/Daraa_DTED/coverage/rangetype?f=json - {"ogcType:unsignedByte", GDT_Byte}, + {"ogcType:unsignedByte", GDT_UInt8}, {"ogcType:signedShort", GDT_Int16}, {"ogcType:unsignedShort", GDT_UInt16}, {"ogcType:signedInt", GDT_Int32}, @@ -1603,7 +1603,7 @@ GDALColorInterp OGCAPIMapWrapperBand::GetColorInterpretation() OGCAPIDataset *poGDS = cpl::down_cast(poDS); // The WMS driver returns Grey-Alpha for 2 band, RGB(A) for 3 or 4 bands // Restrict that behavior to Byte only data. - if (eDataType == GDT_Byte) + if (eDataType == GDT_UInt8) return poGDS->m_poWMSDS->GetRasterBand(nBand)->GetColorInterpretation(); return GCI_Undefined; } diff --git a/frmts/opjlike/jp2opjlikedataset.cpp b/frmts/opjlike/jp2opjlikedataset.cpp index 069783a2ccd5..463dcfee2a24 100644 --- a/frmts/opjlike/jp2opjlikedataset.cpp +++ b/frmts/opjlike/jp2opjlikedataset.cpp @@ -1316,7 +1316,7 @@ GDALDataset *JP2OPJLikeDataset::Open(GDALOpenInfo *poOpenInfo) &nTileH, &numResolutions)) return nullptr; - GDALDataType eDataType = GDT_Byte; + GDALDataType eDataType = GDT_UInt8; if (localctx.psImage->comps[0].prec > 16) { if (localctx.psImage->comps[0].sgnd) @@ -1334,7 +1334,7 @@ GDALDataset *JP2OPJLikeDataset::Open(GDALOpenInfo *poOpenInfo) int bIs420 = (localctx.psImage->color_space != CODEC::cvtenum(JP2_CLRSPC_SRGB) && - eDataType == GDT_Byte && + eDataType == GDT_UInt8 && (localctx.psImage->numcomps == 3 || localctx.psImage->numcomps == 4) && localctx.psImage->comps[1].w == localctx.psImage->comps[0].w / 2 && localctx.psImage->comps[1].h == localctx.psImage->comps[0].h / 2 && @@ -2014,7 +2014,7 @@ GDALDataset *JP2OPJLikeDataset::CreateCopy( GDALDataType eDataType = poSrcDS->GetRasterBand(1)->GetRasterDataType(); const int nDataTypeSize = GDALGetDataTypeSizeBytes(eDataType); - if (eDataType != GDT_Byte && eDataType != GDT_Int16 && + if (eDataType != GDT_UInt8 && eDataType != GDT_Int16 && eDataType != GDT_UInt16 && eDataType != GDT_Int32 && eDataType != GDT_UInt32) { @@ -2218,7 +2218,7 @@ GDALDataset *JP2OPJLikeDataset::CreateCopy( int bYCBCR420 = FALSE; if (pszYCBCR420 && CPLTestBool(pszYCBCR420)) { - if ((nBands == 3 || nBands == 4) && eDataType == GDT_Byte && + if ((nBands == 3 || nBands == 4) && eDataType == GDT_UInt8 && nRedBandIndex == 0 && nGreenBandIndex == 1 && nBlueBandIndex == 2) { if (((nXSize % 2) == 0 && (nYSize % 2) == 0 && diff --git a/frmts/pcidsk/gdal_edb.cpp b/frmts/pcidsk/gdal_edb.cpp index 0db7a8ae2ea6..3f9c81dd304a 100644 --- a/frmts/pcidsk/gdal_edb.cpp +++ b/frmts/pcidsk/gdal_edb.cpp @@ -166,7 +166,7 @@ eChanType GDAL_EDBFile::GetType(int nChannel) const { switch (poDS->GetRasterBand(nChannel)->GetRasterDataType()) { - case GDT_Byte: + case GDT_UInt8: return CHN_8U; case GDT_Int16: diff --git a/frmts/pcidsk/pcidskdataset2.cpp b/frmts/pcidsk/pcidskdataset2.cpp index 1b52ddf9991a..8b84ddf8729b 100644 --- a/frmts/pcidsk/pcidskdataset2.cpp +++ b/frmts/pcidsk/pcidskdataset2.cpp @@ -1668,7 +1668,7 @@ GDALDataType PCIDSK2Dataset::PCIDSKTypeToGDAL(eChanType eType) switch (eType) { case CHN_8U: - return GDT_Byte; + return GDT_UInt8; case CHN_16U: return GDT_UInt16; @@ -1680,7 +1680,7 @@ GDALDataType PCIDSK2Dataset::PCIDSKTypeToGDAL(eChanType eType) return GDT_Float32; case CHN_BIT: - return GDT_Byte; + return GDT_UInt8; case CHN_C16U: return GDT_CInt16; diff --git a/frmts/pcraster/pcrasterdataset.cpp b/frmts/pcraster/pcrasterdataset.cpp index cf8d3c48a5d2..8a9fb6cba1c4 100644 --- a/frmts/pcraster/pcrasterdataset.cpp +++ b/frmts/pcraster/pcrasterdataset.cpp @@ -432,7 +432,7 @@ GDALDataset *PCRasterDataset::create(const char *filename, int nr_cols, return nullptr; } - if (gdalType != GDT_Byte && gdalType != GDT_Int32 && + if (gdalType != GDT_UInt8 && gdalType != GDT_Int32 && gdalType != GDT_Float32) { CPLError(CE_Failure, CPLE_AppDefined, diff --git a/frmts/pcraster/pcrasterrasterband.cpp b/frmts/pcraster/pcrasterrasterband.cpp index d5d5d4286578..64853cd779c7 100644 --- a/frmts/pcraster/pcrasterrasterband.cpp +++ b/frmts/pcraster/pcrasterrasterband.cpp @@ -265,7 +265,7 @@ CPLErr PCRasterRasterBand::IWriteBlock(CPL_UNUSED int nBlockXoff, if (valuescale == VS_LDD) { - if ((d_create_in == GDT_Byte) || (d_create_in == GDT_Float32) || + if ((d_create_in == GDT_UInt8) || (d_create_in == GDT_Float32) || (d_create_in == GDT_Float64)) { CPLError(CE_Failure, CPLE_NotSupported, diff --git a/frmts/pcraster/pcrasterutil.cpp b/frmts/pcraster/pcrasterutil.cpp index 2ef95dc6ab9f..2d07aa9ce55f 100644 --- a/frmts/pcraster/pcrasterutil.cpp +++ b/frmts/pcraster/pcrasterutil.cpp @@ -33,7 +33,7 @@ GDALDataType cellRepresentation2GDALType(CSF_CR cellRepresentation) // ---------------------------------------------------------- case CR_UINT1: { - type = GDT_Byte; + type = GDT_UInt8; break; } case CR_INT4: @@ -55,7 +55,7 @@ GDALDataType cellRepresentation2GDALType(CSF_CR cellRepresentation) // ---------------------------------------------------------- case CR_INT1: { - type = GDT_Byte; + type = GDT_UInt8; break; } case CR_INT2: @@ -271,7 +271,7 @@ CSF_VS GDALType2ValueScale(GDALDataType type) switch (type) { - case GDT_Byte: + case GDT_UInt8: { // A foreign dataset is unlikely to support our LDD's. valueScale = VS_BOOLEAN; @@ -329,7 +329,7 @@ CSF_CR GDALType2CellRepresentation(GDALDataType type, bool exact) switch (type) { - case GDT_Byte: + case GDT_UInt8: { cellRepresentation = CR_UINT1; break; diff --git a/frmts/pdf/pdfcreatecopy.cpp b/frmts/pdf/pdfcreatecopy.cpp index 52414093ba99..5729bfec7402 100644 --- a/frmts/pdf/pdfcreatecopy.cpp +++ b/frmts/pdf/pdfcreatecopy.cpp @@ -3352,7 +3352,7 @@ GDALPDFObjectNum GDALPDFBaseWriter::WriteMask(GDALDataset *poSrcDS, int nXOff, CPLErr eErr; eErr = poSrcDS->GetRasterBand(4)->RasterIO( GF_Read, nXOff, nYOff, nReqXSize, nReqYSize, pabyMask, nReqXSize, - nReqYSize, GDT_Byte, 0, 0, nullptr); + nReqYSize, GDT_UInt8, 0, 0, nullptr); if (eErr != CE_None) { VSIFree(pabyMask); @@ -3549,8 +3549,8 @@ GDALPDFObjectNum GDALPDFBaseWriter::WriteBlock( if (nBands == 4) nBands = 3; - poMEMDS.reset( - MEMDataset::Create("", nReqXSize, nReqYSize, 0, GDT_Byte, nullptr)); + poMEMDS.reset(MEMDataset::Create("", nReqXSize, nReqYSize, 0, GDT_UInt8, + nullptr)); pabyMEMDSBuffer = static_cast(VSIMalloc3(nReqXSize, nReqYSize, nBands)); @@ -3561,7 +3561,7 @@ GDALPDFObjectNum GDALPDFBaseWriter::WriteBlock( eErr = poSrcDS->RasterIO(GF_Read, nXOff, nYOff, nReqXSize, nReqYSize, pabyMEMDSBuffer, nReqXSize, nReqYSize, - GDT_Byte, nBands, nullptr, 0, 0, 0, nullptr); + GDT_UInt8, nBands, nullptr, 0, 0, 0, nullptr); if (eErr != CE_None) { @@ -3574,8 +3574,8 @@ GDALPDFObjectNum GDALPDFBaseWriter::WriteBlock( { auto hBand = MEMCreateRasterBandEx( poMEMDS.get(), iBand + 1, - pabyMEMDSBuffer + iBand * nReqXSize * nReqYSize, GDT_Byte, 0, 0, - false); + pabyMEMDSBuffer + iBand * nReqXSize * nReqYSize, GDT_UInt8, 0, + 0, false); poMEMDS->AddMEMBand(hBand); } @@ -3752,7 +3752,7 @@ GDALPDFObjectNum GDALPDFBaseWriter::WriteBlock( /* Get pixel interleaved data */ eErr = poBlockSrcDS->RasterIO( GF_Read, 0, iLine, nReqXSize, 1, pabyLine, nReqXSize, 1, - GDT_Byte, nBands, nullptr, nBands, 0, 1, nullptr); + GDT_UInt8, nBands, nullptr, nBands, 0, 1, nullptr); if (eErr != CE_None) break; @@ -4153,7 +4153,7 @@ GDALDataset *GDALPDFCreateCopy(const char *pszFilename, GDALDataset *poSrcDS, } GDALDataType eDT = poSrcDS->GetRasterBand(1)->GetRasterDataType(); - if (eDT != GDT_Byte) + if (eDT != GDT_UInt8) { CPLError((bStrict) ? CE_Failure : CE_Warning, CPLE_NotSupported, "PDF driver doesn't support data type %s. " diff --git a/frmts/pdf/pdfdataset.cpp b/frmts/pdf/pdfdataset.cpp index 5588a4e34186..6d644a8f4f89 100644 --- a/frmts/pdf/pdfdataset.cpp +++ b/frmts/pdf/pdfdataset.cpp @@ -492,7 +492,7 @@ PDFRasterBand::PDFRasterBand(PDFDataset *poDSIn, int nBandIn, poDS = poDSIn; nBand = nBandIn; - eDataType = GDT_Byte; + eDataType = GDT_UInt8; if (nResolutionLevel > 0) { @@ -2144,7 +2144,7 @@ CPLErr PDFDataset::ReadPixels(int nReqXOff, int nReqYOff, int nReqXSize, { eErr = poDS->RasterIO(GF_Read, 0, 0, nReqXSize, nReqYSize, pabyData, nReqXSize, nReqYSize, - GDT_Byte, 3, nullptr, nPixelSpace, + GDT_UInt8, 3, nullptr, nPixelSpace, nLineSpace, nBandSpace, nullptr); } } @@ -2689,7 +2689,7 @@ CPLErr PDFDataset::IRasterIO(GDALRWFlag eRWFlag, int nXOff, int nYOff, if (m_aiTiles.empty() && eRWFlag == GF_Read && nXSize == nBufXSize && nYSize == nBufYSize && (nBufXSize > nBandBlockXSize || nBufYSize > nBandBlockYSize) && - eBufType == GDT_Byte && nBandCount == nBands && + eBufType == GDT_UInt8 && nBandCount == nBands && IsAllBands(nBandCount, panBandMap)) { bReadPixels = TRUE; @@ -2705,7 +2705,7 @@ CPLErr PDFDataset::IRasterIO(GDALRWFlag eRWFlag, int nXOff, int nYOff, return ReadPixels(nXOff, nYOff, nXSize, nYSize, nPixelSpace, nLineSpace, nBandSpace, static_cast(pData)); - if (nBufXSize != nXSize || nBufYSize != nYSize || eBufType != GDT_Byte) + if (nBufXSize != nXSize || nBufYSize != nYSize || eBufType != GDT_UInt8) { m_bCacheBlocksForOtherBands = true; } @@ -2741,7 +2741,7 @@ CPLErr PDFRasterBand::IRasterIO(GDALRWFlag eRWFlag, int nXOff, int nYOff, return eErr; } - if (nBufXSize != nXSize || nBufYSize != nYSize || eBufType != GDT_Byte) + if (nBufXSize != nXSize || nBufYSize != nYSize || eBufType != GDT_UInt8) { poGDS->m_bCacheBlocksForOtherBands = true; } diff --git a/frmts/pdf/pdfwritabledataset.cpp b/frmts/pdf/pdfwritabledataset.cpp index 017c1c642108..e93477d02242 100644 --- a/frmts/pdf/pdfwritabledataset.cpp +++ b/frmts/pdf/pdfwritabledataset.cpp @@ -340,7 +340,7 @@ CPLErr PDFWritableVectorDataset::FlushCache(bool /* bAtClosing*/) GDALPDFWriter oWriter(fp); GDALDataset *poSrcDS = - MEMDataset::Create("MEM:::", nWidth, nHeight, 0, GDT_Byte, nullptr); + MEMDataset::Create("MEM:::", nWidth, nHeight, 0, GDT_UInt8, nullptr); poSrcDS->SetGeoTransform(gt); diff --git a/frmts/pds/isis2dataset.cpp b/frmts/pds/isis2dataset.cpp index ba570f31a5b3..e32b865a3428 100644 --- a/frmts/pds/isis2dataset.cpp +++ b/frmts/pds/isis2dataset.cpp @@ -310,7 +310,7 @@ GDALDataset *ISIS2Dataset::Open(GDALOpenInfo *poOpenInfo) } /******** Grab format type - isis2 only supports 8,16,32 *******/ - GDALDataType eDataType = GDT_Byte; + GDALDataType eDataType = GDT_UInt8; bool bNoDataSet = false; double dfNoData = 0.0; @@ -318,7 +318,7 @@ GDALDataset *ISIS2Dataset::Open(GDALOpenInfo *poOpenInfo) switch (itype) { case 1: - eDataType = GDT_Byte; + eDataType = GDT_UInt8; dfNoData = NULL1; bNoDataSet = true; break; diff --git a/frmts/pds/isis3dataset.cpp b/frmts/pds/isis3dataset.cpp index 69440f938a18..a297937c9454 100644 --- a/frmts/pds/isis3dataset.cpp +++ b/frmts/pds/isis3dataset.cpp @@ -476,7 +476,7 @@ CPLErr ISISTiledBand::IReadBlock(int nXBlock, int nYBlock, void *pImage) return CE_Failure; } - if (!m_bNativeOrder && eDataType != GDT_Byte) + if (!m_bNativeOrder && eDataType != GDT_UInt8) GDALSwapWords(pImage, nDTSize, nBlockXSize * nBlockYSize, nDTSize); return CE_None; @@ -503,7 +503,7 @@ static void RemapNoDataT(T *pBuffer, int nItems, T srcNoData, T dstNoData) static void RemapNoData(GDALDataType eDataType, void *pBuffer, int nItems, double dfSrcNoData, double dfDstNoData) { - if (eDataType == GDT_Byte) + if (eDataType == GDT_UInt8) { RemapNoDataT(reinterpret_cast(pBuffer), nItems, static_cast(dfSrcNoData), @@ -590,7 +590,7 @@ CPLErr ISISTiledBand::IWriteBlock(int nXBlock, int nYBlock, void *pImage) return CE_Failure; } - if (!m_bNativeOrder && eDataType != GDT_Byte) + if (!m_bNativeOrder && eDataType != GDT_UInt8) GDALSwapWords(pImage, nDTSize, nBlockXSize * nBlockYSize, nDTSize); if (VSIFWriteL(pImage, 1, nBlockSize, m_fpVSIL) != nBlockSize) @@ -601,7 +601,7 @@ CPLErr ISISTiledBand::IWriteBlock(int nXBlock, int nYBlock, void *pImage) return CE_Failure; } - if (!m_bNativeOrder && eDataType != GDT_Byte) + if (!m_bNativeOrder && eDataType != GDT_UInt8) GDALSwapWords(pImage, nDTSize, nBlockXSize * nBlockYSize, nDTSize); return CE_None; @@ -1142,7 +1142,7 @@ CPLErr ISIS3WrapperRasterBand::IRasterIO( ISISMaskBand::ISISMaskBand(GDALRasterBand *poBaseBand) : m_poBaseBand(poBaseBand), m_pBuffer(nullptr) { - eDataType = GDT_Byte; + eDataType = GDT_UInt8; poBaseBand->GetBlockSize(&nBlockXSize, &nBlockYSize); nRasterXSize = poBaseBand->GetXSize(); nRasterYSize = poBaseBand->GetYSize(); @@ -1221,7 +1221,7 @@ CPLErr ISISMaskBand::IReadBlock(int nXBlock, int nYBlock, void *pImage) } GByte *pabyDst = static_cast(pImage); - if (eSrcDT == GDT_Byte) + if (eSrcDT == GDT_UInt8) { FillMask(m_pBuffer, pabyDst, nReqXSize, nReqYSize, nBlockXSize, ISIS3_NULL1, LOW_REPR_SAT1, LOW_INSTR_SAT1, @@ -1873,13 +1873,13 @@ GDALDataset *ISIS3Dataset::Open(GDALOpenInfo *poOpenInfo) const int nBands = atoi(poDS->GetKeyword("IsisCube.Core.Dimensions.Bands")); /****** Grab format type - ISIS3 only supports 8,U16,S16,32 *****/ - GDALDataType eDataType = GDT_Byte; + GDALDataType eDataType = GDT_UInt8; double dfNoData = 0.0; const char *itype = poDS->GetKeyword("IsisCube.Core.Pixels.Type"); if (EQUAL(itype, "UnsignedByte")) { - eDataType = GDT_Byte; + eDataType = GDT_UInt8; dfNoData = ISIS3_NULL1; } else if (EQUAL(itype, "UnsignedWord")) @@ -2797,7 +2797,7 @@ void ISIS3Dataset::BuildLabel() CPLJSONObject oPixels = GetOrCreateJSONObject(oCore, "Pixels"); oPixels.Set("_type", "group"); const GDALDataType eDT = GetRasterBand(1)->GetRasterDataType(); - oPixels.Set("Type", (eDT == GDT_Byte) ? "UnsignedByte" + oPixels.Set("Type", (eDT == GDT_UInt8) ? "UnsignedByte" : (eDT == GDT_UInt16) ? "UnsignedWord" : (eDT == GDT_Int16) ? "SignedWord" : "Real"); @@ -4126,7 +4126,7 @@ GDALDataset *ISIS3Dataset::Create(const char *pszFilename, int nXSize, int nYSize, int nBandsIn, GDALDataType eType, char **papszOptions) { - if (eType != GDT_Byte && eType != GDT_UInt16 && eType != GDT_Int16 && + if (eType != GDT_UInt8 && eType != GDT_UInt16 && eType != GDT_Int16 && eType != GDT_Float32) { CPLError(CE_Failure, CPLE_NotSupported, "Unsupported data type"); @@ -4289,7 +4289,7 @@ GDALDataset *ISIS3Dataset::Create(const char *pszFilename, int nXSize, poDS->m_osGDALHistory = CSLFetchNameValueDef(papszOptions, "GDAL_HISTORY", ""); } - const double dfNoData = (eType == GDT_Byte) ? ISIS3_NULL1 + const double dfNoData = (eType == GDT_UInt8) ? ISIS3_NULL1 : (eType == GDT_UInt16) ? ISIS3_NULLU2 : (eType == GDT_Int16) ? ISIS3_NULL2 diff --git a/frmts/pds/pds4dataset.cpp b/frmts/pds/pds4dataset.cpp index 6611be037ac8..64712a84eb1a 100644 --- a/frmts/pds/pds4dataset.cpp +++ b/frmts/pds/pds4dataset.cpp @@ -478,7 +478,7 @@ PDS4MaskBand::PDS4MaskBand(GDALRasterBand *poBaseBand, const std::vector &adfConstants) : m_poBaseBand(poBaseBand), m_pBuffer(nullptr), m_adfConstants(adfConstants) { - eDataType = GDT_Byte; + eDataType = GDT_UInt8; poBaseBand->GetBlockSize(&nBlockXSize, &nBlockYSize); nRasterXSize = poBaseBand->GetXSize(); nRasterYSize = poBaseBand->GetYSize(); @@ -564,7 +564,7 @@ CPLErr PDS4MaskBand::IReadBlock(int nXBlock, int nYBlock, void *pImage) } GByte *pabyDst = static_cast(pImage); - if (eSrcDT == GDT_Byte) + if (eSrcDT == GDT_UInt8) { FillMask(m_pBuffer, pabyDst, nReqXSize, nReqYSize, nBlockXSize, m_adfConstants); @@ -1924,7 +1924,7 @@ std::unique_ptr PDS4Dataset::OpenInternal(GDALOpenInfo *poOpenInfo) // Figure out data type const char *pszDataType = CPLGetXMLValue(psSubIter, "Element_Array.data_type", ""); - GDALDataType eDT = GDT_Byte; + GDALDataType eDT = GDT_UInt8; bool bLSBOrder = strstr(pszDataType, "LSB") != nullptr; // ComplexLSB16', 'ComplexLSB8', 'ComplexMSB16', 'ComplexMSB8', @@ -1976,7 +1976,7 @@ std::unique_ptr PDS4Dataset::OpenInternal(GDALOpenInfo *poOpenInfo) } else if (EQUAL(pszDataType, "UnsignedByte")) { - eDT = GDT_Byte; + eDT = GDT_UInt8; } else if (EQUAL(pszDataType, "UnsignedLSB2") || EQUAL(pszDataType, "UnsignedMSB2")) @@ -3769,7 +3769,7 @@ void PDS4Dataset::WriteArray(const CPLString &osPrefix, CPLXMLNode *psFAO, psArray, CXT_Element, (osPrefix + "Element_Array").c_str()); GDALDataType eDT = GetRasterBand(1)->GetRasterDataType(); const char *pszDataType = - (eDT == GDT_Byte) ? "UnsignedByte" + (eDT == GDT_UInt8) ? "UnsignedByte" : (eDT == GDT_Int8) ? "SignedByte" : (eDT == GDT_UInt16) ? "UnsignedLSB2" : (eDT == GDT_Int16) ? (m_bIsLSB ? "SignedLSB2" : "SignedMSB2") @@ -4762,7 +4762,7 @@ std::unique_ptr PDS4Dataset::CreateInternal( if (nXSize == 0) return nullptr; - if (!(eType == GDT_Byte || eType == GDT_Int8 || eType == GDT_Int16 || + if (!(eType == GDT_UInt8 || eType == GDT_Int8 || eType == GDT_Int16 || eType == GDT_UInt16 || eType == GDT_Int32 || eType == GDT_UInt32 || eType == GDT_Int64 || eType == GDT_UInt64 || eType == GDT_Float32 || eType == GDT_Float64 || eType == GDT_CFloat32 || diff --git a/frmts/pds/pdsdataset.cpp b/frmts/pds/pdsdataset.cpp index 93734ccff3cb..c831183d2f3d 100644 --- a/frmts/pds/pdsdataset.cpp +++ b/frmts/pds/pdsdataset.cpp @@ -1012,7 +1012,7 @@ int PDSDataset::ParseImage(const CPLString &osPrefix, /**** Grab format type - pds supports 1,2,4,8,16,32,64 (in theory) **/ /**** I have only seen 8, 16, 32 (float) in released datasets **/ - GDALDataType eDataType = GDT_Byte; + GDALDataType eDataType = GDT_UInt8; int nSuffixItems = 0; int nSuffixLines = 0; int nSuffixBytes = 4; // Default as per PDS specification @@ -1029,7 +1029,7 @@ int PDSDataset::ParseImage(const CPLString &osPrefix, switch (itype) { case 8: - eDataType = GDT_Byte; + eDataType = GDT_UInt8; dfNoData = PDS_NULL1; break; case 16: @@ -1071,7 +1071,7 @@ int PDSDataset::ParseImage(const CPLString &osPrefix, switch (itype) { case 1: - eDataType = GDT_Byte; + eDataType = GDT_UInt8; break; case 2: if (strstr(osST, "UNSIGNED") != nullptr) diff --git a/frmts/pds/vicardataset.cpp b/frmts/pds/vicardataset.cpp index c5cb0c5465f3..54075da54f29 100644 --- a/frmts/pds/vicardataset.cpp +++ b/frmts/pds/vicardataset.cpp @@ -1654,7 +1654,7 @@ void VICARDataset::BuildLabel() CPL_IGNORE_RET_VAL(pszFormat); // Make CSA happy switch (eType) { - case GDT_Byte: + case GDT_UInt8: pszFormat = "BYTE"; break; case GDT_Int16: @@ -1914,7 +1914,7 @@ void VICARDataset::BuildLabelPropertyGeoTIFF(CPLJSONObject &oLabel) } const char *const apszOptions[] = {"GEOTIFF_VERSION=1.0", nullptr}; auto poDS = std::unique_ptr(poGTiffDriver->Create( - osTmpFilename.c_str(), 1, 1, 1, GDT_Byte, apszOptions)); + osTmpFilename.c_str(), 1, 1, 1, GDT_UInt8, apszOptions)); if (!poDS) return; poDS->SetSpatialRef(&m_oSRS); @@ -2537,7 +2537,7 @@ GDALDataset *VICARDataset::Open(GDALOpenInfo *poOpenInfo) return nullptr; } double dfNoData = 0.0; - if (eDataType == GDT_Byte) + if (eDataType == GDT_UInt8) { dfNoData = VICAR_NULL1; } @@ -3045,7 +3045,7 @@ const char *VICARDataset::GetKeyword(const char *pszPath, GDALDataType VICARDataset::GetDataTypeFromFormat(const char *pszFormat) { if (EQUAL(pszFormat, "BYTE")) - return GDT_Byte; + return GDT_UInt8; if (EQUAL(pszFormat, "HALF") || EQUAL(pszFormat, "WORD")) return GDT_Int16; @@ -3158,7 +3158,7 @@ VICARDataset *VICARDataset::CreateInternal(const char *pszFilename, int nXSize, GDALDataType eType, char **papszOptions) { - if (eType != GDT_Byte && eType != GDT_Int16 && eType != GDT_Int32 && + if (eType != GDT_UInt8 && eType != GDT_Int16 && eType != GDT_Int32 && eType != GDT_Float32 && eType != GDT_Float64 && eType != GDT_CFloat32) { CPLError(CE_Failure, CPLE_NotSupported, "Unsupported data type"); diff --git a/frmts/plmosaic/plmosaicdataset.cpp b/frmts/plmosaic/plmosaicdataset.cpp index cc0dfb195798..2dd56cabfb52 100644 --- a/frmts/plmosaic/plmosaicdataset.cpp +++ b/frmts/plmosaic/plmosaicdataset.cpp @@ -810,7 +810,7 @@ int PLMosaicDataset::OpenMosaic() GDALDataType eDT = GDT_Unknown; const char *pszDataType = json_object_get_string(poDataType); if (EQUAL(pszDataType, "byte")) - eDT = GDT_Byte; + eDT = GDT_UInt8; else if (EQUAL(pszDataType, "uint16")) eDT = GDT_UInt16; else if (EQUAL(pszDataType, "int16")) @@ -823,10 +823,10 @@ int PLMosaicDataset::OpenMosaic() return FALSE; } - if (eDT == GDT_Byte && !bQuadDownload) + if (eDT == GDT_UInt8 && !bQuadDownload) bUseTMSForMain = true; - if (bUseTMSForMain && eDT != GDT_Byte) + if (bUseTMSForMain && eDT != GDT_UInt8) { CPLError( CE_Failure, CPLE_NotSupported, @@ -907,7 +907,7 @@ int PLMosaicDataset::OpenMosaic() osQuadsURL += osId + "/quads/"; // Use WMS/TMS driver for overviews (only for byte) - if (eDT == GDT_Byte && EQUAL(pszSRS, "EPSG:3857") && + if (eDT == GDT_UInt8 && EQUAL(pszSRS, "EPSG:3857") && poLinksTiles != nullptr && json_object_get_type(poLinksTiles) == json_type_string) { @@ -978,7 +978,7 @@ int PLMosaicDataset::OpenMosaic() VRTDatasetH hVRTDS = VRTCreate(nOvrXSize, nOvrYSize); for (int iBand = 1; iBand <= 4; iBand++) { - VRTAddBand(hVRTDS, GDT_Byte, nullptr); + VRTAddBand(hVRTDS, GDT_UInt8, nullptr); } int nSrcXOff, nSrcYOff, nDstXOff, nDstYOff; diff --git a/frmts/png/pngdataset.cpp b/frmts/png/pngdataset.cpp index 2b146ce35746..1ad6ca0548eb 100644 --- a/frmts/png/pngdataset.cpp +++ b/frmts/png/pngdataset.cpp @@ -100,7 +100,7 @@ PNGRasterBand::PNGRasterBand(PNGDataset *poDSIn, int nBandIn) if (poDSIn->nBitDepth == 16) eDataType = GDT_UInt16; else - eDataType = GDT_Byte; + eDataType = GDT_UInt8; nBlockXSize = poDSIn->nRasterXSize; #ifdef ENABLE_WHOLE_IMAGE_OPTIMIZATION @@ -970,8 +970,8 @@ CPLErr PNGDataset::LoadWholeImage(void *pSingleBuffer, GSpacing nPixelSpace, apDestBuffers[1] = pabyDest + nBandSpace; apDestBuffers[2] = pabyDest + 2 * nBandSpace; apDestBuffers[3] = pabyDest + 3 * nBandSpace; - GDALDeinterleave(pabyOutputLine, GDT_Byte, nBands, - apDestBuffers, GDT_Byte, nRasterXSize); + GDALDeinterleave(pabyOutputLine, GDT_UInt8, nBands, + apDestBuffers, GDT_UInt8, nRasterXSize); } else if (nPixelSpace <= nBands && nBandSpace > nBands) { @@ -980,8 +980,8 @@ CPLErr PNGDataset::LoadWholeImage(void *pSingleBuffer, GSpacing nPixelSpace, { GByte *pabyDest2 = pabyDest + iBand * nBandSpace; const GByte *pabyScanline2 = pabyOutputLine + iBand; - GDALCopyWords(pabyScanline2, GDT_Byte, nBands, - pabyDest2, GDT_Byte, + GDALCopyWords(pabyScanline2, GDT_UInt8, nBands, + pabyDest2, GDT_UInt8, static_cast(nPixelSpace), nRasterXSize); } @@ -1012,8 +1012,8 @@ CPLErr PNGDataset::LoadWholeImage(void *pSingleBuffer, GSpacing nPixelSpace, { // Cache friendly way for typical band interleaved case. GDALDeinterleave( - pabyOutputLine, GDT_Byte, nBands, - reinterpret_cast(apabyDestBuffers), GDT_Byte, + pabyOutputLine, GDT_UInt8, nBands, + reinterpret_cast(apabyDestBuffers), GDT_UInt8, nRasterXSize); } else @@ -1061,7 +1061,7 @@ CPLErr PNGDataset::IRasterIO(GDALRWFlag eRWFlag, int nXOff, int nYOff, if ((eRWFlag == GF_Read) && (nBandCount == nBands) && (nXOff == 0) && (nYOff == 0) && (nXSize == nBufXSize) && (nXSize == nRasterXSize) && (nYSize == nBufYSize) && (nYSize == nRasterYSize) && - (eBufType == GDT_Byte) && + (eBufType == GDT_UInt8) && (eBufType == GetRasterBand(1)->GetRasterDataType()) && (pData != nullptr) && IsAllBands(nBands, panBandMap)) { @@ -1138,8 +1138,9 @@ CPLErr PNGDataset::IRasterIO(GDALRWFlag eRWFlag, int nXOff, int nYOff, apDestBuffers[1] = pabyDest + nBandSpace; apDestBuffers[2] = pabyDest + 2 * nBandSpace; apDestBuffers[3] = pabyDest + 3 * nBandSpace; - GDALDeinterleave(pabyScanline, GDT_Byte, nBands, - apDestBuffers, GDT_Byte, nRasterXSize); + GDALDeinterleave(pabyScanline, GDT_UInt8, nBands, + apDestBuffers, GDT_UInt8, + nRasterXSize); } else if (nPixelSpace <= nBands && nBandSpace > nBands) { @@ -1148,8 +1149,8 @@ CPLErr PNGDataset::IRasterIO(GDALRWFlag eRWFlag, int nXOff, int nYOff, { GByte *pabyDest2 = pabyDest + iBand * nBandSpace; const GByte *pabyScanline2 = pabyScanline + iBand; - GDALCopyWords(pabyScanline2, GDT_Byte, nBands, - pabyDest2, GDT_Byte, + GDALCopyWords(pabyScanline2, GDT_UInt8, nBands, + pabyDest2, GDT_UInt8, static_cast(nPixelSpace), nXSize); } @@ -1195,7 +1196,7 @@ CPLErr PNGRasterBand::IRasterIO(GDALRWFlag eRWFlag, int nXOff, int nYOff, if ((eRWFlag == GF_Read) && (nXOff == 0) && (nYOff == 0) && (nXSize == nBufXSize) && (nXSize == nRasterXSize) && (nYSize == nBufYSize) && (nYSize == nRasterYSize) && - (eBufType == GDT_Byte) && (eBufType == eDataType)) + (eBufType == GDT_UInt8) && (eBufType == eDataType)) { bool bBlockAlreadyLoaded = false; if (nBlockYSize > 1) @@ -2297,7 +2298,7 @@ GDALDataset *PNGDataset::CreateCopy(const char *pszFilename, return nullptr; } - if (poSrcDS->GetRasterBand(1)->GetRasterDataType() != GDT_Byte && + if (poSrcDS->GetRasterBand(1)->GetRasterDataType() != GDT_UInt8 && poSrcDS->GetRasterBand(1)->GetRasterDataType() != GDT_UInt16) { CPLError( @@ -2353,7 +2354,7 @@ GDALDataset *PNGDataset::CreateCopy(const char *pszFilename, GDALDataType eType; if (poSrcDS->GetRasterBand(1)->GetRasterDataType() != GDT_UInt16) { - eType = GDT_Byte; + eType = GDT_UInt8; nBitDepth = 8; if (nBands == 1) { @@ -2374,7 +2375,7 @@ GDALDataset *PNGDataset::CreateCopy(const char *pszFilename, } const char *pszNbits = CSLFetchNameValue(papszOptions, "NBITS"); - if (eType == GDT_Byte && pszNbits != nullptr) + if (eType == GDT_UInt8 && pszNbits != nullptr) { nBitDepth = atoi(pszNbits); if (!(nBitDepth == 1 || nBitDepth == 2 || nBitDepth == 4 || @@ -3286,7 +3287,7 @@ GDALDataset *PNGDataset::Create(const char *pszFilename, int nXSize, int nYSize, int nBands, GDALDataType eType, char **papszOptions) { - if (eType != GDT_Byte && eType != GDT_UInt16) + if (eType != GDT_UInt8 && eType != GDT_UInt16) { CPLError( CE_Failure, CPLE_AppDefined, @@ -3348,7 +3349,7 @@ GDALDataset *PNGDataset::Create(const char *pszFilename, int nXSize, int nYSize, break; } - poDS->m_nBitDepth = (eType == GDT_Byte ? 8 : 16); + poDS->m_nBitDepth = (eType == GDT_UInt8 ? 8 : 16); poDS->m_pabyBuffer = reinterpret_cast( CPLMalloc(nBands * nXSize * poDS->m_nBitDepth / 8)); diff --git a/frmts/postgisraster/postgisrastertools.cpp b/frmts/postgisraster/postgisrastertools.cpp index 0c3c4e824032..40aa130e764f 100644 --- a/frmts/postgisraster/postgisrastertools.cpp +++ b/frmts/postgisraster/postgisrastertools.cpp @@ -57,7 +57,7 @@ GBool TranslateDataType(const char *pszDataType, if (pnBitsDepth) *pnBitsDepth = 1; if (poDataType) - *poDataType = GDT_Byte; + *poDataType = GDT_UInt8; } else if (EQUAL(pszDataType, "2BUI")) @@ -65,7 +65,7 @@ GBool TranslateDataType(const char *pszDataType, if (pnBitsDepth) *pnBitsDepth = 2; if (poDataType) - *poDataType = GDT_Byte; + *poDataType = GDT_UInt8; } else if (EQUAL(pszDataType, "4BUI")) @@ -73,7 +73,7 @@ GBool TranslateDataType(const char *pszDataType, if (pnBitsDepth) *pnBitsDepth = 4; if (poDataType) - *poDataType = GDT_Byte; + *poDataType = GDT_UInt8; } else if (EQUAL(pszDataType, "8BUI")) @@ -81,7 +81,7 @@ GBool TranslateDataType(const char *pszDataType, if (pnBitsDepth) *pnBitsDepth = 8; if (poDataType) - *poDataType = GDT_Byte; + *poDataType = GDT_UInt8; } else if (EQUAL(pszDataType, "8BSI")) diff --git a/frmts/prf/phprfdataset.cpp b/frmts/prf/phprfdataset.cpp index 35ad7973a127..30ed6c00c33f 100644 --- a/frmts/prf/phprfdataset.cpp +++ b/frmts/prf/phprfdataset.cpp @@ -325,7 +325,7 @@ static GDALDataType ParseChannelsInfo(const CPLXMLNode *psElt) switch (nDataTypeSize) { case 1: - return GDT_Byte; + return GDT_UInt8; case 2: return GDT_UInt16; case 4: diff --git a/frmts/raw/doq1dataset.cpp b/frmts/raw/doq1dataset.cpp index 223b3aa3ead1..0fef77e2ceaf 100644 --- a/frmts/raw/doq1dataset.cpp +++ b/frmts/raw/doq1dataset.cpp @@ -282,7 +282,7 @@ GDALDataset *DOQ1Dataset::Open(GDALOpenInfo *poOpenInfo) { auto poBand = RawRasterBand::Create( poDS.get(), i + 1, poDS->fpImage, nSkipBytes + i, nBytesPerPixel, - nBytesPerLine, GDT_Byte, + nBytesPerLine, GDT_UInt8, RawRasterBand::ByteOrder::ORDER_LITTLE_ENDIAN, RawRasterBand::OwnFP::NO); if (!poBand) diff --git a/frmts/raw/doq2dataset.cpp b/frmts/raw/doq2dataset.cpp index 21ec4f2537a6..e4cf9ad5831d 100644 --- a/frmts/raw/doq2dataset.cpp +++ b/frmts/raw/doq2dataset.cpp @@ -406,7 +406,7 @@ GDALDataset *DOQ2Dataset::Open(GDALOpenInfo *poOpenInfo) { auto poBand = RawRasterBand::Create( poDS.get(), i + 1, poDS->fpImage, nSkipBytes + i, nBytesPerPixel, - nBytesPerLine, GDT_Byte, + nBytesPerLine, GDT_UInt8, RawRasterBand::ByteOrder::ORDER_LITTLE_ENDIAN, RawRasterBand::OwnFP::NO); if (!poBand) diff --git a/frmts/raw/ehdrdataset.cpp b/frmts/raw/ehdrdataset.cpp index bb8294d26b40..326f4b2b451e 100644 --- a/frmts/raw/ehdrdataset.cpp +++ b/frmts/raw/ehdrdataset.cpp @@ -984,7 +984,7 @@ GDALDataset *EHdrDataset::Open(GDALOpenInfo *poOpenInfo, bool bFileSizeCheck) double dfNoData = 0.0; int nLineCount = 0; int bNoDataSet = FALSE; - GDALDataType eDataType = GDT_Byte; + GDALDataType eDataType = GDT_UInt8; int nBits = -1; char chByteOrder = 'M'; char chPixelType = 'N'; // Not defined. @@ -1212,7 +1212,7 @@ GDALDataset *EHdrDataset::Open(GDALOpenInfo *poOpenInfo, bool bFileSizeCheck) if (chPixelType == 'S') eDataType = GDT_Int8; else - eDataType = GDT_Byte; + eDataType = GDT_UInt8; nBits = 8; } else if (nBits == -1) @@ -1224,7 +1224,7 @@ GDALDataset *EHdrDataset::Open(GDALOpenInfo *poOpenInfo, bool bFileSizeCheck) } else { - eDataType = GDT_Byte; + eDataType = GDT_UInt8; nBits = 8; } } @@ -1647,7 +1647,7 @@ GDALDataset *EHdrDataset::Create(const char *pszFilename, int nXSize, return nullptr; } - if (eType != GDT_Byte && eType != GDT_Int8 && eType != GDT_Float32 && + if (eType != GDT_UInt8 && eType != GDT_Int8 && eType != GDT_Float32 && eType != GDT_UInt16 && eType != GDT_Int16 && eType != GDT_Int32 && eType != GDT_UInt32) { @@ -1732,7 +1732,7 @@ GDALDataset *EHdrDataset::Create(const char *pszFilename, int nXSize, bOK &= VSIFPrintfL(fp, "PIXELTYPE FLOAT\n") >= 0; else if (eType == GDT_Int8 || eType == GDT_Int16 || eType == GDT_Int32) bOK &= VSIFPrintfL(fp, "PIXELTYPE SIGNEDINT\n") >= 0; - else if (eType == GDT_Byte && EQUAL(pszPixelType, "SIGNEDBYTE")) + else if (eType == GDT_UInt8 && EQUAL(pszPixelType, "SIGNEDBYTE")) bOK &= VSIFPrintfL(fp, "PIXELTYPE SIGNEDINT\n") >= 0; else bOK &= VSIFPrintfL(fp, "PIXELTYPE UNSIGNEDINT\n") >= 0; @@ -1779,7 +1779,7 @@ GDALDataset *EHdrDataset::CreateCopy(const char *pszFilename, poSrcBand->GetMetadataItem("NBITS", "IMAGE_STRUCTURE")); } - if (poSrcBand->GetRasterDataType() == GDT_Byte && + if (poSrcBand->GetRasterDataType() == GDT_UInt8 && CSLFetchNameValue(papszOptions, "PIXELTYPE") == nullptr) { poSrcBand->EnablePixelTypeSignedByteWarning(false); diff --git a/frmts/raw/eirdataset.cpp b/frmts/raw/eirdataset.cpp index 38474748d27d..151cef9af660 100644 --- a/frmts/raw/eirdataset.cpp +++ b/frmts/raw/eirdataset.cpp @@ -274,7 +274,7 @@ GDALDataset *EIRDataset::Open(GDALOpenInfo *poOpenInfo) int nBands = 1; int nSkipBytes = 0; int nLineCount = 0; - GDALDataType eDataType = GDT_Byte; + GDALDataType eDataType = GDT_UInt8; int nBits = 8; char chByteOrder = 'M'; char szLayout[10] = "BIL"; @@ -347,7 +347,7 @@ GDALDataset *EIRDataset::Open(GDALOpenInfo *poOpenInfo) EQUAL(aosTokens[1], "U4") || EQUAL(aosTokens[1], "U8")) { nBits = 8; - eDataType = GDT_Byte; + eDataType = GDT_UInt8; } else if (EQUAL(aosTokens[1], "U16")) { diff --git a/frmts/raw/envidataset.cpp b/frmts/raw/envidataset.cpp index 4db92f554c17..6a3b99d78d97 100644 --- a/frmts/raw/envidataset.cpp +++ b/frmts/raw/envidataset.cpp @@ -2047,7 +2047,7 @@ ENVIDataset *ENVIDataset::Open(GDALOpenInfo *poOpenInfo, bool bFileSizeCheck) atoi(poDS->m_aosHeader.FetchNameValueDef("header_offset", "0")); // Translate the datatype. - GDALDataType eType = GDT_Byte; + GDALDataType eType = GDT_UInt8; const char *pszDataType = poDS->m_aosHeader["data_type"]; if (pszDataType != nullptr) @@ -2055,7 +2055,7 @@ ENVIDataset *ENVIDataset::Open(GDALOpenInfo *poOpenInfo, bool bFileSizeCheck) switch (atoi(pszDataType)) { case 1: - eType = GDT_Byte; + eType = GDT_UInt8; break; case 2: @@ -2343,7 +2343,7 @@ int ENVIDataset::GetEnviType(GDALDataType eType) int iENVIType = 1; switch (eType) { - case GDT_Byte: + case GDT_UInt8: iENVIType = 1; break; case GDT_Int16: diff --git a/frmts/raw/fastdataset.cpp b/frmts/raw/fastdataset.cpp index 9f4878620084..92c5a020f8d8 100644 --- a/frmts/raw/fastdataset.cpp +++ b/frmts/raw/fastdataset.cpp @@ -783,7 +783,7 @@ GDALDataset *FASTDataset::Open(GDALOpenInfo *poOpenInfo) { case 8: default: - poDS->eDataType = GDT_Byte; + poDS->eDataType = GDT_UInt8; break; // For a strange reason, some Euromap products declare 10 bits // output, but are 16 bits. @@ -796,7 +796,7 @@ GDALDataset *FASTDataset::Open(GDALOpenInfo *poOpenInfo) } else { - poDS->eDataType = GDT_Byte; + poDS->eDataType = GDT_UInt8; } } diff --git a/frmts/raw/genbindataset.cpp b/frmts/raw/genbindataset.cpp index baf9a71f0826..c9833d0aeef8 100644 --- a/frmts/raw/genbindataset.cpp +++ b/frmts/raw/genbindataset.cpp @@ -97,7 +97,7 @@ GenBinBitRasterBand::GenBinBitRasterBand(GenBinDataset *poDSIn, int nBitsIn) poDS = poDSIn; nBand = 1; - eDataType = GDT_Byte; + eDataType = GDT_UInt8; nBlockXSize = poDSIn->nRasterXSize; nBlockYSize = 1; @@ -540,7 +540,7 @@ GDALDataset *GenBinDataset::Open(GDALOpenInfo *poOpenInfo) /* Figure out the data type. */ /* -------------------------------------------------------------------- */ const char *pszDataType = CSLFetchNameValue(papszHdr, "DATATYPE"); - GDALDataType eDataType = GDT_Byte; + GDALDataType eDataType = GDT_UInt8; int nBits = -1; // Only needed for partial byte types if (pszDataType == nullptr) diff --git a/frmts/raw/hkvdataset.cpp b/frmts/raw/hkvdataset.cpp index a48d8adbb444..e4299f242440 100644 --- a/frmts/raw/hkvdataset.cpp +++ b/frmts/raw/hkvdataset.cpp @@ -843,7 +843,7 @@ GDALDataset *HKVDataset::Open(GDALOpenInfo *poOpenInfo) GDALDataType eType; if (nSize == 1) - eType = GDT_Byte; + eType = GDT_UInt8; else if (nSize == 2 && strstr(pszEncoding, "*unsigned") != nullptr) eType = GDT_UInt16; else if (nSize == 4 && bComplex) diff --git a/frmts/raw/krodataset.cpp b/frmts/raw/krodataset.cpp index 7aae83bce03c..206cdb03fc2c 100644 --- a/frmts/raw/krodataset.cpp +++ b/frmts/raw/krodataset.cpp @@ -156,7 +156,7 @@ GDALDataset *KRODataset::Open(GDALOpenInfo *poOpenInfo) GDALDataType eDT = GDT_Unknown; if (nDepth == 8) { - eDT = GDT_Byte; + eDT = GDT_UInt8; } else if (nDepth == 16) { @@ -238,7 +238,7 @@ GDALDataset *KRODataset::Create(const char *pszFilename, int nXSize, int nYSize, int nBandsIn, GDALDataType eType, char ** /* papszOptions */) { - if (eType != GDT_Byte && eType != GDT_UInt16 && eType != GDT_Float32) + if (eType != GDT_UInt8 && eType != GDT_UInt16 && eType != GDT_Float32) { CPLError(CE_Failure, CPLE_AppDefined, "Attempt to create KRO file with unsupported data type '%s'.", diff --git a/frmts/raw/landataset.cpp b/frmts/raw/landataset.cpp index 108bce92cee0..a7dd098b2c8a 100644 --- a/frmts/raw/landataset.cpp +++ b/frmts/raw/landataset.cpp @@ -161,7 +161,7 @@ LAN4BitRasterBand::LAN4BitRasterBand(LANDataset *poDSIn, int nBandIn) { poDS = poDSIn; nBand = nBandIn; - eDataType = GDT_Byte; + eDataType = GDT_UInt8; nBlockXSize = poDSIn->GetRasterXSize(); nBlockYSize = 1; @@ -433,12 +433,12 @@ GDALDataset *LANDataset::Open(GDALOpenInfo *poOpenInfo) GDALDataType eDataType = GDT_Unknown; if (nTmp16 == 0) { - eDataType = GDT_Byte; + eDataType = GDT_UInt8; nPixelOffset = 1; } else if (nTmp16 == 1) // 4 bit { - eDataType = GDT_Byte; + eDataType = GDT_UInt8; nPixelOffset = -1; } else if (nTmp16 == 2) @@ -700,7 +700,7 @@ void LANDataset::CheckForStatistics() GInt16 nMin = 0; GInt16 nMax = 0; - if (poBand->GetRasterDataType() != GDT_Byte) + if (poBand->GetRasterDataType() != GDT_UInt8) { memcpy(&nMin, abyBandInfo + 28, 2); memcpy(&nMax, abyBandInfo + 30, 2); diff --git a/frmts/raw/mffdataset.cpp b/frmts/raw/mffdataset.cpp index 44cb032e54df..d68f5c7fd082 100644 --- a/frmts/raw/mffdataset.cpp +++ b/frmts/raw/mffdataset.cpp @@ -825,7 +825,7 @@ GDALDataset *MFFDataset::Open(GDALOpenInfo *poOpenInfo) else if (EQUAL(pszRefinedType, "R*8")) eDataType = GDT_Float64; else if (EQUAL(pszRefinedType, "I*1")) - eDataType = GDT_Byte; + eDataType = GDT_UInt8; else if (EQUAL(pszRefinedType, "I*2")) eDataType = GDT_Int16; else if (EQUAL(pszRefinedType, "I*4")) @@ -863,7 +863,7 @@ GDALDataset *MFFDataset::Open(GDALOpenInfo *poOpenInfo) } else if (STARTS_WITH_CI(osExt.c_str(), "b")) { - eDataType = GDT_Byte; + eDataType = GDT_UInt8; } else if (STARTS_WITH_CI(osExt.c_str(), "i")) { diff --git a/frmts/raw/ndfdataset.cpp b/frmts/raw/ndfdataset.cpp index 0004a2a69986..beff7ab51d37 100644 --- a/frmts/raw/ndfdataset.cpp +++ b/frmts/raw/ndfdataset.cpp @@ -302,7 +302,7 @@ GDALDataset *NDFDataset::Open(GDALOpenInfo *poOpenInfo) poDS->papszExtraFiles = CSLAddString(poDS->papszExtraFiles, osFilename); auto poBand = RawRasterBand::Create( - poDS.get(), iBand + 1, fpRaw, 0, 1, poDS->nRasterXSize, GDT_Byte, + poDS.get(), iBand + 1, fpRaw, 0, 1, poDS->nRasterXSize, GDT_UInt8, RawRasterBand::ByteOrder::ORDER_LITTLE_ENDIAN, RawRasterBand::OwnFP::YES); if (!poBand) diff --git a/frmts/raw/nsidcbindataset.cpp b/frmts/raw/nsidcbindataset.cpp index 753ee3e2d446..6d1ed3271813 100644 --- a/frmts/raw/nsidcbindataset.cpp +++ b/frmts/raw/nsidcbindataset.cpp @@ -308,7 +308,7 @@ GDALDataset *NSIDCbinDataset::Open(GDALOpenInfo *poOpenInfo) auto poBand = std::make_unique( poDS.get(), 1, poDS->fp, 300, nBytesPerSample, poDS->nRasterXSize, - GDT_Byte); + GDT_UInt8); if (!poBand->IsValid()) return nullptr; poDS->SetBand(1, std::move(poBand)); diff --git a/frmts/raw/pauxdataset.cpp b/frmts/raw/pauxdataset.cpp index eac3cef9b82c..79a81036ef87 100644 --- a/frmts/raw/pauxdataset.cpp +++ b/frmts/raw/pauxdataset.cpp @@ -655,7 +655,7 @@ GDALDataset *PAuxDataset::Open(GDALOpenInfo *poOpenInfo) else if (EQUAL(aosTokensBand[0], "32R")) eType = GDT_Float32; else - eType = GDT_Byte; + eType = GDT_UInt8; bool bNative = true; if (CSLCount(aosTokensBand) > 4) diff --git a/frmts/raw/pnmdataset.cpp b/frmts/raw/pnmdataset.cpp index 653dd138df2e..f05e48199d9f 100644 --- a/frmts/raw/pnmdataset.cpp +++ b/frmts/raw/pnmdataset.cpp @@ -220,7 +220,7 @@ GDALDataset *PNMDataset::Open(GDALOpenInfo *poOpenInfo) GDALDataType eDataType = GDT_Unknown; if (nMaxValue < 256) - eDataType = GDT_Byte; + eDataType = GDT_UInt8; else eDataType = GDT_UInt16; @@ -296,7 +296,7 @@ GDALDataset *PNMDataset::Create(const char *pszFilename, int nXSize, int nYSize, /* -------------------------------------------------------------------- */ /* Verify input options. */ /* -------------------------------------------------------------------- */ - if (eType != GDT_Byte && eType != GDT_UInt16) + if (eType != GDT_UInt8 && eType != GDT_UInt16) { CPLError(CE_Failure, CPLE_AppDefined, "Attempt to create PNM dataset with an illegal " @@ -353,14 +353,14 @@ GDALDataset *PNMDataset::Create(const char *pszFilename, int nXSize, int nYSize, if (pszMaxValue) { nMaxValue = atoi(pszMaxValue); - if (eType == GDT_Byte && (nMaxValue > 255 || nMaxValue < 0)) + if (eType == GDT_UInt8 && (nMaxValue > 255 || nMaxValue < 0)) nMaxValue = 255; else if (nMaxValue > 65535 || nMaxValue < 0) nMaxValue = 65535; } else { - if (eType == GDT_Byte) + if (eType == GDT_UInt8) nMaxValue = 255; else nMaxValue = 65535; diff --git a/frmts/raw/roipacdataset.cpp b/frmts/raw/roipacdataset.cpp index 59457c050a45..8b9e602a852d 100644 --- a/frmts/raw/roipacdataset.cpp +++ b/frmts/raw/roipacdataset.cpp @@ -304,7 +304,7 @@ GDALDataset *ROIPACDataset::Open(GDALOpenInfo *poOpenInfo) } else if (strcmp(pszExtension, "flg") == 0) { - eDataType = GDT_Byte; + eDataType = GDT_UInt8; nBands = 1; eInterleave = PIXEL; } @@ -595,7 +595,7 @@ GDALDataset *ROIPACDataset::Create(const char *pszFilename, int nXSize, } else if (strcmp(pszExtension, "flg") == 0) { - if (nBandsIn != 1 || eType != GDT_Byte) + if (nBandsIn != 1 || eType != GDT_UInt8) { CPLError(CE_Failure, CPLE_AppDefined, "Attempt to create ROI_PAC %s dataset with an illegal " diff --git a/frmts/raw/rrasterdataset.cpp b/frmts/raw/rrasterdataset.cpp index 511f63967aee..820ec80320b8 100644 --- a/frmts/raw/rrasterdataset.cpp +++ b/frmts/raw/rrasterdataset.cpp @@ -330,7 +330,7 @@ static void GetMinMax(const void *pBuffer, GDALDataType eDT, int nBufXSize, { switch (eDT) { - case GDT_Byte: + case GDT_UInt8: GetMinMax(static_cast(pBuffer), nBufXSize, nBufYSize, nPixelSpace, nLineSpace, dfNoDataValue, dfMin, dfMax); break; @@ -521,7 +521,7 @@ void RRASTERDataset::RewriteHeader() GDALDataType eDT = GetRasterBand(1)->GetRasterDataType(); VSIFPrintfL(fp, "datatype=%s\n", (eDT == GDT_Int8 || m_bSignedByte) ? "INT1S" - : (eDT == GDT_Byte) ? "INT1U" + : (eDT == GDT_UInt8) ? "INT1U" : (eDT == GDT_UInt16) ? "INT2U" : (eDT == GDT_UInt32) ? "INT4U" : (eDT == GDT_Int16) ? "INT2S" @@ -1115,7 +1115,7 @@ GDALDataset *RRASTERDataset::Open(GDALOpenInfo *poOpenInfo) GDALDataType eDT = GDT_Unknown; if (EQUAL(osDataType, "LOG1S")) - eDT = GDT_Byte; // mapping TBC + eDT = GDT_UInt8; // mapping TBC else if (EQUAL(osDataType, "INT1S")) eDT = GDT_Int8; else if (EQUAL(osDataType, "INT2S")) @@ -1125,7 +1125,7 @@ GDALDataset *RRASTERDataset::Open(GDALOpenInfo *poOpenInfo) // else if( EQUAL(osDataType, "INT8S") ) // eDT = GDT_UInt64; // unhandled else if (EQUAL(osDataType, "INT1U")) - eDT = GDT_Byte; + eDT = GDT_UInt8; else if (EQUAL(osDataType, "INT2U")) eDT = GDT_UInt16; else if (EQUAL(osDataType, "INT4U")) // Not documented @@ -1406,7 +1406,7 @@ GDALDataset *RRASTERDataset::Create(const char *pszFilename, int nXSize, return nullptr; } - if (eType != GDT_Byte && eType != GDT_Int8 && eType != GDT_UInt16 && + if (eType != GDT_UInt8 && eType != GDT_Int8 && eType != GDT_UInt16 && eType != GDT_Int16 && eType != GDT_Int32 && eType != GDT_UInt32 && eType != GDT_Float32 && eType != GDT_Float64) { @@ -1461,7 +1461,7 @@ GDALDataset *RRASTERDataset::Create(const char *pszFilename, int nXSize, poDS->m_bInitRaster = CPLFetchBool(papszOptions, "@INIT_RASTER", true); const char *pszPixelType = CSLFetchNameValue(papszOptions, "PIXELTYPE"); - const bool bByteSigned = (eType == GDT_Byte && pszPixelType && + const bool bByteSigned = (eType == GDT_UInt8 && pszPixelType && EQUAL(pszPixelType, "SIGNEDBYTE")); if (bByteSigned) poDS->m_bSignedByte = true; diff --git a/frmts/rcm/rcmdataset.cpp b/frmts/rcm/rcmdataset.cpp index 7a4a19e2ed0b..b1c8961f2dd9 100644 --- a/frmts/rcm/rcmdataset.cpp +++ b/frmts/rcm/rcmdataset.cpp @@ -913,7 +913,7 @@ CPLErr RCMCalibRasterBand::IReadBlock(int nBlockXOff, int nBlockYOff, CPLFree(panImageTmp); } /* Ticket #2104: Support for ScanSAR products */ - else if (this->m_eOriginalType == GDT_Byte) + else if (this->m_eOriginalType == GDT_UInt8) { GByte *pabyImageTmp = static_cast(VSI_MALLOC2_VERBOSE(nBlockXSize, nBlockYSize)); @@ -922,7 +922,7 @@ CPLErr RCMCalibRasterBand::IReadBlock(int nBlockXOff, int nBlockYOff, eErr = m_poBandDataset->RasterIO( GF_Read, nBlockXOff * nBlockXSize, nBlockYOff * nBlockYSize, nRequestXSize, nRequestYSize, pabyImageTmp, nRequestXSize, - nRequestYSize, GDT_Byte, 1, nullptr, 1, nBlockXSize, 0, nullptr); + nRequestYSize, GDT_UInt8, 1, nullptr, 1, nBlockXSize, 0, nullptr); /* iterate over detected values */ for (int i = 0; i < nRequestYSize; i++) diff --git a/frmts/rik/rikdataset.cpp b/frmts/rik/rikdataset.cpp index 1ce30d20858a..98932c3e1038 100644 --- a/frmts/rik/rikdataset.cpp +++ b/frmts/rik/rikdataset.cpp @@ -161,7 +161,7 @@ RIKRasterBand::RIKRasterBand(RIKDataset *poDSIn, int nBandIn) poDS = poDSIn; nBand = nBandIn; - eDataType = GDT_Byte; + eDataType = GDT_UInt8; nBlockXSize = poDSIn->nBlockXSize; nBlockYSize = poDSIn->nBlockYSize; diff --git a/frmts/rmf/rmfdataset.cpp b/frmts/rmf/rmfdataset.cpp index e0ca8ef59ffa..f75856c13365 100644 --- a/frmts/rmf/rmfdataset.cpp +++ b/frmts/rmf/rmfdataset.cpp @@ -1640,7 +1640,7 @@ RMFDataset *RMFDataset::Open(GDALOpenInfo *poOpenInfo, RMFDataset *poParentDS, /* -------------------------------------------------------------------- */ /* Set up essential image parameters. */ /* -------------------------------------------------------------------- */ - GDALDataType eType = GDT_Byte; + GDALDataType eType = GDT_UInt8; poDS->nRasterXSize = poDS->sHeader.nWidth; poDS->nRasterYSize = poDS->sHeader.nHeight; @@ -1728,14 +1728,14 @@ RMFDataset *RMFDataset::Open(GDALOpenInfo *poOpenInfo, RMFDataset *poParentDS, delete poDS; return nullptr; } - eType = GDT_Byte; + eType = GDT_UInt8; } else { poDS->nBands = 1; if (poDS->sHeader.nBitDepth == 8) { - eType = GDT_Byte; + eType = GDT_UInt8; } else if (poDS->sHeader.nBitDepth == 16) { @@ -2056,7 +2056,7 @@ GDALDataset *RMFDataset::Create(const char *pszFilename, int nXSize, int nYSize, return nullptr; } - if (nBandsIn == 1 && eType != GDT_Byte && eType != GDT_Int16 && + if (nBandsIn == 1 && eType != GDT_UInt8 && eType != GDT_Int16 && eType != GDT_Int32 && eType != GDT_Float64) { CPLError( @@ -2069,7 +2069,7 @@ GDALDataset *RMFDataset::Create(const char *pszFilename, int nXSize, int nYSize, return nullptr; } - if (nBandsIn == 3 && eType != GDT_Byte) + if (nBandsIn == 3 && eType != GDT_UInt8) { CPLError( CE_Failure, CPLE_AppDefined, @@ -2801,7 +2801,7 @@ int RMFDataset::SetupCompression(GDALDataType eType, const char *pszFilename) } else if (sHeader.iCompression == RMF_COMPRESSION_JPEG) { - if (eType != GDT_Byte || nBands != RMF_JPEG_BAND_COUNT || + if (eType != GDT_UInt8 || nBands != RMF_JPEG_BAND_COUNT || sHeader.nBitDepth != 24) { CPLError(CE_Failure, CPLE_AppDefined, diff --git a/frmts/rmf/rmfjpeg.cpp b/frmts/rmf/rmfjpeg.cpp index 0df7768d75b6..4468d8613e16 100644 --- a/frmts/rmf/rmfjpeg.cpp +++ b/frmts/rmf/rmfjpeg.cpp @@ -93,7 +93,7 @@ size_t RMFDataset::JPEGDecompress(const GByte *pabyIn, GUInt32 nSizeIn, size_t nRet; int aBandMap[RMF_JPEG_BAND_COUNT] = {3, 2, 1}; eErr = GDALDatasetRasterIO(hTile, GF_Read, 0, 0, nImageWidth, nImageHeight, - pabyOut, nImageWidth, nImageHeight, GDT_Byte, + pabyOut, nImageWidth, nImageHeight, GDT_UInt8, nBandCount, aBandMap, nBandCount, nRawXSize * nBandCount, 1); if (CE_None != eErr) @@ -134,7 +134,7 @@ size_t RMFDataset::JPEGCompress(const GByte *pabyIn, GUInt32 nSizeIn, return 0; } - const GDALDataType eType = GDT_Byte; + const GDALDataType eType = GDT_UInt8; auto poMemDS = std::unique_ptr( MEMDataset::Create("", nRawXSize, nRawYSize, 0, eType, nullptr)); diff --git a/frmts/rs2/rs2dataset.cpp b/frmts/rs2/rs2dataset.cpp index 779e63608b51..9feb9934160a 100644 --- a/frmts/rs2/rs2dataset.cpp +++ b/frmts/rs2/rs2dataset.cpp @@ -280,12 +280,12 @@ CPLErr RS2RasterBand::IReadBlock(int nBlockXOff, int nBlockYOff, void *pImage) GF_Read, nBlockXOff * nBlockXSize, nBlockYOff * nBlockYSize, nRequestXSize, nRequestYSize, pImage, nRequestXSize, nRequestYSize, GDT_UInt16, 1, nullptr, 2, nBlockXSize * 2, 0, nullptr); - else if (eDataType == GDT_Byte) + else if (eDataType == GDT_UInt8) /* Ticket #2104: Support for ScanSAR products */ return poBandFile->RasterIO( GF_Read, nBlockXOff * nBlockXSize, nBlockYOff * nBlockYSize, nRequestXSize, nRequestYSize, pImage, nRequestXSize, nRequestYSize, - GDT_Byte, 1, nullptr, 1, nBlockXSize, 0, nullptr); + GDT_UInt8, 1, nullptr, 1, nBlockXSize, 0, nullptr); CPLAssert(false); return CE_Failure; @@ -518,14 +518,14 @@ CPLErr RS2CalibRasterBand::IReadBlock(int nBlockXOff, int nBlockYOff, } CPLFree(pnImageTmp); } /* Ticket #2104: Support for ScanSAR products */ - else if (m_eType == GDT_Byte) + else if (m_eType == GDT_UInt8) { GByte *pnImageTmp = reinterpret_cast( CPLMalloc(static_cast(nBlockXSize) * nBlockYSize)); eErr = m_poBandDataset->RasterIO( GF_Read, nBlockXOff * nBlockXSize, nBlockYOff * nBlockYSize, nBlockXSize, nRequestYSize, pnImageTmp, nBlockXSize, nRequestYSize, - GDT_Byte, 1, nullptr, 1, 1, 0, nullptr); + GDT_UInt8, 1, nullptr, 1, 1, 0, nullptr); /* iterate over detected values */ for (int i = 0; i < nBlockYSize; i++) @@ -828,7 +828,7 @@ GDALDataset *RS2Dataset::Open(GDALOpenInfo *poOpenInfo) else if (nBitsPerSample == 16 && STARTS_WITH_CI(pszDataType, "Mag")) eDataType = GDT_UInt16; else if (nBitsPerSample == 8 && STARTS_WITH_CI(pszDataType, "Mag")) - eDataType = GDT_Byte; + eDataType = GDT_UInt8; else { CPLError( diff --git a/frmts/safe/safedataset.cpp b/frmts/safe/safedataset.cpp index c922af909901..1ae47dab074a 100644 --- a/frmts/safe/safedataset.cpp +++ b/frmts/safe/safedataset.cpp @@ -123,11 +123,11 @@ CPLErr SAFERasterBand::IReadBlock(int nBlockXOff, int nBlockYOff, void *pImage) nRequestXSize, nRequestYSize, pImage, nRequestXSize, nRequestYSize, GDT_UInt16, 1, nullptr, 2, nBlockXSize * 2, 0, nullptr); - else if (eDataType == GDT_Byte) + else if (eDataType == GDT_UInt8) return poBandFile->RasterIO( GF_Read, nBlockXOff * nBlockXSize, nBlockYOff * nBlockYSize, nRequestXSize, nRequestYSize, pImage, nRequestXSize, nRequestYSize, - GDT_Byte, 1, nullptr, 1, nBlockXSize, 0, nullptr); + GDT_UInt8, 1, nullptr, 1, nBlockXSize, 0, nullptr); CPLAssert(false); return CE_Failure; @@ -591,11 +591,11 @@ CPLErr SAFECalibratedRasterBand::IReadBlock(int nBlockXOff, int nBlockYOff, CPLFree(pnImageTmp); return eErr; } - else if (eDataType == GDT_Byte) // Check if this is required. + else if (eDataType == GDT_UInt8) // Check if this is required. return poBandDataset->RasterIO( GF_Read, nBlockXOff * nBlockXSize, nBlockYOff * nBlockYSize, nRequestXSize, nRequestYSize, pImage, nRequestXSize, nRequestYSize, - GDT_Byte, 1, nullptr, 1, nBlockXSize, 0, nullptr); + GDT_UInt8, 1, nullptr, 1, nBlockXSize, 0, nullptr); CPLAssert(false); return CE_Failure; diff --git a/frmts/saga/sagadataset.cpp b/frmts/saga/sagadataset.cpp index 5f0800488960..ffdd011ae815 100644 --- a/frmts/saga/sagadataset.cpp +++ b/frmts/saga/sagadataset.cpp @@ -31,7 +31,7 @@ /* NODATA Values */ // #define SG_NODATA_GDT_Bit 0.0 -constexpr GByte SG_NODATA_GDT_Byte = 255; +constexpr GByte SG_NODATA_GDT_UInt8 = 255; #define SG_NODATA_GDT_UInt16 65535 #define SG_NODATA_GDT_Int16 -32767 #define SG_NODATA_GDT_UInt32 4294967295U @@ -597,17 +597,17 @@ GDALDataset *SAGADataset::Open(GDALOpenInfo *poOpenInfo) /* -------------------------------------------------------------------- */ if (EQUAL(szDataFormat, "BIT")) { - poBand->SetDataType(GDT_Byte); + poBand->SetDataType(GDT_UInt8); poBand->m_nBits = 8; } else if (EQUAL(szDataFormat, "BYTE_UNSIGNED")) { - poBand->SetDataType(GDT_Byte); + poBand->SetDataType(GDT_UInt8); poBand->m_nBits = 8; } else if (EQUAL(szDataFormat, "BYTE")) { - poBand->SetDataType(GDT_Byte); + poBand->SetDataType(GDT_UInt8); poBand->m_nBits = 8; } else if (EQUAL(szDataFormat, "SHORTINT_UNSIGNED")) @@ -801,7 +801,7 @@ CPLErr SAGADataset::WriteHeader(const CPLString &osHDRFilename, VSIFPrintfL(fp, "DATAFORMAT\t= SHORTINT\n"); else if (eType == GDT_UInt16) VSIFPrintfL(fp, "DATAFORMAT\t= SHORTINT_UNSIGNED\n"); - else if (eType == GDT_Byte) + else if (eType == GDT_UInt8) VSIFPrintfL(fp, "DATAFORMAT\t= BYTE_UNSIGNED\n"); else if (eType == GDT_Float32) VSIFPrintfL(fp, "DATAFORMAT\t= FLOAT\n"); @@ -855,7 +855,7 @@ GDALDataset *SAGADataset::Create(const char *pszFilename, int nXSize, return nullptr; } - if (eType != GDT_Byte && eType != GDT_UInt16 && eType != GDT_Int16 && + if (eType != GDT_UInt8 && eType != GDT_UInt16 && eType != GDT_Int16 && eType != GDT_UInt32 && eType != GDT_Int32 && eType != GDT_Float32 && eType != GDT_Float64) { @@ -887,11 +887,11 @@ GDALDataset *SAGADataset::Create(const char *pszFilename, int nXSize, } else { - switch (eType) /* GDT_Byte, GDT_UInt16, GDT_Int16, GDT_UInt32 */ + switch (eType) /* GDT_UInt8, GDT_UInt16, GDT_Int16, GDT_UInt32 */ { /* GDT_Int32, GDT_Float32, GDT_Float64 */ - case (GDT_Byte): + case (GDT_UInt8): { - dfNoDataVal = SG_NODATA_GDT_Byte; + dfNoDataVal = SG_NODATA_GDT_UInt8; break; } case (GDT_UInt16): diff --git a/frmts/sentinel2/sentinel2dataset.cpp b/frmts/sentinel2/sentinel2dataset.cpp index b4dba942eda8..b50b1a48b1b2 100644 --- a/frmts/sentinel2/sentinel2dataset.cpp +++ b/frmts/sentinel2/sentinel2dataset.cpp @@ -4057,7 +4057,7 @@ SENTINEL2Dataset *SENTINEL2Dataset::CreateL1CL2ADataset( ? 3 : ((bAlpha) ? 1 : 0) + static_cast(aosBands.size()); const int nAlphaBand = (bIsPreview || bIsTCI || !bAlpha) ? 0 : nBands; - const GDALDataType eDT = (bIsPreview || bIsTCI) ? GDT_Byte : GDT_UInt16; + const GDALDataType eDT = (bIsPreview || bIsTCI) ? GDT_UInt8 : GDT_UInt16; for (int nBand = 1; nBand <= nBands; nBand++) { diff --git a/frmts/srtmhgt/srtmhgtdataset.cpp b/frmts/srtmhgt/srtmhgtdataset.cpp index 36122ebc1b7e..11933f40a650 100644 --- a/frmts/srtmhgt/srtmhgtdataset.cpp +++ b/frmts/srtmhgt/srtmhgtdataset.cpp @@ -172,7 +172,7 @@ CPLErr SRTMHGTRasterBand::IWriteBlock(int /*nBlockXOff*/, int nBlockYOff, double SRTMHGTRasterBand::GetNoDataValue(int *pbSuccess) { - if (eDataType == GDT_Byte) + if (eDataType == GDT_UInt8) return GDALPamRasterBand::GetNoDataValue(pbSuccess); if (pbSuccess) @@ -446,7 +446,7 @@ GDALPamDataset *SRTMHGTDataset::OpenPAM(GDALOpenInfo *poOpenInfo) break; case 3601 * 3601: numPixels_x = numPixels_y = 3601; - eDT = GDT_Byte; + eDT = GDT_UInt8; break; case 3601 * 3601 * 2: numPixels_x = numPixels_y = 3601; @@ -465,7 +465,7 @@ GDALPamDataset *SRTMHGTDataset::OpenPAM(GDALOpenInfo *poOpenInfo) poDS->eAccess = poOpenInfo->eAccess; #ifdef CPL_LSB - if (poDS->eAccess == GA_Update && eDT != GDT_Byte) + if (poDS->eAccess == GA_Update && eDT != GDT_UInt8) { poDS->pabyBuffer = static_cast(CPLMalloc(numPixels_x * sizeof(eDT))); diff --git a/frmts/stacta/stactadataset.cpp b/frmts/stacta/stactadataset.cpp index d8fb47de6dae..9c3a653d7c77 100644 --- a/frmts/stacta/stactadataset.cpp +++ b/frmts/stacta/stactadataset.cpp @@ -1076,7 +1076,7 @@ bool STACTADataset::Open(GDALOpenInfo *poOpenInfo) {"int16", GDT_Int16}, {"int32", GDT_Int32}, {"int64", GDT_Int64}, - {"uint8", GDT_Byte}, + {"uint8", GDT_UInt8}, {"uint16", GDT_UInt16}, {"uint32", GDT_UInt32}, {"uint64", GDT_UInt64}, @@ -1407,7 +1407,7 @@ bool STACTADataset::Open(GDALOpenInfo *poOpenInfo) oBands.IsValid() ? "raster:bits_per_sample" : "bits_per_sample"); if (((nBitsPerSample >= 1 && nBitsPerSample <= 7) && - poBand->GetRasterDataType() == GDT_Byte) || + poBand->GetRasterDataType() == GDT_UInt8) || ((nBitsPerSample >= 9 && nBitsPerSample <= 15) && poBand->GetRasterDataType() == GDT_UInt16)) { diff --git a/frmts/tga/tgadataset.cpp b/frmts/tga/tgadataset.cpp index a8d5a8a864a9..4d5106221911 100644 --- a/frmts/tga/tgadataset.cpp +++ b/frmts/tga/tgadataset.cpp @@ -700,9 +700,10 @@ GDALDataset *GDALTGADataset::Open(GDALOpenInfo *poOpenInfo) delete poDS; return nullptr; } - poDS->SetBand( - 1, new GDALTGARasterBand( - poDS, 1, sHeader.nPixelDepth == 16 ? GDT_UInt16 : GDT_Byte)); + poDS->SetBand(1, new GDALTGARasterBand(poDS, 1, + sHeader.nPixelDepth == 16 + ? GDT_UInt16 + : GDT_UInt8)); } else { @@ -718,7 +719,7 @@ GDALDataset *GDALTGADataset::Open(GDALOpenInfo *poOpenInfo) sHeader.nPixelDepth == 16 ? 3 : (3 + (hasFourthChannel ? 1 : 0)); for (int iBand = 1; iBand <= l_nBands; iBand++) { - poDS->SetBand(iBand, new GDALTGARasterBand(poDS, iBand, GDT_Byte)); + poDS->SetBand(iBand, new GDALTGARasterBand(poDS, iBand, GDT_UInt8)); } } diff --git a/frmts/tiledb/tiledbdense.cpp b/frmts/tiledb/tiledbdense.cpp index 2a205d349709..00741c7ba2f4 100644 --- a/frmts/tiledb/tiledbdense.cpp +++ b/frmts/tiledb/tiledbdense.cpp @@ -110,7 +110,7 @@ static CPLErr SetBuffer(tiledb::Query *poQuery, GDALDataType eType, { switch (eType) { - case GDT_Byte: + case GDT_UInt8: poQuery->set_data_buffer( osAttrName, reinterpret_cast(pImage), nSize); break; @@ -196,7 +196,7 @@ TileDBRasterBand::TileDBRasterBand(TileDBRasterDataset *poDSIn, int nBandIn, eDataType = GDT_Int8; break; case TILEDB_UINT8: - eDataType = GDT_Byte; + eDataType = GDT_UInt8; break; case TILEDB_INT16: eDataType = @@ -491,7 +491,7 @@ double TileDBRasterBand::GetNoDataValue(int *pbHasNoData) { switch (eDataType) { - case GDT_Byte: + case GDT_UInt8: dfNoData = *static_cast(value); break; case GDT_Int8: @@ -584,7 +584,7 @@ CPLErr TileDBRasterBand::SetNoDataValue(double dfNoData) bool bIsValid = false; switch (eDataType) { - case GDT_Byte: + case GDT_UInt8: bIsValid = IsValidNoData(dfNoData); break; case GDT_Int8: @@ -1829,7 +1829,7 @@ CPLErr TileDBRasterDataset::CreateAttribute(GDALDataType eType, switch (eType) { - case GDT_Byte: + case GDT_UInt8: { m_schema->add_attribute(::CreateAttribute( *m_ctx, osName, *m_filterList, bHasFillValue, diff --git a/frmts/tiledb/tiledbmultidimarray.cpp b/frmts/tiledb/tiledbmultidimarray.cpp index 80bb3bab067a..628899ff3c8f 100644 --- a/frmts/tiledb/tiledbmultidimarray.cpp +++ b/frmts/tiledb/tiledbmultidimarray.cpp @@ -78,7 +78,7 @@ TileDBArray::TileDBDataTypeToGDALDataType(tiledb_datatype_t tiledb_dt) switch (tiledb_dt) { case TILEDB_UINT8: - eDT = GDT_Byte; + eDT = GDT_UInt8; break; case TILEDB_INT8: @@ -332,7 +332,7 @@ std::shared_ptr TileDBArray::OpenFromDisk( : schema.attribute(osAttributeName); GDALDataType eDT = TileDBDataTypeToGDALDataType(attr.type()); if (attr.type() == TILEDB_CHAR) - eDT = GDT_Byte; + eDT = GDT_UInt8; if (eDT == GDT_Unknown) { const char *pszTypeName = ""; @@ -1251,7 +1251,7 @@ FillBlockSize(const std::vector> &aoDimensions, { switch (dt) { - case GDT_Byte: + case GDT_UInt8: tiledb_dt = TILEDB_UINT8; break; case GDT_Int8: diff --git a/frmts/vrt/data/gdalvrt.xsd b/frmts/vrt/data/gdalvrt.xsd index 04506b04ee76..ed4c38f27ed1 100644 --- a/frmts/vrt/data/gdalvrt.xsd +++ b/frmts/vrt/data/gdalvrt.xsd @@ -425,6 +425,7 @@ + diff --git a/frmts/vrt/pixelfunctions.cpp b/frmts/vrt/pixelfunctions.cpp index 3d5c61d5f236..8e1438031f42 100644 --- a/frmts/vrt/pixelfunctions.cpp +++ b/frmts/vrt/pixelfunctions.cpp @@ -56,7 +56,7 @@ inline double GetSrcVal(const void *pSource, GDALDataType eSrcType, T ii) { case GDT_Unknown: return 0; - case GDT_Byte: + case GDT_UInt8: return static_cast(pSource)[ii]; case GDT_Int8: return static_cast(pSource)[ii]; @@ -791,7 +791,7 @@ static bool OptimizedSumPackedOutput(GDALDataType eSrcType, double dfK, { switch (eSrcType) { - case GDT_Byte: + case GDT_UInt8: OptimizedSumPackedOutput(dfK, pOutBuffer, nLineSpace, nXSize, nYSize, nSources, papoSources); @@ -927,7 +927,7 @@ static bool OptimizedSumThroughLargerType(GDALDataType eBufType, double dfK, { switch (eBufType) { - case GDT_Byte: + case GDT_UInt8: return OptimizedSumThroughLargerType( dfK, pOutBuffer, nPixelSpace, nLineSpace, nXSize, nYSize, nSources, papoSources); @@ -967,7 +967,7 @@ static bool OptimizedSumThroughLargerType(GDALDataType eSrcType, { switch (eSrcType) { - case GDT_Byte: + case GDT_UInt8: return OptimizedSumThroughLargerType( eBufType, dfK, pOutBuffer, nPixelSpace, nLineSpace, nXSize, nYSize, nSources, papoSources); @@ -1086,8 +1086,8 @@ static CPLErr SumPixelFunc(void **papoSources, int nSources, void *pData, if (dfNoData == 0 && !bPropagateNoData) { #ifdef USE_SSE2 - if (eBufType == GDT_Byte && nPixelSpace == sizeof(uint8_t) && - eSrcType == GDT_Byte && + if (eBufType == GDT_UInt8 && nPixelSpace == sizeof(uint8_t) && + eSrcType == GDT_UInt8 && dfK >= std::numeric_limits::min() && dfK <= std::numeric_limits::max() && static_cast(dfK) == dfK) @@ -1155,7 +1155,7 @@ static CPLErr SumPixelFunc(void **papoSources, int nSources, void *pData, } else if ( dfK >= 0 && dfK <= INT_MAX && eBufType == GDT_Int32 && - nPixelSpace == sizeof(int32_t) && eSrcType == GDT_Byte && + nPixelSpace == sizeof(int32_t) && eSrcType == GDT_UInt8 && // Limitation to avoid overflow of int32 if all source values are at the max of their data type nSources <= (INT_MAX - dfK) / std::numeric_limits::max()) @@ -2683,7 +2683,7 @@ static CPLErr MinPixelFunc(void **papoSources, int nSources, void *pData, eSrcType == eBufType && nPixelSpace == GDALGetDataTypeSizeBytes(eSrcType)) { - if (eSrcType == GDT_Byte) + if (eSrcType == GDT_UInt8) { OptimizedMinOrMaxSSE2( papoSources, nSources, pData, nXSize, nYSize, nLineSpace); @@ -2749,7 +2749,7 @@ static CPLErr MaxPixelFunc(void **papoSources, int nSources, void *pData, eSrcType == eBufType && nPixelSpace == GDALGetDataTypeSizeBytes(eSrcType)) { - if (eSrcType == GDT_Byte) + if (eSrcType == GDT_UInt8) { OptimizedMinOrMaxSSE2( papoSources, nSources, pData, nXSize, nYSize, nLineSpace); @@ -3578,7 +3578,7 @@ static CPLErr BasicPixelFunc(void **papoSources, int nSources, void *pData, #if defined(USE_SSE2) && !defined(USE_NEON_OPTIMIZATIONS) if constexpr (std::is_same_v) { - if (!bHasNoData && eSrcType == GDT_Byte && eBufType == GDT_Byte && + if (!bHasNoData && eSrcType == GDT_UInt8 && eBufType == GDT_UInt8 && nPixelSpace == 1 && // We use signed int16 to accumulate nSources <= std::numeric_limits::max() / @@ -3678,7 +3678,7 @@ static CPLErr BasicPixelFunc(void **papoSources, int nSources, void *pData, return CE_None; } - if (!bHasNoData && eSrcType == GDT_Byte && eBufType == GDT_Byte && + if (!bHasNoData && eSrcType == GDT_UInt8 && eBufType == GDT_UInt8 && nPixelSpace == 1 && // We use signed int32 to accumulate nSources <= std::numeric_limits::max() / diff --git a/frmts/vrt/vrtderivedrasterband.cpp b/frmts/vrt/vrtderivedrasterband.cpp index 73b7eff8ed74..a4e857b87889 100644 --- a/frmts/vrt/vrtderivedrasterband.cpp +++ b/frmts/vrt/vrtderivedrasterband.cpp @@ -68,7 +68,7 @@ static PyObject *GDALCreateNumpyArray(PyObject *pCreateArray, void *pBuffer, const char *pszDataType = nullptr; switch (eType) { - case GDT_Byte: + case GDT_UInt8: pszDataType = "uint8"; break; case GDT_Int8: diff --git a/frmts/vrt/vrtdriver.cpp b/frmts/vrt/vrtdriver.cpp index 38abe56f90c3..2a22cdec5fa0 100644 --- a/frmts/vrt/vrtdriver.cpp +++ b/frmts/vrt/vrtdriver.cpp @@ -280,7 +280,7 @@ static GDALDataset *VRTCreateCopy(const char *pszFilename, GDALDataset *poSrcDS, /* -------------------------------------------------------------------- */ auto poVRTDS = VRTDataset::CreateVRTDataset( pszFilename, poSrcDS->GetRasterXSize(), poSrcDS->GetRasterYSize(), 0, - GDT_Byte, papszOptions); + GDT_UInt8, papszOptions); if (poVRTDS == nullptr) return nullptr; diff --git a/frmts/vrt/vrtprocesseddatasetfunctions.cpp b/frmts/vrt/vrtprocesseddatasetfunctions.cpp index 3196ca57d3de..fadc91fb8e27 100644 --- a/frmts/vrt/vrtprocesseddatasetfunctions.cpp +++ b/frmts/vrt/vrtprocesseddatasetfunctions.cpp @@ -188,7 +188,7 @@ static CPLErr BandAffineCombinationInit( } else if (EQUAL(pszKey, "dst_intended_datatype")) { - for (GDALDataType eDT = GDT_Byte; eDT < GDT_TypeCount; + for (GDALDataType eDT = GDT_UInt8; eDT < GDT_TypeCount; eDT = static_cast(eDT + 1)) { if (EQUAL(GDALGetDataTypeName(eDT), pszValue)) diff --git a/frmts/vrt/vrtrasterband.cpp b/frmts/vrt/vrtrasterband.cpp index c96f512cba4c..19d8e1f9ed0b 100644 --- a/frmts/vrt/vrtrasterband.cpp +++ b/frmts/vrt/vrtrasterband.cpp @@ -62,7 +62,7 @@ void VRTRasterBand::Initialize(int nXSize, int nYSize) poDS = nullptr; nBand = 0; eAccess = GA_ReadOnly; - eDataType = GDT_Byte; + eDataType = GDT_UInt8; nRasterXSize = nXSize; nRasterYSize = nYSize; @@ -91,7 +91,7 @@ CPLErr VRTRasterBand::CopyCommonInfoFrom(GDALRasterBand *poSrcBand) const char *pszNBits = poSrcBand->GetMetadataItem("NBITS", "IMAGE_STRUCTURE"); SetMetadataItem("NBITS", pszNBits, "IMAGE_STRUCTURE"); - if (poSrcBand->GetRasterDataType() == GDT_Byte) + if (poSrcBand->GetRasterDataType() == GDT_UInt8) { poSrcBand->EnablePixelTypeSignedByteWarning(false); const char *pszPixelType = diff --git a/frmts/vrt/vrtsourcedrasterband.cpp b/frmts/vrt/vrtsourcedrasterband.cpp index 4f73d91534ff..a2bd5d05d8b4 100644 --- a/frmts/vrt/vrtsourcedrasterband.cpp +++ b/frmts/vrt/vrtsourcedrasterband.cpp @@ -1105,7 +1105,7 @@ double VRTSourcedRasterBand::GetMinimum(int *pbSuccess) if (iSource == 0 || dfSourceMin < dfMin) { dfMin = dfSourceMin; - if (dfMin == 0 && eDataType == GDT_Byte) + if (dfMin == 0 && eDataType == GDT_UInt8) break; } if (m_papoSources.size() > 1) @@ -1183,7 +1183,7 @@ double VRTSourcedRasterBand::GetMaximum(int *pbSuccess) if (iSource == 0 || dfSourceMax > dfMax) { dfMax = dfSourceMax; - if (dfMax == 255.0 && eDataType == GDT_Byte) + if (dfMax == 255.0 && eDataType == GDT_UInt8) break; } if (m_papoSources.size() > 1) @@ -1455,7 +1455,7 @@ CPLErr VRTSourcedRasterBand::ComputeRasterMinMax(int bApproxOK, } bool bSignedByte = false; - if (eDataType == GDT_Byte) + if (eDataType == GDT_UInt8) { EnablePixelTypeSignedByteWarning(false); const char *pszPixelType = @@ -1527,7 +1527,7 @@ CPLErr VRTSourcedRasterBand::ComputeRasterMinMax(int bApproxOK, } // Early exit if we know we reached theoretical bounds - if (eDataType == GDT_Byte && !bSignedByte && dfGlobalMin == 0.0 && + if (eDataType == GDT_UInt8 && !bSignedByte && dfGlobalMin == 0.0 && dfGlobalMax == 255.0) { break; diff --git a/frmts/vrt/vrtsources.cpp b/frmts/vrt/vrtsources.cpp index bcd81bc21705..09631f5fc954 100644 --- a/frmts/vrt/vrtsources.cpp +++ b/frmts/vrt/vrtsources.cpp @@ -2051,7 +2051,7 @@ CPLErr VRTAveragedSource::RasterIO(GDALDataType /*eVRTBandDataType*/, int nXOff, static_cast(pData) + nPixelSpace * iBufPixel + static_cast(nLineSpace) * iBufLine; - if (eBufType == GDT_Byte) + if (eBufType == GDT_UInt8) *pDstLocation = static_cast( std::min(255.0, std::max(0.0, dfOutputValue + 0.5))); else @@ -2326,7 +2326,7 @@ CPLErr VRTNoDataFromMaskSource::RasterIO( double dfRemappedValue = m_dfRemappedValue; if (!m_bHasRemappedValue) { - if (eSrcBandDT == GDT_Byte && + if (eSrcBandDT == GDT_UInt8 && m_dfNoDataValue >= std::numeric_limits::min() && m_dfNoDataValue <= std::numeric_limits::max() && static_cast(m_dfNoDataValue) == m_dfNoDataValue) @@ -2366,8 +2366,8 @@ CPLErr VRTNoDataFromMaskSource::RasterIO( } } const bool bByteOptim = - (eSrcBandDT == GDT_Byte && eBufType == GDT_Byte && - eSrcMaskBandDT == GDT_Byte && m_dfMaskValueThreshold >= 0 && + (eSrcBandDT == GDT_UInt8 && eBufType == GDT_UInt8 && + eSrcMaskBandDT == GDT_UInt8 && m_dfMaskValueThreshold >= 0 && m_dfMaskValueThreshold <= 255 && static_cast(m_dfMaskValueThreshold) == m_dfMaskValueThreshold && m_dfNoDataValue >= 0 && m_dfNoDataValue <= 255 && @@ -2499,7 +2499,7 @@ CPLErr VRTNoDataFromMaskSource::RasterIO( GSpacing nDstOffset = iY * nLineSpace; for (int iX = 0; iX < nOutXSize; iX++) { - if (eSrcMaskBandDT == GDT_Byte) + if (eSrcMaskBandDT == GDT_UInt8) { dfMaskVal = oWorkingState.m_abyWrkBufferMask[nSrcIdx]; } @@ -3081,7 +3081,7 @@ CPLErr VRTComplexSource::RasterIO(GDALDataType eVRTBandDataType, int nXOff, if (m_nProcessingFlags == PROCESSING_FLAG_NODATA) { // Optimization if doing only nodata processing - if (eSourceType == GDT_Byte) + if (eSourceType == GDT_UInt8) { if (!GDALIsValueInRange(m_dfNoDataValue)) { @@ -3091,7 +3091,7 @@ CPLErr VRTComplexSource::RasterIO(GDALDataType eVRTBandDataType, int nXOff, psExtraArgIn, oWorkingState); } - return RasterIOProcessNoData( + return RasterIOProcessNoData( poSourceBand, eVRTBandDataType, nReqXOff, nReqYOff, nReqXSize, nReqYSize, pabyOut, nOutXSize, nOutYSize, eBufType, nPixelSpace, nLineSpace, psExtraArg, oWorkingState); @@ -3180,7 +3180,7 @@ static void CopyWord(const SrcType *pSrcVal, GDALDataType eSrcType, { switch (eDstType) { - case GDT_Byte: + case GDT_UInt8: GDALCopyWord(*pSrcVal, *static_cast(pDstVal)); break; case GDT_Int8: @@ -3528,7 +3528,7 @@ CPLErr VRTComplexSource::RasterIOInternal( if (poMaskBand->RasterIO( GF_Read, nReqXOff, nReqYOff, nReqXSize, nReqYSize, oWorkingState.m_abyWrkBufferMask.data(), nOutXSize, - nOutYSize, GDT_Byte, 1, static_cast(nOutXSize), + nOutYSize, GDT_UInt8, 1, static_cast(nOutXSize), psExtraArg) != CE_None) { return CE_Failure; @@ -3687,7 +3687,7 @@ CPLErr VRTComplexSource::RasterIOInternal( afResult[0] = static_cast(m_nMaxValue); } - if (eBufType == GDT_Byte && eVRTBandDataType == GDT_Byte) + if (eBufType == GDT_UInt8 && eVRTBandDataType == GDT_UInt8) { *pDstLocation = static_cast(std::min( 255.0f, @@ -3805,7 +3805,7 @@ CPLErr VRTComplexSource::GetHistogram(int nXSize, int nYSize, double dfMin, /************************************************************************/ VRTFuncSource::VRTFuncSource() - : pfnReadFunc(nullptr), pCBData(nullptr), eType(GDT_Byte), + : pfnReadFunc(nullptr), pCBData(nullptr), eType(GDT_UInt8), fNoDataValue(static_cast(VRT_NODATA_UNSET)) { } diff --git a/frmts/webp/webpdataset.cpp b/frmts/webp/webpdataset.cpp index 0d7ac94d2a62..6a8d56d41678 100644 --- a/frmts/webp/webpdataset.cpp +++ b/frmts/webp/webpdataset.cpp @@ -105,7 +105,7 @@ WEBPRasterBand::WEBPRasterBand(WEBPDataset *poDSIn, int) { poDS = poDSIn; - eDataType = GDT_Byte; + eDataType = GDT_UInt8; nBlockXSize = poDSIn->nRasterXSize; nBlockYSize = 1; @@ -416,7 +416,7 @@ CPLErr WEBPDataset::IRasterIO(GDALRWFlag eRWFlag, int nXOff, int nYOff, if ((eRWFlag == GF_Read) && (nBandCount == nBands) && (nXOff == 0) && (nYOff == 0) && (nXSize == nBufXSize) && (nXSize == nRasterXSize) && (nYSize == nBufYSize) && (nYSize == nRasterYSize) && - (eBufType == GDT_Byte) && (pData != nullptr) && + (eBufType == GDT_UInt8) && (pData != nullptr) && IsAllBands(nBandCount, panBandMap)) { if (Uncompress() != CE_None) @@ -872,7 +872,7 @@ GDALDataset *WEBPDataset::CreateCopy(const char *pszFilename, const GDALDataType eDT = poSrcDS->GetRasterBand(1)->GetRasterDataType(); - if (eDT != GDT_Byte) + if (eDT != GDT_UInt8) { CPLError((bStrict) ? CE_Failure : CE_Warning, CPLE_NotSupported, "WEBP driver doesn't support data type %s. " @@ -1046,7 +1046,7 @@ GDALDataset *WEBPDataset::CreateCopy(const char *pszFilename, /* -------------------------------------------------------------------- */ CPLErr eErr = poSrcDS->RasterIO(GF_Read, 0, 0, nXSize, nYSize, pabyBuffer, nXSize, - nYSize, GDT_Byte, nBands, nullptr, nBands, + nYSize, GDT_UInt8, nBands, nullptr, nBands, static_cast(nBands) * nXSize, 1, nullptr); /* -------------------------------------------------------------------- */ diff --git a/frmts/wms/gdalwmsdataset.cpp b/frmts/wms/gdalwmsdataset.cpp index 91b4c599c89b..7608b225adf0 100644 --- a/frmts/wms/gdalwmsdataset.cpp +++ b/frmts/wms/gdalwmsdataset.cpp @@ -38,7 +38,7 @@ /************************************************************************/ GDALWMSDataset::GDALWMSDataset() : m_mini_driver(nullptr), m_cache(nullptr), m_poColorTable(nullptr), - m_data_type(GDT_Byte), m_block_size_x(0), m_block_size_y(0), + m_data_type(GDT_UInt8), m_block_size_x(0), m_block_size_y(0), m_use_advise_read(0), m_verify_advise_read(0), m_offline_mode(0), m_http_max_conn(0), m_http_timeout(0), m_http_options(nullptr), m_tileOO(nullptr), m_clamp_requests(true), m_unsafeSsl(false), diff --git a/frmts/wms/gdalwmsrasterband.cpp b/frmts/wms/gdalwmsrasterband.cpp index b3fbba29f9b2..d653b30c0a08 100644 --- a/frmts/wms/gdalwmsrasterband.cpp +++ b/frmts/wms/gdalwmsrasterband.cpp @@ -731,10 +731,10 @@ CPLErr GDALWMSRasterBand::ReadBlockFromDataset(GDALDataset *ds, int x, int y, if (nDSRasterCount != m_parent_dataset->nBands) { /* Maybe its an image with color table */ - if ((eDataType == GDT_Byte) && (ds->GetRasterCount() == 1)) + if ((eDataType == GDT_UInt8) && (ds->GetRasterCount() == 1)) { GDALRasterBand *rb = ds->GetRasterBand(1); - if (rb->GetRasterDataType() == GDT_Byte) + if (rb->GetRasterDataType() == GDT_UInt8) { GDALColorTable *ct = rb->GetColorTable(); if (ct != nullptr) diff --git a/frmts/wms/minidriver_tiled_wms.cpp b/frmts/wms/minidriver_tiled_wms.cpp index 02da77d14230..3bcd09238989 100644 --- a/frmts/wms/minidriver_tiled_wms.cpp +++ b/frmts/wms/minidriver_tiled_wms.cpp @@ -492,7 +492,7 @@ CPLErr WMSMiniDriver_TiledWMS::Initialize(CPLXMLNode *config, GDALDataType dt = GDALGetDataTypeByName(CPLGetXMLValue(TG, "DataType", "Byte")); m_parent_dataset->WMSSetDataType(dt); - if (dt != GDT_Byte) + if (dt != GDT_UInt8) m_parent_dataset->SetTileOO("@DATATYPE", GDALGetDataTypeName(dt)); // Let the TiledGroup override the projection pszProjection = CPLGetXMLValue(TG, "Projection", ""); diff --git a/frmts/wmts/wmtsdataset.cpp b/frmts/wmts/wmtsdataset.cpp index 505d84f9ab06..45a77052e87e 100644 --- a/frmts/wmts/wmtsdataset.cpp +++ b/frmts/wmts/wmtsdataset.cpp @@ -1077,7 +1077,7 @@ GDALDataset *WMTSDataset::Open(GDALOpenInfo *poOpenInfo) int bHasAOI = FALSE; OGREnvelope sAOI; int nBands = 4; - GDALDataType eDataType = GDT_Byte; + GDALDataType eDataType = GDT_UInt8; CPLString osProjection; CPLString osExtraQueryParameters; diff --git a/frmts/xyz/xyzdataset.cpp b/frmts/xyz/xyzdataset.cpp index debdf145856d..d41612045a27 100644 --- a/frmts/xyz/xyzdataset.cpp +++ b/frmts/xyz/xyzdataset.cpp @@ -623,14 +623,14 @@ double XYZRasterBand::GetNoDataValue(int *pbSuccess) { XYZDataset *poGDS = cpl::down_cast(poDS); if (!poGDS->bSameNumberOfValuesPerLine && poGDS->dfMinZ > -32768 && - eDataType != GDT_Byte) + eDataType != GDT_UInt8) { if (pbSuccess) *pbSuccess = TRUE; return (poGDS->dfMinZ > 0) ? 0 : -32768; } else if (!poGDS->bSameNumberOfValuesPerLine && poGDS->dfMinZ > 0 && - eDataType == GDT_Byte) + eDataType == GDT_UInt8) { if (pbSuccess) *pbSuccess = TRUE; @@ -988,7 +988,7 @@ GDALDataset *XYZDataset::Open(GDALOpenInfo *poOpenInfo) double dfLastY = 0.0; std::vector adfStepX; std::vector adfStepY; - GDALDataType eDT = GDT_Byte; + GDALDataType eDT = GDT_UInt8; bool bSameNumberOfValuesPerLine = true; char chDecimalSep = '\0'; int nStepYSign = 0; @@ -1108,7 +1108,7 @@ GDALDataset *XYZDataset::Open(GDALOpenInfo *poOpenInfo) { eDT = GDT_Float32; } - else if ((eDT == GDT_Byte || eDT == GDT_Int16) + else if ((eDT == GDT_UInt8 || eDT == GDT_Int16) // cppcheck-suppress // knownConditionTrueFalse && (nZ < 0 || nZ > 255)) @@ -1493,7 +1493,7 @@ GDALDataset *XYZDataset::Open(GDALOpenInfo *poOpenInfo) { if (eDT == GDT_Int32) eDT = GDT_Float32; - else if (eDT == GDT_Byte) + else if (eDT == GDT_UInt8) eDT = GDT_Int16; CPLAssert(eDT == GDT_Int16 || eDT == GDT_Float32); } @@ -1609,7 +1609,7 @@ GDALDataset *XYZDataset::CreateCopy(const char *pszFilename, const GDALDataType eSrcDT = poSrcDS->GetRasterBand(1)->GetRasterDataType(); GDALDataType eReqDT; - if (eSrcDT == GDT_Byte || eSrcDT == GDT_Int16 || eSrcDT == GDT_UInt16 || + if (eSrcDT == GDT_UInt8 || eSrcDT == GDT_Int16 || eSrcDT == GDT_UInt16 || eSrcDT == GDT_Int32) eReqDT = GDT_Int32; else diff --git a/frmts/zarr/zarr_array.cpp b/frmts/zarr/zarr_array.cpp index acdb32c6db41..25cbd67475ea 100644 --- a/frmts/zarr/zarr_array.cpp +++ b/frmts/zarr/zarr_array.cpp @@ -1213,7 +1213,7 @@ bool ZarrArray::IRead(const GUInt64 *arrayStartIdx, const size_t *count, { bNoDataIsZero = true; GByte zero = 0; - GDALCopyWords(&zero, GDT_Byte, 0, &abyTargetNoData[0], + GDALCopyWords(&zero, GDT_UInt8, 0, &abyTargetNoData[0], bufferDataType.GetNumericDataType(), 0, 1); } } @@ -2045,7 +2045,7 @@ ZarrArray::OpenTilePresenceCache(bool bCanCreate) const const std::string osTilePresenceArrayName(MassageName(GetFullName()) + "_tile_presence"); auto poTilePresenceArray = poRGCache->OpenMDArray(osTilePresenceArrayName); - const auto eByteDT = GDALExtendedDataType::Create(GDT_Byte); + const auto eByteDT = GDALExtendedDataType::Create(GDT_UInt8); if (poTilePresenceArray) { bool ok = true; @@ -2172,7 +2172,7 @@ bool ZarrArray::CacheTilePresence() const std::vector anArrayStep(m_aoDims.size(), 0); const std::vector anBufferStride(m_aoDims.size(), 0); const auto &apoDimsCache = poTilePresenceArray->GetDimensions(); - const auto eByteDT = GDALExtendedDataType::Create(GDT_Byte); + const auto eByteDT = GDALExtendedDataType::Create(GDT_UInt8); CPLDebug(ZARR_DEBUG_KEY, "CacheTilePresence(): Iterating over %s to find which tiles are " @@ -2908,7 +2908,7 @@ bool ZarrArray::IsTileMissingFromCacheInfo(const std::string &osFilename, const std::vector anCount(m_aoDims.size(), 1); const std::vector anArrayStep(m_aoDims.size(), 0); const std::vector anBufferStride(m_aoDims.size(), 0); - const auto eByteDT = GDALExtendedDataType::Create(GDT_Byte); + const auto eByteDT = GDALExtendedDataType::Create(GDT_UInt8); for (size_t i = 0; i < m_aoDims.size(); ++i) { anTileIdx[i] = static_cast(tileIndices[i]); diff --git a/frmts/zarr/zarr_attribute.cpp b/frmts/zarr/zarr_attribute.cpp index 69bc0a51f53e..66fcf1808ff3 100644 --- a/frmts/zarr/zarr_attribute.cpp +++ b/frmts/zarr/zarr_attribute.cpp @@ -349,7 +349,7 @@ CPLJSONObject ZarrAttributeGroup::Serialize() const const int64_t nVal = attr->ReadAsInt64(); o.Add(attr->GetName(), static_cast(nVal)); } - else if (eDT == GDT_Byte || eDT == GDT_UInt16 || + else if (eDT == GDT_UInt8 || eDT == GDT_UInt16 || eDT == GDT_UInt32 || eDT == GDT_UInt64) { const int64_t nVal = attr->ReadAsInt64(); @@ -373,7 +373,7 @@ CPLJSONObject ZarrAttributeGroup::Serialize() const arr.Add(static_cast(nVal)); } } - else if (eDT == GDT_Byte || eDT == GDT_UInt16 || + else if (eDT == GDT_UInt8 || eDT == GDT_UInt16 || eDT == GDT_UInt32 || eDT == GDT_UInt64) { const auto list = attr->ReadAsInt64Array(); diff --git a/frmts/zarr/zarr_filters.cpp b/frmts/zarr/zarr_filters.cpp index 1e86c2ad27fa..c439dd62dca2 100644 --- a/frmts/zarr/zarr_filters.cpp +++ b/frmts/zarr/zarr_filters.cpp @@ -460,7 +460,7 @@ static bool ZarrFixedScaleOffsetDecompressor(const void *input_data, } const int inputEltSize = astype[2] - '0'; - const GDALDataType eInDT = inputEltSize == 1 ? GDT_Byte + const GDALDataType eInDT = inputEltSize == 1 ? GDT_UInt8 : inputEltSize == 2 ? GDT_UInt16 : GDT_UInt32; diff --git a/frmts/zarr/zarr_v2_array.cpp b/frmts/zarr/zarr_v2_array.cpp index 3096b1540a77..757e810418d8 100644 --- a/frmts/zarr/zarr_v2_array.cpp +++ b/frmts/zarr/zarr_v2_array.cpp @@ -1121,12 +1121,12 @@ static GDALExtendedDataType ParseDtype(const CPLJSONObject &obj, if (chType == 'b' && nBytes == 1) // boolean { elt.nativeType = DtypeElt::NativeType::BOOLEAN; - eDT = GDT_Byte; + eDT = GDT_UInt8; } else if (chType == 'u' && nBytes == 1) { elt.nativeType = DtypeElt::NativeType::UNSIGNED_INT; - eDT = GDT_Byte; + eDT = GDT_UInt8; } else if (chType == 'i' && nBytes == 1) { diff --git a/frmts/zarr/zarr_v2_group.cpp b/frmts/zarr/zarr_v2_group.cpp index df73929861ff..cc6fa25f0c73 100644 --- a/frmts/zarr/zarr_v2_group.cpp +++ b/frmts/zarr/zarr_v2_group.cpp @@ -715,7 +715,7 @@ static CPLJSONObject FillDTypeElts(const GDALExtendedDataType &oDataType, bool bUnsupported = false; switch (eDT) { - case GDT_Byte: + case GDT_UInt8: { elt.nativeType = DtypeElt::NativeType::UNSIGNED_INT; dtype.Set(dummy, "|u1"); @@ -1050,7 +1050,7 @@ std::shared_ptr ZarrV2Group::CreateMDArray( { case GDT_Unknown: break; - case GDT_Byte: + case GDT_UInt8: oFilter.Add("dtype", "u1"); break; case GDT_Int8: diff --git a/frmts/zarr/zarr_v3_array.cpp b/frmts/zarr/zarr_v3_array.cpp index 7af63385fa5b..72a47c8448c6 100644 --- a/frmts/zarr/zarr_v3_array.cpp +++ b/frmts/zarr/zarr_v3_array.cpp @@ -888,7 +888,7 @@ static GDALExtendedDataType ParseDtypeV3(const CPLJSONObject &obj, if (str == "bool") // boolean { elt.nativeType = DtypeElt::NativeType::BOOLEAN; - eDT = GDT_Byte; + eDT = GDT_UInt8; } else if (str == "int8") { @@ -898,7 +898,7 @@ static GDALExtendedDataType ParseDtypeV3(const CPLJSONObject &obj, else if (str == "uint8") { elt.nativeType = DtypeElt::NativeType::UNSIGNED_INT; - eDT = GDT_Byte; + eDT = GDT_UInt8; } else if (str == "int16") { diff --git a/frmts/zarr/zarr_v3_group.cpp b/frmts/zarr/zarr_v3_group.cpp index e2a346f3c10b..da3048cfaf56 100644 --- a/frmts/zarr/zarr_v3_group.cpp +++ b/frmts/zarr/zarr_v3_group.cpp @@ -392,7 +392,7 @@ static CPLJSONObject FillDTypeElts(const GDALExtendedDataType &oDataType, bool bUnsupported = false; switch (eDT) { - case GDT_Byte: + case GDT_UInt8: { elt.nativeType = DtypeElt::NativeType::UNSIGNED_INT; dtype.Set(dummy, "uint8"); diff --git a/gcore/gdal.h b/gcore/gdal.h index 49cf136c0951..24498a05a63c 100644 --- a/gcore/gdal.h +++ b/gcore/gdal.h @@ -47,26 +47,28 @@ CPL_C_START typedef enum { /*! Unknown or unspecified type */ GDT_Unknown = 0, - /*! Eight bit unsigned integer */ GDT_Byte = 1, + /*! 8-bit unsigned integer (GDT_Byte in GDAL < 3.13) */ GDT_UInt8 = 1, /*! 8-bit signed integer (GDAL >= 3.7) */ GDT_Int8 = 14, - /*! Sixteen bit unsigned integer */ GDT_UInt16 = 2, - /*! Sixteen bit signed integer */ GDT_Int16 = 3, - /*! Thirty two bit unsigned integer */ GDT_UInt32 = 4, - /*! Thirty two bit signed integer */ GDT_Int32 = 5, + /*! 16-bit unsigned integer */ GDT_UInt16 = 2, + /*! 16-bit signed integer */ GDT_Int16 = 3, + /*! 32-bit unsigned integer */ GDT_UInt32 = 4, + /*! 32-bit signed integer */ GDT_Int32 = 5, /*! 64 bit unsigned integer (GDAL >= 3.5)*/ GDT_UInt64 = 12, /*! 64 bit signed integer (GDAL >= 3.5)*/ GDT_Int64 = 13, - /*! Sixteen bit floating point */ GDT_Float16 = 15, - /*! Thirty two bit floating point */ GDT_Float32 = 6, - /*! Sixty four bit floating point */ GDT_Float64 = 7, + /*! 16-bit floating point */ GDT_Float16 = 15, + /*! 32-bit floating point */ GDT_Float32 = 6, + /*! 64-bit floating point */ GDT_Float64 = 7, /*! Complex Int16 */ GDT_CInt16 = 8, /*! Complex Int32 */ GDT_CInt32 = 9, - /* TODO?(#6879): GDT_CInt64 */ /*! Complex Float16 */ GDT_CFloat16 = 16, /*! Complex Float32 */ GDT_CFloat32 = 10, /*! Complex Float64 */ GDT_CFloat64 = 11, GDT_TypeCount = 17 /* maximum type # + 1 */ } GDALDataType; +/** GDT_Byte is the name used before GDAL 3.13 for GDT_UInt8 */ +#define GDT_Byte GDT_UInt8 + int CPL_DLL CPL_STDCALL GDALGetDataTypeSize(GDALDataType) /*! @cond Doxygen_Suppress */ CPL_WARN_DEPRECATED("Use GDALGetDataTypeSizeBits() or " diff --git a/gcore/gdal_misc.cpp b/gcore/gdal_misc.cpp index 2b9229b797f0..3116c1e3f65c 100644 --- a/gcore/gdal_misc.cpp +++ b/gcore/gdal_misc.cpp @@ -87,7 +87,7 @@ static int GetNonComplexDataTypeElementSizeBits(GDALDataType eDataType) { switch (eDataType) { - case GDT_Byte: + case GDT_UInt8: case GDT_Int8: return 8; @@ -262,7 +262,7 @@ GDALDataType CPL_STDCALL GDALFindDataType(int nBits, int bSigned, int bFloating, if (!bSigned) { if (nBits <= 8) - return GDT_Byte; + return GDT_UInt8; if (nBits <= 16) return GDT_UInt16; if (nBits <= 32) @@ -367,7 +367,7 @@ GDALDataType CPL_STDCALL GDALFindDataTypeForValue(double dValue, int bComplex) * Returns the size of a GDT_* type in bytes. In contrast, * GDALGetDataTypeSize() returns the size in bits. * - * @param eDataType type, such as GDT_Byte. + * @param eDataType type, such as GDT_UInt8. * @return the number of bytes or zero if it is not recognised. */ @@ -376,7 +376,7 @@ int CPL_STDCALL GDALGetDataTypeSizeBytes(GDALDataType eDataType) { switch (eDataType) { - case GDT_Byte: + case GDT_UInt8: case GDT_Int8: return 1; @@ -419,7 +419,7 @@ int CPL_STDCALL GDALGetDataTypeSizeBytes(GDALDataType eDataType) * Returns the size of a GDT_* type in bits, not bytes! Use * GDALGetDataTypeSizeBytes() for bytes. * - * @param eDataType type, such as GDT_Byte. + * @param eDataType type, such as GDT_UInt8. * @return the number of bits or zero if it is not recognised. */ @@ -441,7 +441,7 @@ int CPL_STDCALL GDALGetDataTypeSizeBits(GDALDataType eDataType) * Use GDALGetDataTypeSizeBytes() for bytes. * Use GDALGetDataTypeSizeBits() for bits. * - * @param eDataType type, such as GDT_Byte. + * @param eDataType type, such as GDT_UInt8. * @return the number of bits or zero if it is not recognised. */ @@ -475,7 +475,7 @@ int CPL_STDCALL GDALDataTypeIsComplex(GDALDataType eDataType) case GDT_CFloat64: return TRUE; - case GDT_Byte: + case GDT_UInt8: case GDT_Int8: case GDT_Int16: case GDT_UInt16: @@ -518,7 +518,7 @@ int CPL_STDCALL GDALDataTypeIsFloating(GDALDataType eDataType) case GDT_CFloat64: return TRUE; - case GDT_Byte: + case GDT_UInt8: case GDT_Int8: case GDT_Int16: case GDT_UInt16: @@ -544,7 +544,7 @@ int CPL_STDCALL GDALDataTypeIsFloating(GDALDataType eDataType) /** * \brief Is data type integer? (might be complex) * - * @return TRUE if the passed type is integer (one of GDT_Byte, GDT_Int16, + * @return TRUE if the passed type is integer (one of GDT_UInt8, GDT_Int16, * GDT_UInt16, GDT_Int32, GDT_UInt32, GDT_CInt16, GDT_CInt32). */ @@ -553,7 +553,7 @@ int CPL_STDCALL GDALDataTypeIsInteger(GDALDataType eDataType) { switch (eDataType) { - case GDT_Byte: + case GDT_UInt8: case GDT_Int8: case GDT_Int16: case GDT_UInt16: @@ -594,7 +594,7 @@ int CPL_STDCALL GDALDataTypeIsSigned(GDALDataType eDataType) { switch (eDataType) { - case GDT_Byte: + case GDT_UInt8: case GDT_UInt16: case GDT_UInt32: case GDT_UInt64: @@ -702,7 +702,7 @@ int CPL_STDCALL GDALDataTypeIsConversionLossy(GDALDataType eTypeFrom, * \brief Get name of data type. * * Returns a symbolic name for the data type. This is essentially the - * the enumerated item name with the GDT_ prefix removed. So GDT_Byte returns + * the enumerated item name with the GDT_ prefix removed. So GDT_UInt8 returns * "Byte". The returned strings are static strings and should not be modified * or freed by the application. These strings are useful for reporting * datatypes in debug statements, errors and other user output. @@ -720,7 +720,8 @@ const char *CPL_STDCALL GDALGetDataTypeName(GDALDataType eDataType) case GDT_Unknown: return "Unknown"; - case GDT_Byte: + case GDT_UInt8: + // TODO: return UInt8 for GDAL 4 ? return "Byte"; case GDT_Int8: @@ -794,6 +795,9 @@ GDALDataType CPL_STDCALL GDALGetDataTypeByName(const char *pszName) { VALIDATE_POINTER1(pszName, "GDALGetDataTypeByName", GDT_Unknown); + if (EQUAL(pszName, "UInt8")) + return GDT_UInt8; + for (int iType = 1; iType < GDT_TypeCount; iType++) { const auto eType = static_cast(iType); @@ -855,7 +859,7 @@ double GDALAdjustValueToDataType(GDALDataType eDT, double dfValue, bool bRounded = false; switch (eDT) { - case GDT_Byte: + case GDT_UInt8: ClampAndRound(dfValue, bClamped, bRounded); break; case GDT_Int8: @@ -970,7 +974,7 @@ bool GDALIsValueExactAs(double dfValue, GDALDataType eDT) { switch (eDT) { - case GDT_Byte: + case GDT_UInt8: return GDALIsValueExactAs(dfValue); case GDT_Int8: return GDALIsValueExactAs(dfValue); @@ -1025,7 +1029,7 @@ bool GDALIsValueInRangeOf(double dfValue, GDALDataType eDT) { switch (eDT) { - case GDT_Byte: + case GDT_UInt8: return GDALIsValueInRange(dfValue); case GDT_Int8: return GDALIsValueInRange(dfValue); @@ -1089,7 +1093,7 @@ GDALDataType CPL_STDCALL GDALGetNonComplexDataType(GDALDataType eDataType) case GDT_CFloat64: return GDT_Float64; - case GDT_Byte: + case GDT_UInt8: case GDT_UInt16: case GDT_UInt32: case GDT_UInt64: @@ -1586,7 +1590,7 @@ int CPL_STDCALL GDALGetRandomRasterSample(GDALRasterBandH hBand, int nSamples, switch (poBlock->GetDataType()) { - case GDT_Byte: + case GDT_UInt8: dfValue = reinterpret_cast(pDataRef)[iOffset]; break; @@ -5554,7 +5558,7 @@ double GDALGetNoDataReplacementValue(GDALDataType dt, double dfNoDataValue) // specified data type and return a replacement value if it is, return // 0 otherwise. double dfReplacementVal = dfNoDataValue; - if (dt == GDT_Byte) + if (dt == GDT_UInt8) { if (GDALClampDoubleValue(dfNoDataValue, cpl::NumericLimits::lowest(), diff --git a/gcore/gdalallvalidmaskband.cpp b/gcore/gdalallvalidmaskband.cpp index b482f0bad6fe..7320bdfc0697 100644 --- a/gcore/gdalallvalidmaskband.cpp +++ b/gcore/gdalallvalidmaskband.cpp @@ -33,7 +33,7 @@ GDALAllValidMaskBand::GDALAllValidMaskBand(GDALRasterBand *poParent) nRasterXSize = poParent->GetXSize(); nRasterYSize = poParent->GetYSize(); - eDataType = GDT_Byte; + eDataType = GDT_UInt8; poParent->GetBlockSize(&nBlockXSize, &nBlockYSize); } @@ -75,7 +75,7 @@ CPLErr GDALAllValidMaskBand::IRasterIO(GDALRWFlag eRWFlag, int, int, int, int, GByte byVal = 255; for (int iY = 0; iY < nBufYSize; ++iY) { - GDALCopyWords64(&byVal, GDT_Byte, 0, pabyData + iY * nLineSpace, + GDALCopyWords64(&byVal, GDT_UInt8, 0, pabyData + iY * nLineSpace, eBufType, static_cast(nPixelSpace), nBufXSize); } diff --git a/gcore/gdalcomputedrasterband.cpp b/gcore/gdalcomputedrasterband.cpp index d42af3d08007..0fbf1db460c1 100644 --- a/gcore/gdalcomputedrasterband.cpp +++ b/gcore/gdalcomputedrasterband.cpp @@ -640,9 +640,9 @@ GDALComputedRasterBand::GDALComputedRasterBand(Operation op, ? GDT_Float64 : GDT_Float32; else if (IsComparisonOperator(op)) - eDataType = GDT_Byte; - else if (op == Operation::OP_ADD && firstDT == GDT_Byte && - secondDT == GDT_Byte) + eDataType = GDT_UInt8; + else if (op == Operation::OP_ADD && firstDT == GDT_UInt8 && + secondDT == GDT_UInt8) eDataType = GDT_UInt16; else if (firstDT == GDT_Float32 && secondDT == GDT_Float32) eDataType = GDT_Float32; @@ -672,7 +672,7 @@ GDALComputedRasterBand::GDALComputedRasterBand(Operation op, double constant, nRasterYSize = band.GetYSize(); const auto firstDT = band.GetRasterDataType(); if (IsComparisonOperator(op)) - eDataType = GDT_Byte; + eDataType = GDT_UInt8; else if (firstDT == GDT_Float32 && static_cast(static_cast(constant)) == constant) eDataType = GDT_Float32; @@ -697,11 +697,11 @@ GDALComputedRasterBand::GDALComputedRasterBand(Operation op, nRasterYSize = band.GetYSize(); const auto firstDT = band.GetRasterDataType(); if (IsComparisonOperator(op)) - eDataType = GDT_Byte; - else if (op == Operation::OP_ADD && firstDT == GDT_Byte && + eDataType = GDT_UInt8; + else if (op == Operation::OP_ADD && firstDT == GDT_UInt8 && constant >= -128 && constant <= 127 && std::floor(constant) == constant) - eDataType = GDT_Byte; + eDataType = GDT_UInt8; else if (firstDT == GDT_Float32 && static_cast(static_cast(constant)) == constant) eDataType = GDT_Float32; diff --git a/gcore/gdaldefaultoverviews.cpp b/gcore/gdaldefaultoverviews.cpp index 1aad5e23444b..6d8faeabbca4 100644 --- a/gcore/gdaldefaultoverviews.cpp +++ b/gcore/gdaldefaultoverviews.cpp @@ -1442,7 +1442,7 @@ CPLErr GDALDefaultOverviews::CreateMaskBand(int nFlags, int nBand) osMskFilename.Printf("%s.msk", poDS->GetDescription()); poMaskDS = poDr->Create(osMskFilename, poDS->GetRasterXSize(), - poDS->GetRasterYSize(), nBands, GDT_Byte, papszOpt); + poDS->GetRasterYSize(), nBands, GDT_UInt8, papszOpt); CSLDestroy(papszOpt); if (poMaskDS == nullptr) // Presumably error already issued. diff --git a/gcore/gdalmultidim.cpp b/gcore/gdalmultidim.cpp index 3f08ff7d211d..71410bde6149 100644 --- a/gcore/gdalmultidim.cpp +++ b/gcore/gdalmultidim.cpp @@ -1086,7 +1086,7 @@ bool GDALGroup::CopyFrom(const std::shared_ptr &poDstRootGroup, switch (eAutoScaleType) { - case GDT_Byte: + case GDT_UInt8: setDTMinMax(GByte); break; case GDT_Int8: @@ -1747,7 +1747,7 @@ bool GDALExtendedDataType::CopyValue(const void *pSrc, { case GDT_Unknown: break; - case GDT_Byte: + case GDT_UInt8: str = CPLSPrintf("%d", *static_cast(pSrc)); break; case GDT_Int8: @@ -6735,7 +6735,7 @@ class GDALMDArrayMask final : public GDALPamMDArray { private: std::shared_ptr m_poParent{}; - GDALExtendedDataType m_dt{GDALExtendedDataType::Create(GDT_Byte)}; + GDALExtendedDataType m_dt{GDALExtendedDataType::Create(GDT_UInt8)}; double m_dfMissingValue = 0.0; bool m_bHasMissingValue = false; double m_dfFillValue = 0.0; @@ -6937,8 +6937,9 @@ bool GDALMDArrayMask::Init(CSLConstList papszOptions) { const auto eType = poFlagValues->GetDataType().GetNumericDataType(); // We could support Int64 or UInt64, but more work... - if (eType != GDT_Byte && eType != GDT_Int8 && eType != GDT_UInt16 && - eType != GDT_Int16 && eType != GDT_UInt32 && eType != GDT_Int32) + if (eType != GDT_UInt8 && eType != GDT_Int8 && + eType != GDT_UInt16 && eType != GDT_Int16 && + eType != GDT_UInt32 && eType != GDT_Int32) { CPLError(CE_Failure, CPLE_NotSupported, "Unsupported data type for flag_values attribute: %s", @@ -6951,8 +6952,9 @@ bool GDALMDArrayMask::Init(CSLConstList papszOptions) { const auto eType = poFlagMasks->GetDataType().GetNumericDataType(); // We could support Int64 or UInt64, but more work... - if (eType != GDT_Byte && eType != GDT_Int8 && eType != GDT_UInt16 && - eType != GDT_Int16 && eType != GDT_UInt32 && eType != GDT_Int32) + if (eType != GDT_UInt8 && eType != GDT_Int8 && + eType != GDT_UInt16 && eType != GDT_Int16 && + eType != GDT_UInt32 && eType != GDT_Int32) { CPLError(CE_Failure, CPLE_NotSupported, "Unsupported data type for flag_masks attribute: %s", @@ -7114,7 +7116,7 @@ bool GDALMDArrayMask::IRead(const GUInt64 *arrayStartIdx, const size_t *count, GByte abyOne[16]; // 16 is sizeof GDT_CFloat64 CPLAssert(nBufferDTSize <= 16); const GByte flag = 1; - GDALCopyWords64(&flag, GDT_Byte, 0, abyOne, + GDALCopyWords64(&flag, GDT_UInt8, 0, abyOne, bufferDataType.GetNumericDataType(), 0, 1); lbl_next_depth: @@ -7179,7 +7181,7 @@ bool GDALMDArrayMask::IRead(const GUInt64 *arrayStartIdx, const size_t *count, switch (oTmpBufferDT.GetNumericDataType()) { - case GDT_Byte: + case GDT_UInt8: ReadInternal(count, bufferStride, bufferDataType, pDstBuffer, pTempBuffer, oTmpBufferDT, tmpBufferStrideVector); diff --git a/gcore/gdalmultidim_gltorthorectification.cpp b/gcore/gdalmultidim_gltorthorectification.cpp index f1d156d6898e..db0c34c4882f 100644 --- a/gcore/gdalmultidim_gltorthorectification.cpp +++ b/gcore/gdalmultidim_gltorthorectification.cpp @@ -133,7 +133,7 @@ class GLTOrthoRectifiedArray final : public GDALPamMDArray newAr->m_abyBandValidity.resize(count[0], 1); CPL_IGNORE_RET_VAL(poGoodWaveLengths->Read( arrayStartIdx, count, arrayStep, bufferStride, - GDALExtendedDataType::Create(GDT_Byte), + GDALExtendedDataType::Create(GDT_UInt8), newAr->m_abyBandValidity.data())); } } diff --git a/gcore/gdalmultidim_rat.cpp b/gcore/gdalmultidim_rat.cpp index eaf8b5c74f4a..8e509c9691c6 100644 --- a/gcore/gdalmultidim_rat.cpp +++ b/gcore/gdalmultidim_rat.cpp @@ -66,7 +66,7 @@ class GDALRasterAttributeTableFromMDArrays final switch (m_apoArrays[iCol]->GetDataType().GetNumericDataType()) { case GDT_Int8: - case GDT_Byte: + case GDT_UInt8: case GDT_UInt16: case GDT_Int16: case GDT_Int32: diff --git a/gcore/gdalnodatamaskband.cpp b/gcore/gdalnodatamaskband.cpp index cd5dd988c508..ddf7f84fbaf1 100644 --- a/gcore/gdalnodatamaskband.cpp +++ b/gcore/gdalnodatamaskband.cpp @@ -41,7 +41,7 @@ GDALNoDataMaskBand::GDALNoDataMaskBand(GDALRasterBand *poParentIn) nRasterXSize = m_poParent->GetXSize(); nRasterYSize = m_poParent->GetYSize(); - eDataType = GDT_Byte; + eDataType = GDT_UInt8; m_poParent->GetBlockSize(&nBlockXSize, &nBlockYSize); const auto eParentDT = m_poParent->GetRasterDataType(); @@ -67,7 +67,7 @@ GDALNoDataMaskBand::GDALNoDataMaskBand(GDALRasterBand *poParentIn, nRasterXSize = m_poParent->GetXSize(); nRasterYSize = m_poParent->GetYSize(); - eDataType = GDT_Byte; + eDataType = GDT_UInt8; m_poParent->GetBlockSize(&nBlockXSize, &nBlockYSize); const auto eParentDT = m_poParent->GetRasterDataType(); @@ -94,8 +94,8 @@ static GDALDataType GetWorkDataType(GDALDataType eDataType) GDALDataType eWrkDT = GDT_Unknown; switch (eDataType) { - case GDT_Byte: - eWrkDT = GDT_Byte; + case GDT_UInt8: + eWrkDT = GDT_UInt8; break; case GDT_Int16: @@ -153,7 +153,7 @@ bool GDALNoDataMaskBand::IsNoDataInRange(double dfNoDataValue, GDALDataType eWrkDT = GetWorkDataType(eDataTypeIn); switch (eWrkDT) { - case GDT_Byte: + case GDT_UInt8: { return GDALIsValueInRange(dfNoDataValue); } @@ -244,7 +244,7 @@ CPLErr GDALNoDataMaskBand::IReadBlock(int nXBlockOff, int nYBlockOff, GDALRasterIOExtraArg sExtraArg; INIT_RASTERIO_EXTRA_ARG(sExtraArg); return IRasterIO(GF_Read, nXOff, nYOff, nXSizeRequest, nYSizeRequest, - pImage, nXSizeRequest, nYSizeRequest, GDT_Byte, 1, + pImage, nXSizeRequest, nYSizeRequest, GDT_UInt8, 1, nBlockXSize, &sExtraArg); } @@ -328,7 +328,7 @@ CPLErr GDALNoDataMaskBand::IRasterIO(GDALRWFlag eRWFlag, int nXOff, int nYOff, // Optimization in common use case (#4488). // This avoids triggering the block cache on this band, which helps // reducing the global block cache consumption. - if (eBufType == GDT_Byte && eWrkDT == GDT_Byte && nPixelSpace == 1 && + if (eBufType == GDT_UInt8 && eWrkDT == GDT_UInt8 && nPixelSpace == 1 && nLineSpace >= nBufXSize) { const CPLErr eErr = m_poParent->RasterIO( @@ -408,7 +408,7 @@ CPLErr GDALNoDataMaskBand::IRasterIO(GDALRWFlag eRWFlag, int nXOff, int nYOff, return std::pair(CE_None, pTemp); }; - if (eBufType == GDT_Byte) + if (eBufType == GDT_UInt8) { const int nWrkDTSize = GDALGetDataTypeSizeBytes(eWrkDT); auto [eErr, pTemp] = AllocTempBufferOrFallback(nWrkDTSize); @@ -435,7 +435,7 @@ CPLErr GDALNoDataMaskBand::IRasterIO(GDALRWFlag eRWFlag, int nXOff, int nYOff, */ switch (eWrkDT) { - case GDT_Byte: + case GDT_UInt8: { const auto nNoData = static_cast(m_dfNoDataValue); const auto *panSrc = static_cast(pTemp); @@ -561,7 +561,7 @@ CPLErr GDALNoDataMaskBand::IRasterIO(GDALRWFlag eRWFlag, int nXOff, int nYOff, return eErr; eErr = IRasterIO(eRWFlag, nXOff, nYOff, nXSize, nYSize, pTemp, nBufXSize, - nBufYSize, GDT_Byte, 1, nBufXSize, psExtraArg); + nBufYSize, GDT_UInt8, 1, nBufXSize, psExtraArg); if (eErr != CE_None) { VSIFree(pTemp); @@ -572,7 +572,7 @@ CPLErr GDALNoDataMaskBand::IRasterIO(GDALRWFlag eRWFlag, int nXOff, int nYOff, { GDALCopyWords64( static_cast(pTemp) + static_cast(iY) * nBufXSize, - GDT_Byte, 1, static_cast(pData) + iY * nLineSpace, + GDT_UInt8, 1, static_cast(pData) + iY * nLineSpace, eBufType, static_cast(nPixelSpace), nBufXSize); } VSIFree(pTemp); diff --git a/gcore/gdalnodatavaluesmaskband.cpp b/gcore/gdalnodatavaluesmaskband.cpp index 0cb02f1157b1..5cd39b9525be 100644 --- a/gcore/gdalnodatavaluesmaskband.cpp +++ b/gcore/gdalnodatavaluesmaskband.cpp @@ -51,7 +51,7 @@ GDALNoDataValuesMaskBand::GDALNoDataValuesMaskBand(GDALDataset *poDSIn) nRasterXSize = poDS->GetRasterXSize(); nRasterYSize = poDS->GetRasterYSize(); - eDataType = GDT_Byte; + eDataType = GDT_UInt8; poDS->GetRasterBand(1)->GetBlockSize(&nBlockXSize, &nBlockYSize); } @@ -110,8 +110,8 @@ CPLErr GDALNoDataValuesMaskBand::IReadBlock(int nXBlockOff, int nYBlockOff, /* -------------------------------------------------------------------- */ switch (poDS->GetRasterBand(1)->GetRasterDataType()) { - case GDT_Byte: - eWrkDT = GDT_Byte; + case GDT_UInt8: + eWrkDT = GDT_UInt8; break; case GDT_UInt16: @@ -196,7 +196,7 @@ CPLErr GDALNoDataValuesMaskBand::IReadBlock(int nXBlockOff, int nYBlockOff, /* -------------------------------------------------------------------- */ switch (eWrkDT) { - case GDT_Byte: + case GDT_UInt8: { FillOutBuffer(nBlockOffsetPixels, nBands, pabySrc, padfNodataValues, pImage); diff --git a/gcore/gdalrasterband.cpp b/gcore/gdalrasterband.cpp index 3c735b30c360..e5d6460248c3 100644 --- a/gcore/gdalrasterband.cpp +++ b/gcore/gdalrasterband.cpp @@ -541,7 +541,7 @@ template struct GetGDTFromCppType; static constexpr GDALDataType GDT = eDT; \ } -DEFINE_GetGDTFromCppType(uint8_t, GDT_Byte); +DEFINE_GetGDTFromCppType(uint8_t, GDT_UInt8); DEFINE_GetGDTFromCppType(int8_t, GDT_Int8); DEFINE_GetGDTFromCppType(uint16_t, GDT_UInt16); DEFINE_GetGDTFromCppType(int16_t, GDT_Int16); @@ -1022,7 +1022,7 @@ INSTANTIATE_READ_RASTER_VECTOR(std::complex) { memset( panHistogram, 0, sizeof(GUIntBig) * 256 ); - CPLAssert( poBand->GetRasterDataType() == GDT_Byte ); + CPLAssert( poBand->GetRasterDataType() == GDT_UInt8 ); int nXBlockSize, nYBlockSize; @@ -2905,7 +2905,7 @@ double GDALRasterBand::GetMaximum(int *pbSuccess) switch (eDataType) { - case GDT_Byte: + case GDT_UInt8: { EnablePixelTypeSignedByteWarning(false); const char *pszPixelType = @@ -3014,7 +3014,7 @@ double GDALRasterBand::GetMinimum(int *pbSuccess) switch (eDataType) { - case GDT_Byte: + case GDT_UInt8: { EnablePixelTypeSignedByteWarning(false); const char *pszPixelType = @@ -4259,7 +4259,7 @@ CPLErr GDALRasterBand::GetHistogram(double dfMin, double dfMax, int nBuckets, } bool bSignedByte = false; - if (eDataType == GDT_Byte) + if (eDataType == GDT_UInt8) { EnablePixelTypeSignedByteWarning(false); const char *pszPixelType = @@ -4322,7 +4322,7 @@ CPLErr GDALRasterBand::GetHistogram(double dfMin, double dfMax, int nBuckets, if (poMaskBand->RasterIO(GF_Read, 0, 0, nRasterXSize, nRasterYSize, pabyMaskData, nXReduced, nYReduced, - GDT_Byte, 0, 0, nullptr) != CE_None) + GDT_UInt8, 0, 0, nullptr) != CE_None) { CPLFree(pData); CPLFree(pabyMaskData); @@ -4343,7 +4343,7 @@ CPLErr GDALRasterBand::GetHistogram(double dfMin, double dfMax, int nBuckets, switch (eDataType) { - case GDT_Byte: + case GDT_UInt8: { if (bSignedByte) dfValue = @@ -4558,7 +4558,7 @@ CPLErr GDALRasterBand::GetHistogram(double dfMin, double dfMax, int nBuckets, if (poMaskBand && poMaskBand->RasterIO(GF_Read, iXBlock * nBlockXSize, iYBlock * nBlockYSize, nXCheck, nYCheck, - pabyMaskData, nXCheck, nYCheck, GDT_Byte, + pabyMaskData, nXCheck, nYCheck, GDT_UInt8, 0, nBlockXSize, nullptr) != CE_None) { CPLFree(pabyMaskData); @@ -4575,7 +4575,7 @@ CPLErr GDALRasterBand::GetHistogram(double dfMin, double dfMax, int nBuckets, void *pData = poBlock->GetDataRef(); // this is a special case for a common situation. - if (eDataType == GDT_Byte && !bSignedByte && dfScale == 1.0 && + if (eDataType == GDT_UInt8 && !bSignedByte && dfScale == 1.0 && (dfMin >= -0.5 && dfMin <= 0.5) && nYCheck == nBlockYSize && nXCheck == nBlockXSize && nBuckets == 256) { @@ -4614,7 +4614,7 @@ CPLErr GDALRasterBand::GetHistogram(double dfMin, double dfMax, int nBuckets, switch (eDataType) { - case GDT_Byte: + case GDT_UInt8: { if (bSignedByte) dfValue = @@ -4916,7 +4916,7 @@ CPLErr GDALRasterBand::GetDefaultHistogram(double *pdfMin, double *pdfMax, int nBuckets = 256; bool bSignedByte = false; - if (eDataType == GDT_Byte) + if (eDataType == GDT_UInt8) { EnablePixelTypeSignedByteWarning(false); const char *pszPixelType = @@ -4926,7 +4926,7 @@ CPLErr GDALRasterBand::GetDefaultHistogram(double *pdfMin, double *pdfMax, pszPixelType != nullptr && EQUAL(pszPixelType, "SIGNEDBYTE"); } - if (GetRasterDataType() == GDT_Byte && !bSignedByte) + if (GetRasterDataType() == GDT_UInt8 && !bSignedByte) { *pdfMin = -0.5; *pdfMax = 255.5; @@ -6341,7 +6341,7 @@ static inline double GetPixelValue(GDALDataType eDataType, bool bSignedByte, double dfValue = 0; switch (eDataType) { - case GDT_Byte: + case GDT_UInt8: { if (bSignedByte) dfValue = static_cast(pData)[iOffset]; @@ -6988,7 +6988,7 @@ CPLErr GDALRasterBand::ComputeStatistics(int bApproxOK, double *pdfMin, } bool bSignedByte = false; - if (eDataType == GDT_Byte) + if (eDataType == GDT_UInt8) { EnablePixelTypeSignedByteWarning(false); const char *pszPixelType = @@ -7051,7 +7051,7 @@ CPLErr GDALRasterBand::ComputeStatistics(int bApproxOK, double *pdfMin, if (poMaskBand->RasterIO(GF_Read, 0, 0, nRasterXSize, nRasterYSize, pabyMaskData, nXReduced, nYReduced, - GDT_Byte, 0, 0, nullptr) != CE_None) + GDT_UInt8, 0, 0, nullptr) != CE_None) { CPLFree(pData); CPLFree(pabyMaskData); @@ -7124,9 +7124,9 @@ CPLErr GDALRasterBand::ComputeStatistics(int bApproxOK, double *pdfMin, if (nSampleRate == 1) bApproxOK = false; - // Particular case for GDT_Byte and GUInt16 that only use integral types + // Particular case for GDT_UInt8 and GUInt16 that only use integral types // for each block, and possibly for the whole raster. - if (!poMaskBand && ((eDataType == GDT_Byte && !bSignedByte) || + if (!poMaskBand && ((eDataType == GDT_UInt8 && !bSignedByte) || eDataType == GDT_UInt16)) { // We can do integer computation on the whole raster in the Byte case @@ -7136,7 +7136,7 @@ CPLErr GDALRasterBand::ComputeStatistics(int bApproxOK, double *pdfMin, // For GUInt16, this limits to raster of 4 giga pixels const bool bIntegerStats = - ((eDataType == GDT_Byte && + ((eDataType == GDT_UInt8 && static_cast(nBlocksPerRow) * nBlocksPerColumn / nSampleRate < GUINTBIG_MAX / (255U * 255U) / @@ -7153,7 +7153,8 @@ CPLErr GDALRasterBand::ComputeStatistics(int bApproxOK, double *pdfMin, CPLTestBool( CPLGetConfigOption("GDAL_STATS_USE_INTEGER_STATS", "YES")); - const GUInt32 nMaxValueType = (eDataType == GDT_Byte) ? 255 : 65535; + const GUInt32 nMaxValueType = + (eDataType == GDT_UInt8) ? 255 : 65535; GUInt32 nMin = nMaxValueType; GUInt32 nMax = 0; GUIntBig nSum = 0; @@ -7201,7 +7202,7 @@ CPLErr GDALRasterBand::ComputeStatistics(int bApproxOK, double *pdfMin, GUIntBig &nBlockValidCountRef = bIntegerStats ? nValidCount : nBlockValidCount; - if (eDataType == GDT_Byte) + if (eDataType == GDT_UInt8) { ComputeStatisticsInternal< GByte, /* COMPUTE_OTHER_STATS = */ true>:: @@ -7378,7 +7379,7 @@ CPLErr GDALRasterBand::ComputeStatistics(int bApproxOK, double *pdfMin, if (poMaskBand && poMaskBand->RasterIO(GF_Read, iXBlock * nBlockXSize, iYBlock * nBlockYSize, nXCheck, nYCheck, - pabyMaskData, nXCheck, nYCheck, GDT_Byte, + pabyMaskData, nXCheck, nYCheck, GDT_UInt8, 0, nBlockXSize, nullptr) != CE_None) { CPLFree(pabyMaskData); @@ -8035,16 +8036,16 @@ static void ComputeMinMaxGeneric(const void *pData, GDALDataType eDataType, case GDT_Unknown: CPLAssert(false); break; - case GDT_Byte: + case GDT_UInt8: if (bSignedByte) { - ComputeMinMaxGeneric( + ComputeMinMaxGeneric( pData, nXCheck, nYCheck, nBlockXSize, sNoDataValues, pabyMaskData, dfMin, dfMax); } else { - ComputeMinMaxGeneric( + ComputeMinMaxGeneric( pData, nXCheck, nYCheck, nBlockXSize, sNoDataValues, pabyMaskData, dfMin, dfMax); } @@ -8163,7 +8164,7 @@ static bool ComputeMinMaxGenericIterBlocks( if (poMaskBand && poMaskBand->RasterIO(GF_Read, iXBlock * nBlockXSize, iYBlock * nBlockYSize, nXCheck, nYCheck, - pabyMaskData, nXCheck, nYCheck, GDT_Byte, 0, + pabyMaskData, nXCheck, nYCheck, GDT_UInt8, 0, nBlockXSize, nullptr) != CE_None) { CPLFree(pabyMaskData); @@ -8281,7 +8282,7 @@ CPLErr GDALRasterBand::ComputeRasterMinMax(int bApproxOK, double *adfMinMax) } bool bSignedByte = false; - if (eDataType == GDT_Byte) + if (eDataType == GDT_UInt8) { EnablePixelTypeSignedByteWarning(false); const char *pszPixelType = @@ -8294,7 +8295,7 @@ CPLErr GDALRasterBand::ComputeRasterMinMax(int bApproxOK, double *adfMinMax) GDALRasterIOExtraArg sExtraArg; INIT_RASTERIO_EXTRA_ARG(sExtraArg); - GUInt32 nMin = (eDataType == GDT_Byte) + GUInt32 nMin = (eDataType == GDT_UInt8) ? 255 : 65535; // used for GByte & GUInt16 cases GUInt32 nMax = 0; // used for GByte & GUInt16 cases @@ -8307,7 +8308,7 @@ CPLErr GDALRasterBand::ComputeRasterMinMax(int bApproxOK, double *adfMinMax) double dfMax = -std::numeric_limits::infinity(); // used for generic code path const bool bUseOptimizedPath = - !poMaskBand && ((eDataType == GDT_Byte && !bSignedByte) || + !poMaskBand && ((eDataType == GDT_UInt8 && !bSignedByte) || eDataType == GDT_Int16 || eDataType == GDT_UInt16); const auto ComputeMinMaxForBlock = @@ -8315,7 +8316,7 @@ CPLErr GDALRasterBand::ComputeRasterMinMax(int bApproxOK, double *adfMinMax) &nMaxInt16](const void *pData, int nXCheck, int nBufferWidth, int nYCheck) { - if (eDataType == GDT_Byte && !bSignedByte) + if (eDataType == GDT_UInt8 && !bSignedByte) { const bool bHasNoData = sNoDataValues.bGotNoDataValue && @@ -8431,7 +8432,7 @@ CPLErr GDALRasterBand::ComputeRasterMinMax(int bApproxOK, double *adfMinMax) if (poMaskBand->RasterIO(GF_Read, 0, 0, nRasterXSize, nRasterYSize, pabyMaskData, nXReduced, nYReduced, - GDT_Byte, 0, 0, nullptr) != CE_None) + GDT_UInt8, 0, 0, nullptr) != CE_None) { CPLFree(pData); CPLFree(pabyMaskData); @@ -8504,7 +8505,7 @@ CPLErr GDALRasterBand::ComputeRasterMinMax(int bApproxOK, double *adfMinMax) poBlock->DropLock(); - if (eDataType == GDT_Byte && !bSignedByte && nMin == 0 && + if (eDataType == GDT_UInt8 && !bSignedByte && nMin == 0 && nMax == 255) break; } @@ -8524,7 +8525,7 @@ CPLErr GDALRasterBand::ComputeRasterMinMax(int bApproxOK, double *adfMinMax) if (bUseOptimizedPath) { - if ((eDataType == GDT_Byte && !bSignedByte) || eDataType == GDT_UInt16) + if ((eDataType == GDT_UInt8 && !bSignedByte) || eDataType == GDT_UInt16) { dfMin = nMin; dfMax = nMax; @@ -8647,7 +8648,7 @@ CPLErr GDALRasterBand::ComputeRasterMinMaxLocation(double *pdfMin, } bool bSignedByte = false; - if (eDataType == GDT_Byte) + if (eDataType == GDT_UInt8) { EnablePixelTypeSignedByteWarning(false); const char *pszPixelType = @@ -8683,7 +8684,7 @@ CPLErr GDALRasterBand::ComputeRasterMinMaxLocation(double *pdfMin, if (poMaskBand && poMaskBand->RasterIO(GF_Read, iXBlock * nBlockXSize, iYBlock * nBlockYSize, nXCheck, nYCheck, - pabyMaskData, nXCheck, nYCheck, GDT_Byte, 0, + pabyMaskData, nXCheck, nYCheck, GDT_UInt8, 0, nBlockXSize, nullptr) != CE_None) { CPLFree(pabyMaskData); @@ -8792,7 +8793,7 @@ CPLErr GDALRasterBand::ComputeRasterMinMaxLocation(double *pdfMin, poBlock->DropLock(); - if (eDataType == GDT_Byte) + if (eDataType == GDT_UInt8) { if (bNeedsMin && dfMin == 0) { @@ -9062,7 +9063,7 @@ CPLErr CPL_STDCALL GDALSetDefaultRAT(GDALRasterBandH hBand, * *
  • If there is no nodata value, but the dataset has an alpha band that seems * to apply to this band (specific rules yet to be determined) and that is of - * type GDT_Byte then that alpha band will be returned, and the flags + * type GDT_UInt8 then that alpha band will be returned, and the flags * GMF_PER_DATASET and GMF_ALPHA will be returned in the flags. *
  • *
  • If neither of the above apply, an instance of the new @@ -9275,7 +9276,7 @@ GDALRasterBand *GDALRasterBand::GetMaskBand() this == poDS->GetRasterBand(1) && poDS->GetRasterBand(2)->GetColorInterpretation() == GCI_AlphaBand) { - if (poDS->GetRasterBand(2)->GetRasterDataType() == GDT_Byte) + if (poDS->GetRasterBand(2)->GetRasterDataType() == GDT_UInt8) { nMaskFlags = GMF_ALPHA | GMF_PER_DATASET; poMask.resetNotOwned(poDS->GetRasterBand(2)); @@ -9303,7 +9304,7 @@ GDALRasterBand *GDALRasterBand::GetMaskBand() this == poDS->GetRasterBand(3)) && poDS->GetRasterBand(4)->GetColorInterpretation() == GCI_AlphaBand) { - if (poDS->GetRasterBand(4)->GetRasterDataType() == GDT_Byte) + if (poDS->GetRasterBand(4)->GetRasterDataType() == GDT_UInt8) { nMaskFlags = GMF_ALPHA | GMF_PER_DATASET; poMask.resetNotOwned(poDS->GetRasterBand(4)); @@ -9401,7 +9402,7 @@ GDALRasterBandH CPL_STDCALL GDALGetMaskBand(GDALRasterBandH hBand) *
  • *
  • If there is no nodata value, but the dataset has an alpha band that * seems to apply to this band (specific rules yet to be determined) and that is - * of type GDT_Byte then that alpha band will be returned, and the flags + * of type GDT_UInt8 then that alpha band will be returned, and the flags * GMF_PER_DATASET and GMF_ALPHA will be returned in the flags. *
  • *
  • If neither of the above apply, an instance of the new @@ -9667,8 +9668,8 @@ GDALRasterBand::GetIndexColorTranslationTo(GDALRasterBand *poReferenceBand, if (poReferenceBand->GetColorInterpretation() == GCI_PaletteIndex && // cppcheck-suppress knownConditionTrueFalse GetColorInterpretation() == GCI_PaletteIndex && - poReferenceBand->GetRasterDataType() == GDT_Byte && - GetRasterDataType() == GDT_Byte) + poReferenceBand->GetRasterDataType() == GDT_UInt8 && + GetRasterDataType() == GDT_UInt8) { const GDALColorTable *srcColorTable = GetColorTable(); GDALColorTable *destColorTable = poReferenceBand->GetColorTable(); @@ -10378,7 +10379,7 @@ const char *GDALRasterBand::GetMetadataItem(const char *pszName, const char *pszDomain) { // TODO (GDAL 4.0?): remove this when GDAL 3.7 has been widely adopted. - if (m_bEnablePixelTypeSignedByteWarning && eDataType == GDT_Byte && + if (m_bEnablePixelTypeSignedByteWarning && eDataType == GDT_UInt8 && pszDomain != nullptr && EQUAL(pszDomain, "IMAGE_STRUCTURE") && EQUAL(pszName, "PIXELTYPE")) { diff --git a/gcore/gdalrescaledalphaband.cpp b/gcore/gdalrescaledalphaband.cpp index fa1eb8acece4..2b4b432db64b 100644 --- a/gcore/gdalrescaledalphaband.cpp +++ b/gcore/gdalrescaledalphaband.cpp @@ -2,7 +2,7 @@ * * Project: GDAL Core * Purpose: Implementation of GDALRescaledAlphaBand, a class implementing - * a band mask based from a non-GDT_Byte alpha band + * a band mask based from a non-GDT_UInt8 alpha band * Author: Even Rouault, * ****************************************************************************** @@ -37,7 +37,7 @@ GDALRescaledAlphaBand::GDALRescaledAlphaBand(GDALRasterBand *poParentIn) nRasterXSize = poParent->GetXSize(); nRasterYSize = poParent->GetYSize(); - eDataType = GDT_Byte; + eDataType = GDT_UInt8; poParent->GetBlockSize(&nBlockXSize, &nBlockYSize); } @@ -69,7 +69,7 @@ CPLErr GDALRescaledAlphaBand::IReadBlock(int nXBlockOff, int nYBlockOff, return IRasterIO(GF_Read, nXBlockOff * nBlockXSize, nYBlockOff * nBlockYSize, nXSizeRequest, nYSizeRequest, - pImage, nXSizeRequest, nYSizeRequest, GDT_Byte, 1, + pImage, nXSizeRequest, nYSizeRequest, GDT_UInt8, 1, nBlockXSize, &sExtraArg); } @@ -85,7 +85,7 @@ CPLErr GDALRescaledAlphaBand::IRasterIO( // Optimization in common use case. // This avoids triggering the block cache on this band, which helps // reducing the global block cache consumption. - if (eRWFlag == GF_Read && eBufType == GDT_Byte && nXSize == nBufXSize && + if (eRWFlag == GF_Read && eBufType == GDT_UInt8 && nXSize == nBufXSize && nYSize == nBufYSize && nPixelSpace == 1) { if (pTemp == nullptr) diff --git a/gcore/gdalvirtualmem.cpp b/gcore/gdalvirtualmem.cpp index 7975d8f358c0..2710a3a9f9e0 100644 --- a/gcore/gdalvirtualmem.cpp +++ b/gcore/gdalvirtualmem.cpp @@ -42,7 +42,7 @@ class GDALVirtualMem // int nYSize; coord_type nBufXSize = 0; coord_type nBufYSize = 0; - GDALDataType eBufType = GDT_Byte; + GDALDataType eBufType = GDT_UInt8; int nBandCount = 0; int *panBandMap = nullptr; int nPixelSpace = 0; @@ -1021,7 +1021,7 @@ class GDALTiledVirtualMem int nYSize = 0; int nTileXSize = 0; int nTileYSize = 0; - GDALDataType eBufType = GDT_Byte; + GDALDataType eBufType = GDT_UInt8; int nBandCount = 0; int *panBandMap = nullptr; GDALTileOrganization eTileOrganization = GTO_TIP; diff --git a/gcore/overview.cpp b/gcore/overview.cpp index b5cb4e02183b..e9502878d237 100644 --- a/gcore/overview.cpp +++ b/gcore/overview.cpp @@ -170,7 +170,7 @@ static CPLErr GDALResampleChunk_Near(const GDALOverviewResampleArgs &args, { // For nearest resampling, as no computation is done, only the // size of the data type matters. - case GDT_Byte: + case GDT_UInt8: case GDT_Int8: { CPLAssert(GDALGetDataTypeSizeBytes(args.eWrkDataType) == 1); @@ -1380,7 +1380,7 @@ GDALResampleChunk_AverageOrRMS_T(const GDALOverviewResampleArgs &args, if (bSrcXSpacingIsTwo && nSrcYOff2 == nSrcYOff + 2 && pabyChunkNodataMask == nullptr) { - if constexpr (eWrkDataType == GDT_Byte || + if constexpr (eWrkDataType == GDT_UInt8 || eWrkDataType == GDT_UInt16) { // Optimized case : no nodata, overview by a factor of 2 and @@ -1391,7 +1391,7 @@ GDALResampleChunk_AverageOrRMS_T(const GDALOverviewResampleArgs &args, nChunkXSize; int iDstPixel = 0; #ifdef USE_SSE2 - if constexpr (eWrkDataType == GDT_Byte) + if constexpr (eWrkDataType == GDT_UInt8) { if constexpr (bQuadraticMean) { @@ -1799,7 +1799,7 @@ GDALResampleChunk_AverageOrRMS_T(const GDALOverviewResampleArgs &args, continue; } } - if constexpr (eWrkDataType == GDT_Byte) + if constexpr (eWrkDataType == GDT_UInt8) { T nVal; if constexpr (bQuadraticMean) @@ -1948,9 +1948,9 @@ GDALResampleChunk_AverageOrRMSInternal(const GDALOverviewResampleArgs &args, *peDstBufferDataType = args.eWrkDataType; switch (args.eWrkDataType) { - case GDT_Byte: + case GDT_UInt8: { - return GDALResampleChunk_AverageOrRMS_T( args, static_cast(pChunk), ppDstBuffer); } @@ -2576,7 +2576,7 @@ static CPLErr GDALResampleChunk_ModeT(const GDALOverviewResampleArgs &args, paDstScanline[iDstPixel - nDstXOff] = paVals[iMaxVal]; } else if constexpr (std::is_same::value) - // ( eSrcDataType == GDT_Byte && nEntryCount < 256 ) + // ( eSrcDataType == GDT_UInt8 && nEntryCount < 256 ) { // So we go here for a paletted or non-paletted byte band. // The input values are then between 0 and 255. @@ -2645,7 +2645,7 @@ static CPLErr GDALResampleChunk_Mode(const GDALOverviewResampleArgs &args, // For mode resampling, as no computation is done, only the // size of the data type matters... except for Byte where we have // special processing. And for floating point values - case GDT_Byte: + case GDT_UInt8: { return GDALResampleChunk_ModeT(args, static_cast(pChunk), @@ -3398,7 +3398,7 @@ static CPLErr GDALResampleChunk_ConvolutionT( // TODO: we should have some generic function to do this. Twork fDstMin = cpl::NumericLimits::lowest(); Twork fDstMax = cpl::NumericLimits::max(); - if (dstDataType == GDT_Byte) + if (dstDataType == GDT_UInt8) { fDstMin = std::numeric_limits::min(); fDstMax = std::numeric_limits::max(); @@ -4166,7 +4166,7 @@ GDALResampleChunk_ConvolutionInternal(const GDALOverviewResampleArgs &args, // Cubic, etc... can have overshoots, so make sure we clamp values to the // maximum value if NBITS is set. if (eResample != GRA_Bilinear && args.nOvrNBITS > 0 && - (args.eOvrDataType == GDT_Byte || args.eOvrDataType == GDT_UInt16 || + (args.eOvrDataType == GDT_UInt8 || args.eOvrDataType == GDT_UInt16 || args.eOvrDataType == GDT_UInt32)) { int nBits = args.nOvrNBITS; @@ -4187,7 +4187,7 @@ GDALResampleChunk_ConvolutionInternal(const GDALOverviewResampleArgs &args, switch (args.eWrkDataType) { - case GDT_Byte: + case GDT_UInt8: { return GDALResampleChunk_ConvolutionTRasterIO(GF_Read, 0, nChunkYOffQueried, nWidth, nChunkYSizeQueried, pabyChunkNodataMask, - nWidth, nChunkYSizeQueried, GDT_Byte, 0, - 0, nullptr); + nWidth, nChunkYSizeQueried, GDT_UInt8, + 0, 0, nullptr); // Special case to promote 1bit data to 8bit 0/255 values. if (EQUAL(pszResampling, "AVERAGE_BIT2GRAYSCALE")) @@ -5267,7 +5267,7 @@ CPLErr GDALRegenerateOverviewsEx(GDALRasterBandH hSrcBand, int nOverviewCount, pafChunk[i] = 255.0f; } } - else if (eWrkDataType == GDT_Byte) + else if (eWrkDataType == GDT_UInt8) { GByte *pabyChunk = static_cast(pChunk); for (size_t i = 0; @@ -5316,7 +5316,7 @@ CPLErr GDALRegenerateOverviewsEx(GDALRasterBandH hSrcBand, int nOverviewCount, pafChunk[i] = 255.0f; } } - else if (eWrkDataType == GDT_Byte) + else if (eWrkDataType == GDT_UInt8) { GByte *pabyChunk = static_cast(pChunk); for (size_t i = 0; @@ -6479,7 +6479,7 @@ CPLErr GDALRegenerateOverviewsMultiBand( nChunkXSizeQueried, nChunkYSizeQueried, apabyChunkNoDataMask[iBand].get(), nChunkXSizeQueried, nChunkYSizeQueried, - GDT_Byte, 0, 0, nullptr); + GDT_UInt8, 0, 0, nullptr); } } } diff --git a/gcore/rasterio.cpp b/gcore/rasterio.cpp index 65b8119eec51..81046a230299 100644 --- a/gcore/rasterio.cpp +++ b/gcore/rasterio.cpp @@ -833,8 +833,9 @@ CPLErr GDALRasterBand::IRasterIO(GDALRWFlag eRWFlag, int nXOff, int nYOff, { bRet = DownsamplingIntegerXFactor( this, iSrcX, nSrcXInc, iSrcOffsetCst, pabyDstData, - static_cast(nPixelSpace), nBufXSize, GDT_Byte, - GDT_Byte, nStartBlockX, nBlockXSize, poBlock, nLBlockY); + static_cast(nPixelSpace), nBufXSize, GDT_UInt8, + GDT_UInt8, nStartBlockX, nBlockXSize, poBlock, + nLBlockY); } else if (eDataType == eBufType) { @@ -1396,7 +1397,7 @@ CPLErr GDALRasterBand::RasterIOResampled( GF_Read, nChunkXOffQueried, nChunkYOffQueried, nChunkXSizeQueried, nChunkYSizeQueried, pabyChunkNoDataMask, nChunkXSizeQueried, - nChunkYSizeQueried, GDT_Byte, 0, 0, nullptr); + nChunkYSizeQueried, GDT_UInt8, 0, 0, nullptr); /* Optimizations if mask if fully opaque or transparent */ int nPixels = nChunkXSizeQueried * nChunkYSizeQueried; @@ -1857,7 +1858,7 @@ CPLErr GDALDataset::RasterIOResampled( GF_Read, nChunkXOffQueried, nChunkYOffQueried, nChunkXSizeQueried, nChunkYSizeQueried, pabyChunkNoDataMask, nChunkXSizeQueried, - nChunkYSizeQueried, GDT_Byte, 0, 0, nullptr); + nChunkYSizeQueried, GDT_UInt8, 0, 0, nullptr); /* Optimizations if mask if fully opaque or transparent */ const int nPixels = nChunkXSizeQueried * nChunkYSizeQueried; @@ -1878,7 +1879,7 @@ CPLErr GDALDataset::RasterIOResampled( for (int j = 0; j < nDstYCount; j++) { GDALCopyWords64( - abyZero, GDT_Byte, 0, + abyZero, GDT_UInt8, 0, static_cast(pData) + iBand * nBandSpace + nLineSpace * (j + nDstYOff) + @@ -3217,7 +3218,7 @@ inline void GDALCopyWordsFromT(const T *const CPL_RESTRICT pSrcData, { switch (eDstType) { - case GDT_Byte: + case GDT_UInt8: GDALCopyWordsT(pSrcData, nSrcPixelStride, static_cast(pDstData), nDstPixelStride, nWordCount); @@ -3420,7 +3421,7 @@ static void GDALReplicateWord(const void *CPL_RESTRICT pSrcData, switch (eDstType) { - case GDT_Byte: + case GDT_UInt8: case GDT_Int8: { if (nDstPixelStride == 1) @@ -3760,7 +3761,7 @@ void CPL_STDCALL GDALCopyWords(const void *CPL_RESTRICT pSrcData, * rules: *
      *
    • Values assigned to a lower range integer type are clipped. For - * instance assigning GDT_Int16 values to a GDT_Byte buffer will cause values + * instance assigning GDT_Int16 values to a GDT_UInt8 buffer will cause values * less the 0 to be set to 0, and values larger than 255 to be set to 255. *
    • *
    • @@ -3882,7 +3883,7 @@ void CPL_STDCALL GDALCopyWords64(const void *CPL_RESTRICT pSrcData, if (eSrcType == eDstType) { - if (eSrcType == GDT_Byte || eSrcType == GDT_Int8) + if (eSrcType == GDT_UInt8 || eSrcType == GDT_Int8) { GDALFastCopy(static_cast(pDstData), nDstPixelStride, static_cast(pSrcData), nSrcPixelStride, @@ -3933,7 +3934,7 @@ void CPL_STDCALL GDALCopyWords64(const void *CPL_RESTRICT pSrcData, // directly. switch (eSrcType) { - case GDT_Byte: + case GDT_UInt8: GDALCopyWordsFromT( static_cast(pSrcData), nSrcPixelStride, false, pDstData, eDstType, nDstPixelStride, nWordCount); @@ -4481,7 +4482,7 @@ CPLErr GDALDataset::BlockBasedRasterIO( int nBlockXSize = 1; int nBlockYSize = 1; CPLErr eErr = CE_None; - GDALDataType eDataType = GDT_Byte; + GDALDataType eDataType = GDT_UInt8; const bool bUseIntegerRequestCoords = (!psExtraArg->bFloatingPointWindowValidity || @@ -6075,7 +6076,7 @@ void GDALDeinterleave(const void *pSourceBuffer, GDALDataType eSourceDT, { if (eSourceDT == eDestDT) { - if (eSourceDT == GDT_Byte || eSourceDT == GDT_Int8) + if (eSourceDT == GDT_UInt8 || eSourceDT == GDT_Int8) { if (nComponents == 3) { @@ -6358,7 +6359,7 @@ static void GDALTranspose2D(const void *pSrc, GDALDataType eSrcType, DST *pDst, // clang-format off switch (eSrcType) { - case GDT_Byte: CALL_GDALTranspose2D_internal(uint8_t); break; + case GDT_UInt8: CALL_GDALTranspose2D_internal(uint8_t); break; case GDT_Int8: CALL_GDALTranspose2D_internal(int8_t); break; case GDT_UInt16: CALL_GDALTranspose2D_internal(uint16_t); break; case GDT_Int16: CALL_GDALTranspose2D_internal(int16_t); break; @@ -6580,7 +6581,7 @@ GDALInterleave4Byte(const uint8_t *CPL_RESTRICT pSrc, void GDALTranspose2D(const void *pSrc, GDALDataType eSrcType, void *pDst, GDALDataType eDstType, size_t nSrcWidth, size_t nSrcHeight) { - if (eSrcType == eDstType && (eSrcType == GDT_Byte || eSrcType == GDT_Int8)) + if (eSrcType == eDstType && (eSrcType == GDT_UInt8 || eSrcType == GDT_Int8)) { if (nSrcHeight == 2) { @@ -6620,7 +6621,7 @@ void GDALTranspose2D(const void *pSrc, GDALDataType eSrcType, void *pDst, // clang-format off switch (eDstType) { - case GDT_Byte: CALL_GDALTranspose2D_internal(uint8_t, false); break; + case GDT_UInt8: CALL_GDALTranspose2D_internal(uint8_t, false); break; case GDT_Int8: CALL_GDALTranspose2D_internal(int8_t, false); break; case GDT_UInt16: CALL_GDALTranspose2D_internal(uint16_t, false); break; case GDT_Int16: CALL_GDALTranspose2D_internal(int16_t, false); break; diff --git a/gcore/rawdataset.cpp b/gcore/rawdataset.cpp index 4b6f384c7c30..cf3299f332b8 100644 --- a/gcore/rawdataset.cpp +++ b/gcore/rawdataset.cpp @@ -426,10 +426,10 @@ CPLErr RawRasterBand::FlushCache(bool bAtClosing) bool RawRasterBand::NeedsByteOrderChange() const { #ifdef CPL_LSB - return eDataType != GDT_Byte && + return eDataType != GDT_UInt8 && eByteOrder != RawRasterBand::ByteOrder::ORDER_LITTLE_ENDIAN; #else - return eDataType != GDT_Byte && + return eDataType != GDT_UInt8 && eByteOrder != RawRasterBand::ByteOrder::ORDER_BIG_ENDIAN; #endif } diff --git a/ogr/ogrsf_frmts/gpkg/gdalgeopackagerasterband.cpp b/ogr/ogrsf_frmts/gpkg/gdalgeopackagerasterband.cpp index 74879230fcbe..53e4392f215f 100644 --- a/ogr/ogrsf_frmts/gpkg/gdalgeopackagerasterband.cpp +++ b/ogr/ogrsf_frmts/gpkg/gdalgeopackagerasterband.cpp @@ -76,7 +76,7 @@ GDALGPKGMBTilesLikePseudoDataset::~GDALGPKGMBTilesLikePseudoDataset() void GDALGPKGMBTilesLikePseudoDataset::SetDataType(GDALDataType eDT) { - CPLAssert(eDT == GDT_Byte || eDT == GDT_Int16 || eDT == GDT_UInt16 || + CPLAssert(eDT == GDT_UInt8 || eDT == GDT_Int16 || eDT == GDT_UInt16 || eDT == GDT_Float32); m_eDT = eDT; m_nDTSize = GDALGetDataTypeSizeBytes(m_eDT); @@ -276,7 +276,7 @@ GDALColorTable *GDALGPKGMBTilesLikeRasterBand::GetColorTable() CPLErr GDALGPKGMBTilesLikeRasterBand::SetColorTable(GDALColorTable *poCT) { - if (m_poTPD->m_eDT != GDT_Byte) + if (m_poTPD->m_eDT != GDT_UInt8) return CE_Failure; if (poDS->GetRasterCount() != 1) { @@ -315,7 +315,7 @@ void GDALGPKGMBTilesLikeRasterBand::AssignColorTable(const GDALColorTable *poCT) GDALColorInterp GDALGPKGMBTilesLikeRasterBand::GetColorInterpretation() { - if (m_poTPD->m_eDT != GDT_Byte) + if (m_poTPD->m_eDT != GDT_UInt8) return GCI_Undefined; if (poDS->GetRasterCount() == 1) return GetColorTable() ? GCI_PaletteIndex : GCI_GrayIndex; @@ -439,7 +439,7 @@ CPLErr GDALGPKGMBTilesLikePseudoDataset::ReadTile( const int nBands = IGetRasterCount(); auto poDSTile = std::unique_ptr(GDALDataset::Open( osMemFileName.c_str(), GDAL_OF_RASTER | GDAL_OF_INTERNAL, - (m_eDT == GDT_Byte) ? apszDriversByte + (m_eDT == GDT_UInt8) ? apszDriversByte : (m_eTF == GPKG_TF_TIFF_32BIT_FLOAT) ? apszDriversFloat : apszDriversInt, nullptr, nullptr)); @@ -455,7 +455,7 @@ CPLErr GDALGPKGMBTilesLikePseudoDataset::ReadTile( if (!(poDSTile->GetRasterXSize() == nBlockXSize && poDSTile->GetRasterYSize() == nBlockYSize && (nTileBandCount >= 1 && nTileBandCount <= 4)) || - (m_eDT != GDT_Byte && nTileBandCount != 1)) + (m_eDT != GDT_UInt8 && nTileBandCount != 1)) { CPLError(CE_Failure, CPLE_AppDefined, "Inconsistent tiles characteristics"); @@ -463,7 +463,7 @@ CPLErr GDALGPKGMBTilesLikePseudoDataset::ReadTile( return CE_Failure; } - GDALDataType eRequestDT = GDT_Byte; + GDALDataType eRequestDT = GDT_UInt8; if (m_eTF == GPKG_TF_PNG_16BIT) { CPLAssert(m_eDT == GDT_Int16 || m_eDT == GDT_UInt16 || @@ -485,7 +485,7 @@ CPLErr GDALGPKGMBTilesLikePseudoDataset::ReadTile( return CE_Failure; } - if (m_eDT != GDT_Byte) + if (m_eDT != GDT_UInt8) { int bHasNoData = FALSE; const double dfNoDataValue = @@ -723,7 +723,7 @@ GByte *GDALGPKGMBTilesLikePseudoDataset::ReadTile(int nRow, int nCol) const int nBands = IGetRasterCount(); const size_t nBandBlockSize = static_cast(nBlockXSize) * nBlockYSize * m_nDTSize; - const int nTileBands = m_eDT == GDT_Byte ? 4 : 1; + const int nTileBands = m_eDT == GDT_UInt8 ? 4 : 1; if (m_nShiftXPixelsMod || m_nShiftYPixelsMod) { GByte *pabyData = nullptr; @@ -872,7 +872,7 @@ GByte *GDALGPKGMBTilesLikePseudoDataset::ReadTile(int nRow, int nCol, char *pszSQL = sqlite3_mprintf( "SELECT tile_data%s FROM \"%w\" " "WHERE zoom_level = %d AND tile_row = %d AND tile_column = %d%s", - m_eDT != GDT_Byte ? ", id" : "", // MBTiles do not have an id + m_eDT != GDT_UInt8 ? ", id" : "", // MBTiles do not have an id m_osRasterTable.c_str(), m_nZoomLevel, GetRowFromIntoTopConvention(nRow), nCol, !m_osWHERE.empty() ? CPLSPrintf(" AND (%s)", m_osWHERE.c_str()) : ""); @@ -894,7 +894,7 @@ GByte *GDALGPKGMBTilesLikePseudoDataset::ReadTile(int nRow, int nCol, { const int nBytes = sqlite3_column_bytes(hStmt, 0); GIntBig nTileId = - (m_eDT == GDT_Byte) ? 0 : sqlite3_column_int64(hStmt, 1); + (m_eDT == GDT_UInt8) ? 0 : sqlite3_column_int64(hStmt, 1); GByte *pabyRawData = static_cast( const_cast(sqlite3_column_blob(hStmt, 0))); const CPLString osMemFileName( @@ -1115,7 +1115,7 @@ CPLErr GDALGPKGMBTilesLikeRasterBand::IReadBlock(int nBlockXOff, int nBlockYOff, pabyTileData + (iBand - 1) * nBandBlockSize, nBandBlockSize); #ifdef DEBUG_VERBOSE - if (eDataType == GDT_Byte && + if (eDataType == GDT_UInt8 && (nBlockXOff + 1) * nBlockXSize <= nRasterXSize && (nBlockYOff + 1) * nBlockYSize > nRasterYSize) { @@ -1615,7 +1615,7 @@ CPLErr GDALGPKGMBTilesLikePseudoDataset::WriteTileInternal() m_asCachedTilesDesc[i].nCol = -1; m_asCachedTilesDesc[i].nIdxWithinTileData = -1; } - const int nTileBands = m_eDT == GDT_Byte ? 4 : 1; + const int nTileBands = m_eDT == GDT_UInt8 ? 4 : 1; GByte *pabyTemp = m_pabyCachedTiles + nTileBands * nBandBlockSize; ReadTile(nRow, nCol, pabyTemp, &bIsLossyFormat); for (int i = 0; i < nBands; i++) @@ -1642,7 +1642,8 @@ CPLErr GDALGPKGMBTilesLikePseudoDataset::WriteTileInternal() return CE_None; #ifdef DEBUG_VERBOSE - if (m_nShiftXPixelsMod == 0 && m_nShiftYPixelsMod == 0 && m_eDT == GDT_Byte) + if (m_nShiftXPixelsMod == 0 && m_nShiftYPixelsMod == 0 && + m_eDT == GDT_UInt8) { int nBlockXOff = nCol; int nBlockYOff = nRow; @@ -1736,7 +1737,7 @@ CPLErr GDALGPKGMBTilesLikePseudoDataset::WriteTileInternal() bool bAllOpaque = true; // Detect fully transparent tiles, but only if all bands are dirty (that is // the user wrote content into them) ! - if (bAllDirty && m_eDT == GDT_Byte && m_poCT == nullptr && nAlphaBand != 0) + if (bAllDirty && m_eDT == GDT_UInt8 && m_poCT == nullptr && nAlphaBand != 0) { GByte byFirstAlphaVal = m_pabyCachedTiles[(nAlphaBand - 1) * nBlockXSize * nBlockYSize]; @@ -1763,7 +1764,7 @@ CPLErr GDALGPKGMBTilesLikePseudoDataset::WriteTileInternal() else bAllOpaque = false; } - else if (bAllDirty && m_eDT == GDT_Byte && m_poCT == nullptr && + else if (bAllDirty && m_eDT == GDT_UInt8 && m_poCT == nullptr && (!bHasNoData || dfNoDataValue == 0.0)) { bool bAllEmpty = true; @@ -1834,10 +1835,10 @@ CPLErr GDALGPKGMBTilesLikePseudoDataset::WriteTileInternal() bool bTileDriverSupports4Bands = false; bool bTileDriverSupportsCT = false; - if (nBands == 1 && m_eDT == GDT_Byte) + if (nBands == 1 && m_eDT == GDT_UInt8) IGetRasterBand(1)->GetColorTable(); - GDALDataType eTileDT = GDT_Byte; + GDALDataType eTileDT = GDT_UInt8; // If not all bands are dirty, then (temporarily) use a lossless format if (m_eTF == GPKG_TF_PNG_JPEG || (!bAllDirty && m_eTF == GPKG_TF_JPEG)) { @@ -2156,7 +2157,7 @@ CPLErr GDALGPKGMBTilesLikePseudoDataset::WriteTileInternal() } else { - CPLAssert(m_eDT == GDT_Byte); + CPLAssert(m_eDT == GDT_UInt8); for (int i = 0; i < nTileBands; i++) { int iSrc = i; @@ -2171,7 +2172,7 @@ CPLErr GDALGPKGMBTilesLikePseudoDataset::WriteTileInternal() auto hBand = MEMCreateRasterBandEx( poMEMDS, i + 1, m_pabyCachedTiles + iSrc * nBlockXSize * nBlockYSize, - GDT_Byte, 0, 0, false); + GDT_UInt8, 0, 0, false); poMEMDS->AddMEMBand(hBand); if (i == 0 && nTileBands == 1 && m_poCT != nullptr) @@ -2202,12 +2203,12 @@ CPLErr GDALGPKGMBTilesLikePseudoDataset::WriteTileInternal() CPLAssert(bAllDirty); auto poMEM_RGB_DS = MEMDataset::Create("", nBlockXSize, nBlockYSize, - 0, GDT_Byte, nullptr); + 0, GDT_UInt8, nullptr); for (int i = 0; i < 3; i++) { auto hBand = MEMCreateRasterBandEx( poMEMDS, i + 1, m_pabyCachedTiles + i * nBandBlockSize, - GDT_Byte, 0, 0, false); + GDT_UInt8, 0, 0, false); poMEM_RGB_DS->AddMEMBand(hBand); } @@ -2670,8 +2671,8 @@ GDALGPKGMBTilesLikePseudoDataset::FlushRemainingShiftedTiles(bool bPartialFlush) "SELECT tile_data%s FROM \"%w\" " "WHERE zoom_level = %d AND tile_row = %d AND tile_column = " "%d%s", - m_eDT != GDT_Byte ? ", id" - : "", // MBTiles do not have an id + m_eDT != GDT_UInt8 ? ", id" + : "", // MBTiles do not have an id m_osRasterTable.c_str(), m_nZoomLevel, GetRowFromIntoTopConvention(nRow), nCol, !m_osWHERE.empty() @@ -2691,7 +2692,7 @@ GDALGPKGMBTilesLikePseudoDataset::FlushRemainingShiftedTiles(bool bPartialFlush) { const int nBytes = sqlite3_column_bytes(hNewStmt, 0); GIntBig nTileId = - (m_eDT == GDT_Byte) + (m_eDT == GDT_UInt8) ? 0 : sqlite3_column_int64(hNewStmt, 1); GByte *pabyRawData = @@ -2707,7 +2708,7 @@ GDALGPKGMBTilesLikePseudoDataset::FlushRemainingShiftedTiles(bool bPartialFlush) double dfTileScale = 1.0; GetTileOffsetAndScale(nTileId, dfTileOffset, dfTileScale); - const int nTileBands = m_eDT == GDT_Byte ? 4 : 1; + const int nTileBands = m_eDT == GDT_UInt8 ? 4 : 1; GByte *pabyTemp = m_pabyCachedTiles + nTileBands * nBandBlockSize; ReadTile(osMemFileName, pabyTemp, dfTileOffset, @@ -3068,7 +3069,7 @@ CPLErr GDALGPKGMBTilesLikePseudoDataset::WriteShiftedTile( } rc = sqlite3_step(hStmt); - const int nTileBands = m_eDT == GDT_Byte ? 4 : 1; + const int nTileBands = m_eDT == GDT_UInt8 ? 4 : 1; GByte *pabyTemp = m_pabyCachedTiles + nTileBands * nBandBlockSize; if (rc == SQLITE_ROW) { @@ -3398,7 +3399,7 @@ CPLErr GDALGPKGMBTilesLikeRasterBand::IWriteBlock(int nBlockXOff, { #ifdef DEBUG_VERBOSE - if (eDataType == GDT_Byte && + if (eDataType == GDT_UInt8 && nBlockXOff * nBlockXSize <= nRasterXSize - nBlockXSize && nBlockYOff * nBlockYSize > nRasterYSize - nBlockYSize) @@ -3665,7 +3666,7 @@ CPLErr GDALGeoPackageRasterBand::SetNoDataValue(double dfNoDataValue) GDALGeoPackageDataset *poGDS = cpl::down_cast(poDS); - if (eDataType == GDT_Byte) + if (eDataType == GDT_UInt8) { if (!(dfNoDataValue >= 0 && dfNoDataValue <= 255 && static_cast(dfNoDataValue) == dfNoDataValue)) @@ -3835,7 +3836,7 @@ char **GDALGeoPackageRasterBand::GetMetadata(const char *pszDomain) cpl::down_cast(poDS); LoadBandMetadata(); /* force loading from storage if needed */ - if (poGDS->eAccess == GA_ReadOnly && eDataType != GDT_Byte && + if (poGDS->eAccess == GA_ReadOnly && eDataType != GDT_UInt8 && (pszDomain == nullptr || EQUAL(pszDomain, "")) && !m_bMinMaxComputedFromTileAncillary && !GDALGPKGMBTilesLikeRasterBand::GetMetadataItem("STATISTICS_MINIMUM") && @@ -3952,7 +3953,7 @@ const char *GDALGeoPackageRasterBand::GetMetadataItem(const char *pszName, { LoadBandMetadata(); /* force loading from storage if needed */ - if (m_bAddImplicitStatistics && eDataType != GDT_Byte && + if (m_bAddImplicitStatistics && eDataType != GDT_UInt8 && (pszDomain == nullptr || EQUAL(pszDomain, "")) && (EQUAL(pszName, "STATISTICS_MINIMUM") || EQUAL(pszName, "STATISTICS_MAXIMUM"))) diff --git a/ogr/ogrsf_frmts/gpkg/ogrgeopackagedatasource.cpp b/ogr/ogrsf_frmts/gpkg/ogrgeopackagedatasource.cpp index b9e8c9a23117..7756ee815993 100644 --- a/ogr/ogrsf_frmts/gpkg/ogrgeopackagedatasource.cpp +++ b/ogr/ogrsf_frmts/gpkg/ogrgeopackagedatasource.cpp @@ -2366,7 +2366,7 @@ bool GDALGeoPackageDataset::InitRaster( { nBandCount = poParentDS->GetRasterCount(); } - else if (m_eDT != GDT_Byte) + else if (m_eDT != GDT_UInt8) { if (pszBAND_COUNT != nullptr && !EQUAL(pszBAND_COUNT, "AUTO") && !EQUAL(pszBAND_COUNT, "1")) @@ -2461,10 +2461,10 @@ bool GDALGeoPackageDataset::AllocCachedTiles() const int nCacheCount = 4; /* (m_nShiftXPixelsMod != 0 || m_nShiftYPixelsMod != 0) ? 4 : - (GetUpdate() && m_eDT == GDT_Byte) ? 2 : 1; + (GetUpdate() && m_eDT == GDT_UInt8) ? 2 : 1; */ m_pabyCachedTiles = static_cast(VSI_MALLOC3_VERBOSE( - cpl::fits_on(nCacheCount * (m_eDT == GDT_Byte ? 4 : 1) * + cpl::fits_on(nCacheCount * (m_eDT == GDT_UInt8 ? 4 : 1) * m_nDTSize), nTileWidth, nTileHeight)); if (m_pabyCachedTiles == nullptr) @@ -3270,7 +3270,7 @@ CPLErr GDALGeoPackageDataset::FinalizeRasterRegistration() osInsertGpkgContentsFormatting += ",%d)"; char *pszSQL = sqlite3_mprintf( osInsertGpkgContentsFormatting.c_str(), m_osRasterTable.c_str(), - (m_eDT == GDT_Byte) ? "tiles" : "2d-gridded-coverage", + (m_eDT == GDT_UInt8) ? "tiles" : "2d-gridded-coverage", m_osIdentifier.c_str(), m_osDescription.c_str(), dfGDALMinX, dfGDALMinY, dfGDALMaxX, dfGDALMaxY, pszCurrentDate ? pszCurrentDate @@ -4785,7 +4785,7 @@ void GDALGeoPackageDataset::FlushMetadata() } } if (GetRasterCount() > 0 && - GetRasterBand(1)->GetRasterDataType() == GDT_Byte) + GetRasterBand(1)->GetRasterDataType() == GDT_UInt8) { int bHasNoData = FALSE; const double dfNoDataValue = @@ -4950,7 +4950,7 @@ int GDALGeoPackageDataset::Create(const char *pszFilename, int nXSize, if (nBandsIn != 0) { - if (eDT == GDT_Byte) + if (eDT == GDT_UInt8) { if (nBandsIn != 1 && nBandsIn != 2 && nBandsIn != 3 && nBandsIn != 4) @@ -5139,7 +5139,7 @@ int GDALGeoPackageDataset::Create(const char *pszFilename, int nXSize, "description TEXT"; if (CPLTestBool(CSLFetchNameValueDef(papszOptions, "CRS_WKT_EXTENSION", "NO")) || - (nBandsIn != 0 && eDT != GDT_Byte)) + (nBandsIn != 0 && eDT != GDT_UInt8)) { m_bHasDefinition12_063 = true; osSQL += ", definition_12_063 TEXT NOT NULL"; @@ -5534,7 +5534,7 @@ int GDALGeoPackageDataset::Create(const char *pszFilename, int nXSize, m_eTF = GPKG_TF_PNG; } - if (eDT != GDT_Byte) + if (eDT != GDT_UInt8) { if (!CreateTileGriddedTable(papszOptions)) return FALSE; @@ -5644,7 +5644,7 @@ int GDALGeoPackageDataset::Create(const char *pszFilename, int nXSize, } } - if (bFileExists && nBandsIn > 0 && eDT == GDT_Byte) + if (bFileExists && nBandsIn > 0 && eDT == GDT_UInt8) { // If there was an ogr_empty_table table, we can remove it RemoveOGREmptyTable(); @@ -5961,7 +5961,7 @@ GDALDataset *GDALGeoPackageDataset::CreateCopy(const char *pszFilename, pProgressData)); if (poDS != nullptr && - poSrcDS->GetRasterBand(1)->GetRasterDataType() == GDT_Byte && + poSrcDS->GetRasterBand(1)->GetRasterDataType() == GDT_UInt8 && nBands <= 3) { poDS->m_nBandCountFromMetadata = nBands; @@ -6189,7 +6189,7 @@ GDALDataset *GDALGeoPackageDataset::CreateCopy(const char *pszFilename, int nTargetBands = nBands; /* For grey level or RGB, if there's reprojection involved, add an alpha */ /* channel */ - if (eDT == GDT_Byte && + if (eDT == GDT_UInt8 && ((nBands == 1 && poSrcDS->GetRasterBand(1)->GetColorTable() == nullptr) || nBands == 3)) @@ -6246,7 +6246,7 @@ GDALDataset *GDALGeoPackageDataset::CreateCopy(const char *pszFilename, int bHasNoData = FALSE; double dfNoDataValue = poSrcDS->GetRasterBand(1)->GetNoDataValue(&bHasNoData); - if (eDT != GDT_Byte && bHasNoData) + if (eDT != GDT_UInt8 && bHasNoData) { poDS->GetRasterBand(1)->SetNoDataValue(dfNoDataValue); } diff --git a/ogr/ogrsf_frmts/ngw/ogrngwdriver.cpp b/ogr/ogrsf_frmts/ngw/ogrngwdriver.cpp index d5fa1de50eaa..729919d59ff6 100644 --- a/ogr/ogrsf_frmts/ngw/ogrngwdriver.cpp +++ b/ogr/ogrsf_frmts/ngw/ogrngwdriver.cpp @@ -398,7 +398,7 @@ static GDALDataset *OGRNGWDriverCreateCopy(const char *pszFilename, bool bCreateStyle = true; if (osQMLPath.empty()) { - if ((nBands == 3 || nBands == 4) && nDataType == GDT_Byte) + if ((nBands == 3 || nBands == 4) && nDataType == GDT_UInt8) { oResourceStyle.Add("cls", "raster_style"); } diff --git a/ogr/ogrsf_frmts/openfilegdb/gdalopenfilegdbrasterband.cpp b/ogr/ogrsf_frmts/openfilegdb/gdalopenfilegdbrasterband.cpp index 4e5820a4aecb..5e9d0a5dd8ff 100644 --- a/ogr/ogrsf_frmts/openfilegdb/gdalopenfilegdbrasterband.cpp +++ b/ogr/ogrsf_frmts/openfilegdb/gdalopenfilegdbrasterband.cpp @@ -284,7 +284,7 @@ bool OGROpenFileGDBDataSource::OpenRaster(const GDALOpenInfo *poOpenInfo, const double dfBlockOriginY = psField->Real; // Figure out data type - GDALDataType eDT = GDT_Byte; + GDALDataType eDT = GDT_UInt8; const int nBitWidth = (nBandTypes >> 19) & ((1 << 7) - 1); const int nBitType = (nBandTypes >> 16) & ((1 << 2) - 1); constexpr int IS_UNSIGNED = 0; @@ -292,11 +292,11 @@ bool OGROpenFileGDBDataSource::OpenRaster(const GDALOpenInfo *poOpenInfo, constexpr int IS_FLOATING_POINT = 2; if ((nBitWidth >= 1 && nBitWidth < 8) && nBitType == IS_UNSIGNED) { - eDT = GDT_Byte; + eDT = GDT_UInt8; } else if (nBitWidth == 8 && nBitType <= IS_SIGNED) { - eDT = nBitType == IS_SIGNED ? GDT_Int8 : GDT_Byte; + eDT = nBitType == IS_SIGNED ? GDT_Int8 : GDT_UInt8; } else if (nBitWidth == 16 && nBitType <= IS_SIGNED) { @@ -683,13 +683,13 @@ bool OGROpenFileGDBDataSource::OpenRaster(const GDALOpenInfo *poOpenInfo, else { poMaskBand = std::make_unique( - this, 1, GDT_Byte, 8, nBlockWidth, nBlockHeight, 0, true); + this, 1, GDT_UInt8, 8, nBlockWidth, nBlockHeight, 0, true); } } else if (EQUAL(pszNoDataOrMask, "MASK")) { poMaskBand = std::make_unique( - this, 1, GDT_Byte, 8, nBlockWidth, nBlockHeight, 0, true); + this, 1, GDT_UInt8, 8, nBlockWidth, nBlockHeight, 0, true); } else if (!EQUAL(pszNoDataOrMask, "NONE")) { @@ -717,7 +717,7 @@ bool OGROpenFileGDBDataSource::OpenRaster(const GDALOpenInfo *poOpenInfo, dfMin = std::numeric_limits::min(); dfMax = std::numeric_limits::max(); break; - case GDT_Byte: + case GDT_UInt8: dfMin = std::numeric_limits::min(); dfMax = std::numeric_limits::max(); break; @@ -810,7 +810,7 @@ bool OGROpenFileGDBDataSource::OpenRaster(const GDALOpenInfo *poOpenInfo, // Make the mask band owned by the first raster band poOvrBand->m_poMaskBandOwned = std::make_unique( - this, 1, GDT_Byte, 8, nBlockWidth, nBlockHeight, + this, 1, GDT_UInt8, 8, nBlockWidth, nBlockHeight, iOvr + 1, true); poMaskBandRef = poOvrBand->m_poMaskBandOwned.get(); poMaskBandRef->m_poMainBand = poOvrBand; @@ -1734,7 +1734,7 @@ CPLErr GDALOpenFileGDBRasterBand::IReadBlock(int nBlockXOff, int nBlockYOff, } else if (m_bHasNoData) { - if (eImageDT == GDT_Byte) + if (eImageDT == GDT_UInt8) { SetNoDataFromMask(pImage, pabyMask, nPixels, m_dfNoData); } @@ -1793,7 +1793,7 @@ CPLErr GDALOpenFileGDBRasterBand::IReadBlock(int nBlockXOff, int nBlockYOff, #if 0 printf("Data:\n"); // ok - if (eDataType == GDT_Byte) + if (eDataType == GDT_UInt8) { for (int y = 0; y < nBlockYSize; ++y) { diff --git a/ogr/ogrsf_frmts/sqlite/rasterlite2.cpp b/ogr/ogrsf_frmts/sqlite/rasterlite2.cpp index d2e01f17f04e..9888ae7de5b2 100644 --- a/ogr/ogrsf_frmts/sqlite/rasterlite2.cpp +++ b/ogr/ogrsf_frmts/sqlite/rasterlite2.cpp @@ -358,19 +358,19 @@ bool OGRSQLiteDataSource::OpenRasterSubDataset( CPLFetchBool(papszOpenOptions, "1BIT_AS_8BIT", true); } nBits = 1; - eDT = GDT_Byte; + eDT = GDT_UInt8; break; } case RL2_SAMPLE_2_BIT: { nBits = 2; - eDT = GDT_Byte; + eDT = GDT_UInt8; break; } case RL2_SAMPLE_4_BIT: { nBits = 4; - eDT = GDT_Byte; + eDT = GDT_UInt8; break; } case RL2_SAMPLE_INT8: @@ -382,7 +382,7 @@ bool OGRSQLiteDataSource::OpenRasterSubDataset( case RL2_SAMPLE_UINT8: { nBits = 8; - eDT = GDT_Byte; + eDT = GDT_UInt8; break; } case RL2_SAMPLE_INT16: @@ -1519,7 +1519,7 @@ GDALDataset *OGRSQLiteDriverCreateCopy(const char *pszName, { nPixelType = RL2_PIXEL_PALETTE; } - else if (nBandCount == 3 && (eDT == GDT_Byte || eDT == GDT_UInt16) && + else if (nBandCount == 3 && (eDT == GDT_UInt8 || eDT == GDT_UInt16) && poSrcDS->GetRasterBand(1)->GetColorInterpretation() == GCI_RedBand && poSrcDS->GetRasterBand(2)->GetColorInterpretation() == @@ -1529,11 +1529,11 @@ GDALDataset *OGRSQLiteDriverCreateCopy(const char *pszName, { nPixelType = RL2_PIXEL_RGB; } - else if (nBandCount > 1 && (eDT == GDT_Byte || eDT == GDT_UInt16)) + else if (nBandCount > 1 && (eDT == GDT_UInt8 || eDT == GDT_UInt16)) { nPixelType = RL2_PIXEL_MULTIBAND; } - else if (nBandCount == 1 && eDT != GDT_Byte) + else if (nBandCount == 1 && eDT != GDT_UInt8) { nPixelType = RL2_PIXEL_DATAGRID; } @@ -1561,7 +1561,7 @@ GDALDataset *OGRSQLiteDriverCreateCopy(const char *pszName, } } - if (nBITS > 0 && nBITS <= 8 && eDT != GDT_Byte) + if (nBITS > 0 && nBITS <= 8 && eDT != GDT_UInt8) { CPLError(CE_Failure, CPLE_NotSupported, "NBITS <= 8 only compatible with Byte data type"); @@ -1589,7 +1589,7 @@ GDALDataset *OGRSQLiteDriverCreateCopy(const char *pszName, if (nPixelType == RL2_PIXEL_MONOCHROME) { - if (eDT != GDT_Byte) + if (eDT != GDT_UInt8) { CPLError(CE_Failure, CPLE_NotSupported, "Incompatible data type for MONOCHROME"); @@ -1614,7 +1614,7 @@ GDALDataset *OGRSQLiteDriverCreateCopy(const char *pszName, nSampleType = RL2_SAMPLE_FLOAT; else if (eDT == GDT_Float64) nSampleType = RL2_SAMPLE_DOUBLE; - else if (eDT != GDT_Byte) + else if (eDT != GDT_UInt8) { CPLError(CE_Failure, CPLE_NotSupported, "Unsupported data type"); return nullptr; diff --git a/swig/include/gdal.i b/swig/include/gdal.i index c6e5f335c358..428884cc9f25 100644 --- a/swig/include/gdal.i +++ b/swig/include/gdal.i @@ -129,17 +129,18 @@ typedef int GDALRIOResampleAlg; %rename (DataType) GDALDataType; typedef enum { GDT_Unknown = 0, - /*! Eight bit unsigned integer */ GDT_Byte = 1, - /*! Eight bit signed integer */ GDT_Int8 = 14, - /*! Sixteen bit unsigned integer */ GDT_UInt16 = 2, - /*! Sixteen bit signed integer */ GDT_Int16 = 3, - /*! Thirty two bit unsigned integer */ GDT_UInt32 = 4, - /*! Thirty two bit signed integer */ GDT_Int32 = 5, - /*! 64 bit unsigned integer */ GDT_UInt64 = 12, - /*! 64 bit signed integer */ GDT_Int64 = 13, - /*! Sixteen bit floating point */ GDT_Float16 = 15, - /*! Thirty two bit floating point */ GDT_Float32 = 6, - /*! Sixty four bit floating point */ GDT_Float64 = 7, + /*! 8-bit unsigned integer */ GDT_Byte = 1, + /*! 8-bit unsigned integer */ GDT_UInt8 = 1, + /*! 8-bit signed integer */ GDT_Int8 = 14, + /*! 16-bit unsigned integer */ GDT_UInt16 = 2, + /*! 16-bit signed integer */ GDT_Int16 = 3, + /*! 32-bit unsigned integer */ GDT_UInt32 = 4, + /*! 32-bit signed integer */ GDT_Int32 = 5, + /*! 64-bit unsigned integer */ GDT_UInt64 = 12, + /*! 64-bit signed integer */ GDT_Int64 = 13, + /*! 16-bit floating point */ GDT_Float16 = 15, + /*! 32-bit floating point */ GDT_Float32 = 6, + /*! 64-bit floating point */ GDT_Float64 = 7, /*! Complex Int16 */ GDT_CInt16 = 8, /*! Complex Int32 */ GDT_CInt32 = 9, /*! Complex Float16 */ GDT_CFloat16 = 16, diff --git a/swig/include/gdalconst.i b/swig/include/gdalconst.i index 3ec483542c66..a9b2c5da3185 100644 --- a/swig/include/gdalconst.i +++ b/swig/include/gdalconst.i @@ -36,6 +36,7 @@ // GDALDataType %constant GDT_Unknown = GDT_Unknown; %constant GDT_Byte = GDT_Byte; +%constant GDT_UInt8 = GDT_UInt8; %constant GDT_Int8 = GDT_Int8; %constant GDT_UInt16 = GDT_UInt16; %constant GDT_Int16 = GDT_Int16;