diff --git a/src/null.imageio/nullimageio.cpp b/src/null.imageio/nullimageio.cpp index 0454a0483d..89afc9c0c6 100644 --- a/src/null.imageio/nullimageio.cpp +++ b/src/null.imageio/nullimageio.cpp @@ -24,7 +24,10 @@ class NullOutput final : public ImageOutput { NullOutput() {} ~NullOutput() override {} const char* format_name(void) const override { return "null"; } - int supports(string_view /*feature*/) const override { return true; } + int supports(string_view feature) const override + { + return feature != "rectangles"; + } bool open(const std::string& /*name*/, const ImageSpec& spec, OpenMode /*mode*/) override { @@ -316,10 +319,10 @@ NullInput::open(const std::string& name, ImageSpec& newspec, } } + m_value.resize(m_topspec.pixel_bytes()); // default fills with 0's if (fvalue.size()) { // Convert float to the native type fvalue.resize(m_topspec.nchannels, 0.0f); - m_value.resize(m_topspec.pixel_bytes()); convert_pixel_values(TypeFloat, fvalue.data(), m_topspec.format, m_value.data(), m_topspec.nchannels); } @@ -365,13 +368,10 @@ bool NullInput::read_native_scanline(int /*subimage*/, int /*miplevel*/, int /*y*/, int /*z*/, void* data) { - if (m_value.size()) { - size_t s = m_spec.pixel_bytes(); - for (int x = 0; x < m_spec.width; ++x) - memcpy((char*)data + s * x, m_value.data(), s); - } else { - memset(data, 0, m_spec.scanline_bytes()); - } + size_t s = m_spec.pixel_bytes(); + OIIO_DASSERT(m_value.size() == s); + for (int x = 0; x < m_spec.width; ++x) + memcpy((char*)data + s * x, m_value.data(), s); return true; } @@ -381,13 +381,10 @@ bool NullInput::read_native_tile(int /*subimage*/, int /*miplevel*/, int /*x*/, int /*y*/, int /*z*/, void* data) { - if (m_value.size()) { - size_t s = m_spec.pixel_bytes(); - for (size_t x = 0, e = m_spec.tile_pixels(); x < e; ++x) - memcpy((char*)data + s * x, m_value.data(), s); - } else { - memset(data, 0, m_spec.tile_bytes()); - } + size_t s = m_spec.pixel_bytes(); + OIIO_DASSERT(m_value.size() == s); + for (size_t x = 0, e = m_spec.tile_pixels(); x < e; ++x) + memcpy((char*)data + s * x, m_value.data(), s); return true; } diff --git a/testsuite/null/ref/out.txt b/testsuite/null/ref/out.txt index ae32451d2b..a9ebb22c8b 100644 --- a/testsuite/null/ref/out.txt +++ b/testsuite/null/ref/out.txt @@ -11,3 +11,39 @@ foo.null?RES=640x480&CHANNELS=3&TYPE=uint8&PIXEL=0.25,0.5,1 : 640 x 480, 3 cha Constant: Yes Constant Color: 64.00 128.00 255.00 (of 255) Monochrome: No +Reading foo.null?RES=128x128&CHANNELS=3&TILE=64x64&TEX=1&TYPE=uint16&PIXEL=0.25,0.5,1 +foo.null?RES=128x128&CHANNELS=3&TILE=64x64&TEX=1&TYPE=uint16&PIXEL=0.25,0.5,1 : 128 x 128, 3 channel, uint16 null + MIP-map levels: 128x128 64x64 32x32 16x16 8x8 4x4 2x2 1x1 + channel list: R, G, B + tile size: 64 x 64 + textureformat: "Plain Texture" + wrapmodes: "black,black" + Stats Min: 16384 32768 65535 (of 65535) + Stats Max: 16384 32768 65535 (of 65535) + Stats Avg: 16384.00 32768.00 65535.00 (of 65535) + Stats StdDev: 0.00 0.00 0.00 (of 65535) + Stats NanCount: 0 0 0 + Stats InfCount: 0 0 0 + Stats FiniteCount: 16384 16384 16384 + Constant: Yes + Constant Color: 16384.00 32768.00 65535.00 (of 65535) + Monochrome: No +Reading foo.null?RES=128x128&CHANNELS=3&TYPE=uint8&a=1&b=2.5&c=foo&string e=bar +foo.null?RES=128x128&CHANNELS=3&TYPE=uint8&a=1&b=2.5&c=foo&string e=bar : 128 x 128, 3 channel, uint8 null + channel list: R, G, B + a: 1 + b: 2.5 + c: "foo" + e: "bar" + Stats Min: 0 0 0 (of 255) + Stats Max: 0 0 0 (of 255) + Stats Avg: 0.00 0.00 0.00 (of 255) + Stats StdDev: 0.00 0.00 0.00 (of 255) + Stats NanCount: 0 0 0 + Stats InfCount: 0 0 0 + Stats FiniteCount: 16384 16384 16384 + Constant: Yes + Constant Color: 0.00 0.00 0.00 (of 255) + Monochrome: Yes +Writing out.null +Writing outtile.null diff --git a/testsuite/null/run.py b/testsuite/null/run.py index 24f135d099..d7ad5215f0 100755 --- a/testsuite/null/run.py +++ b/testsuite/null/run.py @@ -5,4 +5,11 @@ # https://github.com/AcademySoftwareFoundation/OpenImageIO -command += oiiotool ('-v -info -stats "foo.null?RES=640x480&CHANNELS=3&TYPE=uint8&PIXEL=0.25,0.5,1"') +command += oiiotool ('-v -info -stats ' + + '"foo.null?RES=640x480&CHANNELS=3&TYPE=uint8&PIXEL=0.25,0.5,1" ' + + '"foo.null?RES=128x128&CHANNELS=3&TILE=64x64&TEX=1&TYPE=uint16&PIXEL=0.25,0.5,1" ' + ) +command += oiiotool ('-v -info -stats ' + + '"foo.null?RES=128x128&CHANNELS=3&TYPE=uint8&a=1&b=2.5&c=foo&string e=bar" ' + + '-o out.null -o:tile=64 outtile.null' + )