Skip to content

Commit

Permalink
fix(jpeg2000): better pixel type promotion logic (#3878)
Browse files Browse the repository at this point in the history
J2K output was defaulting to UINT8 when asked to output an unsupported
type. It should have been UINT16 to try to minimize the amount of
precision loss.

Fixes #3876

Signed-off-by: Larry Gritz <lg@larrygritz.com>
  • Loading branch information
lgritz authored Jun 14, 2023
1 parent 7d9a19b commit fd33ab6
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/jpeg2000.imageio/jpeg2000output.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -156,9 +156,9 @@ Jpeg2000Output::open(const std::string& name, const ImageSpec& spec,

m_filename = name;

// If not uint8 or uint16, default to uint8
// If not uint8 or uint16, default to uint16
if (m_spec.format != TypeDesc::UINT8 && m_spec.format != TypeDesc::UINT16)
m_spec.set_format(TypeDesc::UINT8);
m_spec.set_format(TypeDesc::UINT16);

m_dither = (m_spec.format == TypeDesc::UINT8)
? m_spec.get_int_attribute("oiio:dither", 0)
Expand Down

0 comments on commit fd33ab6

Please sign in to comment.