Skip to content

Commit 393899e

Browse files
authored
fix(tiff): The "tiff:half" hint was only applying to first MIP level (AcademySoftwareFoundation#5240)
IBA::make_texture() only passes the full metadata to the first level of a MIPmap, and that might include output behavior hints, too! Make this hint "sticky" in the TIFF writer, so if any subimage's first level's spec enables half output, all the MIP levels of that subimage will allow it. Fixes AcademySoftwareFoundation#5239 Signed-off-by: Larry Gritz <lg@larrygritz.com>
1 parent 77906d3 commit 393899e

1 file changed

Lines changed: 10 additions & 2 deletions

File tree

src/tiff.imageio/tiffoutput.cpp

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,7 @@ class TIFFOutput final : public ImageOutput {
109109
int m_outputchans; // Number of channels for the output
110110
bool m_convert_rgb_to_cmyk;
111111
bool m_bigtiff; // force bigtiff
112+
bool m_allow_half = false;
112113

113114
// Initialize private members to pre-opened state
114115
void init(void)
@@ -123,6 +124,7 @@ class TIFFOutput final : public ImageOutput {
123124
m_outputchans = 0;
124125
m_convert_rgb_to_cmyk = false;
125126
m_bigtiff = false;
127+
m_allow_half = false;
126128
ioproxy_clear();
127129
}
128130

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

515+
if (m_spec.format == TypeDesc::HALF) {
516+
// Look for hints about whether half output is allowed
517+
m_allow_half
518+
= m_spec.get_int_attribute("tiff:half",
519+
OIIO::get_int_attribute("tiff:half"));
520+
}
521+
513522
// Open the file
514523
#if OIIO_TIFFLIB_VERSION >= 40500
515524
auto openopts = TIFFOpenOptionsAlloc();
@@ -625,8 +634,7 @@ TIFFOutput::open(const std::string& name, const ImageSpec& userspec,
625634
// unless the "tiff:half" attribute is nonzero -- use the global
626635
// OIIO attribute, but override with a specific attribute for this
627636
// file.
628-
if (m_spec.get_int_attribute("tiff:half",
629-
OIIO::get_int_attribute("tiff:half"))) {
637+
if (m_allow_half) {
630638
m_bitspersample = 16;
631639
} else {
632640
// Silently change requests for unsupported 'half' to 'float'

0 commit comments

Comments
 (0)