Corrupted TIFF with GA_Update and image smaller than 64x64
|Reported by:||cleo||Owned by:||warmerdam|
This happens in 1.8.0 as well.
Take any image 24 or 32 bit (haven't tested other bit depths yet), resize to 63x63 or less in GIMP for example and save it out. This will create a strips, interleaved pixel image. Save as TIFF using any compression or no compression. Doesn't matter. Open file with GDALOpen(filename, GA_Update); Do RasterIO on either the file or band. Flush the cache and the image is corrupted.
I'm opening, reading one pixel, writing that pixel back out and flushing the cache, then closing the file. That's it. Works fine with images 64x64 or larger. Reads also work fine.
I'm on Win32, MSVC 9 (2008). Internal libs. Default settings. With 1.9, never crashes but corrupts file. With 1.8 and external libs, it crashes at all image sizes on flush in external lib (in deflate reset for example) used for respective compression though it's possible that's something to do on our end, yet reads work fine. With no compression, doesn't crash, but corrupts the file.
//Register all formats. GDALAllRegister(); // Create a copy that we can write to. // uses boosts' copy_file() method. copyFile(sourceFilename, destFilename); // Open GDALDataset *pDataSet = (GDALDataset *) GDALOpen( destFilename.c_str(), GA_Update); CPPUNIT_ASSERT( pDataSet != NULL); // Read one pixel unsigned int pixel; CPLErr err = pDataSet->RasterIO( GF_Read, 0, 0, 1, 1, &pixel, 1, 1, GDT_Byte, pDataSet->GetRasterCount(), NULL, pDataSet->GetRasterCount(), pDataSet->GetRasterCount(), 1); CPPUNIT_ASSERT (err == CE_None); // Write one pixel err = pDataSet->RasterIO( GF_Write, 0, 0, 1, 1, &pixel, 1, 1, GDT_Byte, pDataSet->GetRasterCount(), NULL, pDataSet->GetRasterCount(), pDataSet->GetRasterCount(), 1); CPPUNIT_ASSERT (err == CE_None); // Flush pDataSet->FlushCache(); // Close GDALClose(pDataSet);