#ifndef _OTB_TRISKELE_I_IMAGE_TPP #define _OTB_TRISKELE_I_IMAGE_TPP template uint32_t IImage::gdalCount = 0; template void IImage::readImage (const Point &cropOrig, const Size &cropSize) { DEF_LOG ("IImage::readImage", "filename: " << filename); if (!gdalCount++) GDALAllRegister (); gdalInputDataset = (GDALDataset *) GDALOpen (filename.c_str (), GA_ReadOnly); if (!gdalInputDataset) { dataType = GDT_Unknown; std::cerr << "GDALError: can't define dataset" << std::endl; return; } size = Size (gdalInputDataset->GetRasterXSize (), gdalInputDataset->GetRasterYSize ()); LOG ("size: " << size); pixels = new PixelT[getPixelsCount ()]; LOG ("bandsCount: " << gdalInputDataset->GetRasterCount ()); GDALRasterBand &poBand = *gdalInputDataset->GetRasterBand (1); CPLErr err = poBand.RasterIO (GF_Read, cropOrig.x, cropOrig.y, cropSize.width, cropSize.height, pixels, cropSize.width, cropSize.height, toGDALType (getType ((PixelT) 0)), 0, 0); if (err != CE_None) std::cerr << "GDALError: can't acces " << filename << std::endl; } template void IImage::close () { if (gdalInputDataset) { GDALClose (gdalInputDataset); gdalInputDataset = nullptr; if (!--gdalCount) GDALDestroyDriverManager (); } } #endif // _OTB_TRISKELE_I_IMAGE_TPP