OpenImageIO icon indicating copy to clipboard operation
OpenImageIO copied to clipboard

[BUG] Radiance HDR files aren't loadable with an ioproxy

Open jessey-git opened this issue 3 years ago • 1 comments
trafficstars

Describe the bug Trying to load a .hdr file with an in-memory ioproxy seems to fail.

To Reproduce Steps to reproduce the behavior:

  Filesystem::IOMemReader memreader((void *)mem, size);
  auto in = ImageInput::open("mem", nullptr, &memreader);
  if (!in) {
    fprintf(stderr, "BAD: %s\n", OIIO::geterror().c_str());
    return nullptr;
  }

Expected behavior The code itself seems to work for .bmp, .png, .tga, .tif, and .jpg so generally things seem ok. Additionally, the .hdr file is valid:

.\iinfo.exe T:\test.hdr                                                                                                                                                                                      
T:\test.hdr : 1024 x 1024, 3 channel, float hdr

Evidence It's like the ioproxy is skipped and a fallback using the filename occurs: BAD: Image "mem" does not exist. Also, it is not the name of an image format that OpenImageIO recognizes.

Platform information:

  • OIIO branch/version: 2.4.3 beta
  • OS: Windows 10
  • C++ compiler: MSVC 2022

jessey-git avatar Sep 06 '22 08:09 jessey-git

Some further information

This doesn't work:

  Filesystem::IOMemReader memreader((void *)mem, size);
  auto in = ImageInput::open("mem", nullptr, &memreader);
  if (!in) {
    // we get sadness... and the following debug message from OIIO
    // OIIO DEBUG: ImageInput::create: "mem" did not open using format "hdr" hdr.
  }

This works:

  Filesystem::IOMemReader memreader((void *)mem, size);
  ImageSpec config;
  ImageSpec tmp;
  auto in = ImageInput::open("hdr", nullptr, nullptr); // explicitly get a HdrInput
  in->set_ioproxy(&memreader); // explicitly set the ioproxy
  bool ok = in->open("", tmp, config);
  // ok is true and reading works correctly

jessey-git avatar Sep 08 '22 21:09 jessey-git

This no longer seems to be the case. So I'll close my own issue here.

jessey-git avatar May 07 '23 05:05 jessey-git