Last active
December 5, 2017 13:20
-
-
Save talaj/546fa2484bf2cbd7c78c5a12497f86e6 to your computer and use it in GitHub Desktop.
libtiff fork test
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <tiffio.h> | |
#include <unistd.h> | |
#include <iostream> | |
#include <memory> | |
int main() | |
{ | |
const char * dem = "/home/tlj/sandbox/world_robin_611m_ocean_hss20.tif"; | |
TIFF *tiff = TIFFOpen(dem, "rcm"); | |
unsigned width, height; | |
TIFFGetField(tiff, TIFFTAG_IMAGEWIDTH, &width); | |
TIFFGetField(tiff, TIFFTAG_IMAGELENGTH, &height); | |
std::clog << "width: " << width << std::endl; | |
std::clog << "height: " << height << std::endl; | |
tsize_t tile_size = TIFFTileSize(tiff); | |
std::clog << "tile size: " << tile_size << std::endl; | |
std::unique_ptr<char[]> tile_buffer(new char[tile_size]); | |
fork(); | |
unsigned div = 10000; | |
for (unsigned i = 0; i < div; i += 100) | |
{ | |
for (unsigned j = 0; j < div; j += 100) | |
{ | |
unsigned x = (width / div) * j; | |
unsigned y = (height / div) * i; | |
ttile_t tile = TIFFComputeTile(tiff, x, y, 0, 0); | |
if (TIFFReadEncodedTile(tiff,tile , tile_buffer.get(), tile_size) == -1) | |
{ | |
std::clog << "TIFFReadEncodedTile error!" << std::endl; | |
} | |
} | |
} | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment