diff --git a/source/FAST/Data/Access/ImagePyramidAccess.cpp b/source/FAST/Data/Access/ImagePyramidAccess.cpp index 817b19cf5..6f1699f38 100644 --- a/source/FAST/Data/Access/ImagePyramidAccess.cpp +++ b/source/FAST/Data/Access/ImagePyramidAccess.cpp @@ -526,7 +526,7 @@ int ImagePyramidAccess::readTileFromTIFF(void *data, int x, int y, int level) { const auto tileHeight = m_image->getLevelTileHeight(level); const auto channels = m_image->getNrOfChannels(); TIFFSetDirectory(m_tiffHandle, level); - uint32_t tile_id = TIFFComputeTile(m_tiffHandle, x, y, 0, 0); + const uint32_t tile_id = TIFFComputeTile(m_tiffHandle, x, y, 0, 0); if(TIFFGetStrileByteCount(m_tiffHandle, tile_id) == 1) { // Blank patch if(channels == 1) { std::memset(data, 0, tileWidth*tileHeight*channels); @@ -558,7 +558,7 @@ int ImagePyramidAccess::readTileFromTIFF(void *data, int x, int y, int level) { return bytesRead; } else { int bytesRead = 0; - if(m_compressionFormat == ImageCompression::JPEG) { + if(m_compressionFormat == ImageCompression::JPEG && m_image->isOMETIFF()) { // Use libjpeg for decompression, as ome-tiff files doesn't seem to like tiff's internal jpeg auto buffer = make_uninitialized_unique(tileWidth*tileHeight*channels); bytesRead = TIFFReadRawTile(m_tiffHandle, tile_id, buffer.get(), tileWidth*tileHeight*channels); @@ -572,14 +572,12 @@ int ImagePyramidAccess::readTileFromTIFF(void *data, int x, int y, int level) { jpeg_create_decompress(&cinfo); jpeg_mem_src(&cinfo, (uchar*)buffer.get(), bytesRead); int ret = jpeg_read_header(&cinfo, false); - if(ret != 1) { - throw Exception("Jpeg error.."); + if(ret != JPEG_HEADER_OK) { + throw Exception("Unable to read JPEG header"); } - //cinfo.jpeg_color_space = JCS_YCbCr; - //cinfo.jpeg_color_space = JCS_RGB; jpeg_start_decompress(&cinfo); - unsigned char* line = (uchar*)data; - while (cinfo.output_scanline < cinfo.output_height) { + uchar* line = (uchar*)data; + while(cinfo.output_scanline < cinfo.output_height) { jpeg_read_scanlines (&cinfo, &line, 1); line += channels*cinfo.output_width; } diff --git a/source/FAST/Data/ImagePyramid.cpp b/source/FAST/Data/ImagePyramid.cpp index 2c810909e..0dbfcf345 100644 --- a/source/FAST/Data/ImagePyramid.cpp +++ b/source/FAST/Data/ImagePyramid.cpp @@ -59,7 +59,7 @@ ImagePyramid::ImagePyramid(int width, int height, int channels, int patchWidth, sprintf(str.get(), fmt, ap); Reporter::warning() << "TIFF: " << module << ": " << str.get() << Reporter::end(); }); - m_tiffHandle = TIFFOpen(m_tiffPath.c_str(), "w8"); + m_tiffHandle = TIFFOpen(m_tiffPath.c_str(), "w8"); // 8 == Bigtiff (64 bit) auto tiff = m_tiffHandle; m_counter += 1;