CPLErr GDALRescaledAlphaBand::IReadBlock( int nXBlockOff, int nYBlockOff, void * pImage ) { int nXSizeRequest = nBlockXSize; if (nXBlockOff * nBlockXSize + nBlockXSize > nRasterXSize) nXSizeRequest = nRasterXSize - nXBlockOff * nBlockXSize; int nYSizeRequest = nBlockYSize; if (nYBlockOff * nBlockYSize + nBlockYSize > nRasterYSize) nYSizeRequest = nRasterYSize - nYBlockOff * nBlockYSize; GDALRasterIOExtraArg sExtraArg; INIT_RASTERIO_EXTRA_ARG(sExtraArg); return IRasterIO(GF_Read, nXBlockOff * nBlockXSize, nYBlockOff * nBlockYSize, nXSizeRequest, nYSizeRequest, pImage, nXSizeRequest, nYSizeRequest, GDT_Byte, 1, nBlockXSize, &sExtraArg); }
CPLErr VRTSourcedRasterBand::IReadBlock( int nBlockXOff, int nBlockYOff, void * pImage ) { int nPixelSize = GDALGetDataTypeSize(eDataType)/8; int nReadXSize, nReadYSize; if( (nBlockXOff+1) * nBlockXSize > GetXSize() ) nReadXSize = GetXSize() - nBlockXOff * nBlockXSize; else nReadXSize = nBlockXSize; if( (nBlockYOff+1) * nBlockYSize > GetYSize() ) nReadYSize = GetYSize() - nBlockYOff * nBlockYSize; else nReadYSize = nBlockYSize; return IRasterIO( GF_Read, nBlockXOff * nBlockXSize, nBlockYOff * nBlockYSize, nReadXSize, nReadYSize, pImage, nReadXSize, nReadYSize, eDataType, nPixelSize, nPixelSize * nBlockXSize ); }
CPLErr JP2LuraRasterBand::IReadBlock(int nBlockXOff, int nBlockYOff, void * pImage) { JP2LuraDataset *poGDS = reinterpret_cast<JP2LuraDataset *>(poDS); #ifdef DEBUG_VERBOSE CPLDebug("JP2Lura", "IReadBlock(nBand=%d,nLevel=%d %d,%d)", nBand, poGDS->iLevel, nBlockXOff, nBlockYOff); #endif int nXOff = nBlockXOff * nBlockXSize; int nYOff = nBlockYOff * nBlockYSize; int nXSize = nBlockXSize; int nYSize = nBlockYSize; if( nXOff + nXSize > nRasterXSize ) nXSize = nRasterXSize - nXOff; if( nYOff + nYSize > nRasterYSize ) nYSize = nRasterYSize - nYOff; GDALRasterIOExtraArg sExtraArgs; INIT_RASTERIO_EXTRA_ARG(sExtraArgs); const int nDTSizeBytes = GDALGetDataTypeSizeBytes(eDataType); CPLErr eErr = IRasterIO(GF_Read, nXOff, nYOff, nXSize, nYSize, pImage, nXSize, nYSize, eDataType, nDTSizeBytes, nDTSizeBytes * nXSize, &sExtraArgs); // Unpack previously packed buffer if needed if( eErr == CE_None && nXSize < nBlockXSize ) { GByte* pabyData = reinterpret_cast<GByte*>(pImage); for( int j = nYSize - 1; j >= 0; --j ) { memmove( pabyData + j * nBlockXSize * nDTSizeBytes, pabyData + j * nXSize * nDTSizeBytes, nXSize * nDTSizeBytes ); } } // Caching other bands while we have the cached buffer valid for( int iBand = 1;eErr == CE_None && iBand <= poGDS->nBands; iBand++ ) { if( iBand == nBand ) continue; JP2LuraRasterBand* poOtherBand = reinterpret_cast<JP2LuraRasterBand*>(poGDS->GetRasterBand(iBand)); GDALRasterBlock* poBlock = poOtherBand-> TryGetLockedBlockRef(nBlockXOff,nBlockYOff); if (poBlock != nullptr) { poBlock->DropLock(); continue; } poBlock = poOtherBand-> GetLockedBlockRef(nBlockXOff,nBlockYOff, TRUE); if (poBlock == nullptr) { continue; } GByte* pabyData = reinterpret_cast<GByte*>(poBlock->GetDataRef()); eErr = poOtherBand->IRasterIO(GF_Read, nXOff, nYOff, nXSize, nYSize, pabyData, nXSize, nYSize, eDataType, nDTSizeBytes, nDTSizeBytes * nXSize, &sExtraArgs); // Unpack previously packed buffer if needed if( eErr == CE_None && nXSize < nBlockXSize ) { for( int j = nYSize - 1; j >= 0; --j ) { memmove( pabyData + j * nBlockXSize * nDTSizeBytes, pabyData + j * nXSize * nDTSizeBytes, nXSize * nDTSizeBytes ); } } poBlock->DropLock(); } return eErr; }