16-bit floating-point support for TIFF output image (see #2357)

This commit is contained in:
Hombre
2018-05-07 09:57:53 +02:00
parent 5ac11ef1b9
commit 30efa5930d
16 changed files with 83 additions and 42 deletions

View File

@@ -267,6 +267,7 @@ int processLineParams ( int argc, char **argv )
int compression = 92;
int subsampling = 3;
int bits = -1;
bool isFloat = false;
std::string outputType = "";
unsigned errors = 0;
@@ -392,11 +393,14 @@ int processLineParams ( int argc, char **argv )
bits = atoi (currParam.substr (2).c_str());
if (bits != 8 && bits != 16 && bits != 32) {
std::cerr << "Error: specify -b8 for 8-bit/integer or -b16 for 16-bit/integer or -b32 for 32-bit/float output." << std::endl;
std::cerr << "Error: specify -b8 for 8-bit/integer or -b16 for 16-bit/integer or -b16f for 16-bit/float or -b32 for 32-bit/float output." << std::endl;
deleteProcParams (processingParams);
return -3;
}
isFloat = (bits == 16 && currParam.length() == 3 && currParam.at(2) == 'f') || bits == 32;
printf("Float output detected (%d bits)!\n", bits);
break;
case 't':
@@ -550,10 +554,11 @@ int processLineParams ( int argc, char **argv )
std::cout << " Chroma halved horizontally." << std::endl;
std::cout << " 3 = Best quality: 1x1, 1x1, 1x1 (4:4:4)" << std::endl;
std::cout << " No chroma subsampling." << std::endl;
std::cout << " -b<8|16|32> Specify bit depth per channel (default value: 16 for TIFF, 8 for PNG)." << std::endl;
std::cout << " TIFF can be 8-bit/int, 16-bit/int or 32-bit/float" << std::endl;
std::cout << " PNG can be 8-bit/int or 16-bit/int." << std::endl;
std::cout << " JPEG is only 8-bit/int." << std::endl;
std::cout << " -b<8|16|16f|32> Specify bit depth per channel (default value: 16 for TIFF, 8 for PNG and JPEG)." << std::endl;
std::cout << " 8 = 8 bits integer, applies to JPEG, PNG and TIFF" << std::endl;
std::cout << " 16 = 16 bits integer, applies to PNG and TIFF" << std::endl;
std::cout << " 16f = 16 bits float, applies to TIFF" << std::endl;
std::cout << " 32 = 32 bits float, applies to TIFF" << std::endl;
std::cout << " -t[z] Specify output to be TIFF." << std::endl;
std::cout << " Uncompressed by default, or deflate compression with 'z'." << std::endl;
std::cout << " -n Specify output to be compressed PNG." << std::endl;
@@ -781,7 +786,7 @@ int processLineParams ( int argc, char **argv )
if ( outputType == "jpg" ) {
errorCode = resultImage->saveAsJPEG ( outputFile, compression, subsampling );
} else if ( outputType == "tif" ) {
errorCode = resultImage->saveAsTIFF ( outputFile, bits, compression == 0 );
errorCode = resultImage->saveAsTIFF ( outputFile, bits, isFloat, compression == 0 );
} else if ( outputType == "png" ) {
errorCode = resultImage->saveAsPNG ( outputFile, bits );
} else {