Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions src/tiff.imageio/tiffoutput.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ class TIFFOutput final : public ImageOutput {
int m_outputchans; // Number of channels for the output
bool m_convert_rgb_to_cmyk;
bool m_bigtiff; // force bigtiff
bool m_allow_half = false;

// Initialize private members to pre-opened state
void init(void)
Expand All @@ -123,6 +124,7 @@ class TIFFOutput final : public ImageOutput {
m_outputchans = 0;
m_convert_rgb_to_cmyk = false;
m_bigtiff = false;
m_allow_half = false;
ioproxy_clear();
}

Expand Down Expand Up @@ -510,6 +512,13 @@ TIFFOutput::open(const std::string& name, const ImageSpec& userspec,
const char* openmode = m_bigtiff ? (mode == AppendSubimage ? "a8" : "w8")
: (mode == AppendSubimage ? "a" : "w");

if (m_spec.format == TypeDesc::HALF) {
// Look for hints about whether half output is allowed
m_allow_half
= m_spec.get_int_attribute("tiff:half",
OIIO::get_int_attribute("tiff:half"));
}

// Open the file
#if OIIO_TIFFLIB_VERSION >= 40500
auto openopts = TIFFOpenOptionsAlloc();
Expand Down Expand Up @@ -625,8 +634,7 @@ TIFFOutput::open(const std::string& name, const ImageSpec& userspec,
// unless the "tiff:half" attribute is nonzero -- use the global
// OIIO attribute, but override with a specific attribute for this
// file.
if (m_spec.get_int_attribute("tiff:half",
OIIO::get_int_attribute("tiff:half"))) {
if (m_allow_half) {
m_bitspersample = 16;
} else {
// Silently change requests for unsupported 'half' to 'float'
Expand Down
Loading