mirror of
https://github.com/mapnik/mapnik.git
synced 2025-12-08 20:13:09 +00:00
tiff io: test paletted (aka colormapped) tiff
This commit is contained in:
parent
36d7e455ed
commit
4e671fd0e9
@ -53,6 +53,66 @@
|
||||
|
||||
TEST_CASE("tiff io") {
|
||||
|
||||
SECTION("scan rgb8 striped") {
|
||||
std::string filename("./tests/data/tiff/scan_512x512_rgb8_striped.tif");
|
||||
mapnik::tiff_reader<boost::iostreams::file_source> tiff_reader(filename);
|
||||
REQUIRE( tiff_reader.width() == 512 );
|
||||
REQUIRE( tiff_reader.height() == 512 );
|
||||
REQUIRE( tiff_reader.planar_config() == PLANARCONFIG_CONTIG );
|
||||
REQUIRE( tiff_reader.rows_per_strip() == 16 );
|
||||
REQUIRE( tiff_reader.bits_per_sample() == 8 );
|
||||
REQUIRE( tiff_reader.is_tiled() == false );
|
||||
REQUIRE( tiff_reader.tile_width() == 0 );
|
||||
REQUIRE( tiff_reader.tile_height() == 0 );
|
||||
REQUIRE( tiff_reader.photometric() == PHOTOMETRIC_PALETTE );
|
||||
REQUIRE( tiff_reader.compression() == COMPRESSION_NONE );
|
||||
std::unique_ptr<mapnik::image_reader> reader(mapnik::get_image_reader(filename,"tiff"));
|
||||
REQUIRE( reader->width() == 512 );
|
||||
REQUIRE( reader->height() == 512 );
|
||||
mapnik::util::file file(filename);
|
||||
mapnik::tiff_reader<boost::iostreams::array_source> tiff_reader2(file.data().get(),file.size());
|
||||
REQUIRE( tiff_reader2.width() == 512 );
|
||||
REQUIRE( tiff_reader2.height() == 512 );
|
||||
std::unique_ptr<mapnik::image_reader> reader2(mapnik::get_image_reader(file.data().get(),file.size()));
|
||||
REQUIRE( reader2->width() == 512 );
|
||||
REQUIRE( reader2->height() == 512 );
|
||||
mapnik::image_data_any data = reader->read(0, 0, reader->width(), reader->height());
|
||||
REQUIRE( data.is<mapnik::image_data_rgba8>() == true );
|
||||
TIFF_ASSERT_SIZE( data,reader );
|
||||
TIFF_ASSERT_NO_ALPHA
|
||||
TIFF_READ_ONE_PIXEL
|
||||
}
|
||||
|
||||
SECTION("scan rgb8 tiled") {
|
||||
std::string filename("./tests/data/tiff/scan_512x512_rgb8_tiled.tif");
|
||||
mapnik::tiff_reader<boost::iostreams::file_source> tiff_reader(filename);
|
||||
REQUIRE( tiff_reader.width() == 512 );
|
||||
REQUIRE( tiff_reader.height() == 512 );
|
||||
REQUIRE( tiff_reader.planar_config() == PLANARCONFIG_CONTIG );
|
||||
REQUIRE( tiff_reader.rows_per_strip() == 0 );
|
||||
REQUIRE( tiff_reader.bits_per_sample() == 8 );
|
||||
REQUIRE( tiff_reader.is_tiled() == true );
|
||||
REQUIRE( tiff_reader.tile_width() == 256 );
|
||||
REQUIRE( tiff_reader.tile_height() == 256 );
|
||||
REQUIRE( tiff_reader.photometric() == PHOTOMETRIC_PALETTE );
|
||||
REQUIRE( tiff_reader.compression() == COMPRESSION_LZW );
|
||||
std::unique_ptr<mapnik::image_reader> reader(mapnik::get_image_reader(filename,"tiff"));
|
||||
REQUIRE( reader->width() == 512 );
|
||||
REQUIRE( reader->height() == 512 );
|
||||
mapnik::util::file file(filename);
|
||||
mapnik::tiff_reader<boost::iostreams::array_source> tiff_reader2(file.data().get(),file.size());
|
||||
REQUIRE( tiff_reader2.width() == 512 );
|
||||
REQUIRE( tiff_reader2.height() == 512 );
|
||||
std::unique_ptr<mapnik::image_reader> reader2(mapnik::get_image_reader(file.data().get(),file.size()));
|
||||
REQUIRE( reader2->width() == 512 );
|
||||
REQUIRE( reader2->height() == 512 );
|
||||
mapnik::image_data_any data = reader->read(0, 0, reader->width(), reader->height());
|
||||
REQUIRE( data.is<mapnik::image_data_rgba8>() == true );
|
||||
TIFF_ASSERT_SIZE( data,reader );
|
||||
TIFF_ASSERT_NO_ALPHA
|
||||
TIFF_READ_ONE_PIXEL
|
||||
}
|
||||
|
||||
SECTION("rgba8 striped") {
|
||||
TIFF_ASSERT("./tests/data/tiff/ndvi_256x256_rgba8_striped.tif")
|
||||
REQUIRE( tiff_reader.rows_per_strip() == 1 );
|
||||
|
||||
BIN
tests/data/tiff/scan_512x512_rgb8_striped.tif
Normal file
BIN
tests/data/tiff/scan_512x512_rgb8_striped.tif
Normal file
Binary file not shown.
BIN
tests/data/tiff/scan_512x512_rgb8_tiled.tif
Normal file
BIN
tests/data/tiff/scan_512x512_rgb8_tiled.tif
Normal file
Binary file not shown.
Loading…
x
Reference in New Issue
Block a user