MCPcopy Create free account
hub / github.com/RenderKit/oidn / saveImageOIIO

Function saveImageOIIO

apps/utils/image_io.cpp:332–367  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

330 }
331
332 void saveImageOIIO(const std::string& filename, const ImageBuffer& image)
333 {
334 auto out = OIIO::ImageOutput::create(filename);
335 if (!out)
336 throw std::runtime_error("cannot save unsupported image file format: '" + filename + "'");
337
338 OIIO::TypeDesc format;
339 switch (image.getDataType())
340 {
341 case DataType::Float32:
342 format = OIIO::TypeDesc::FLOAT;
343 break;
344 case DataType::Float16:
345 format = OIIO::TypeDesc::HALF;
346 break;
347 default:
348 throw std::runtime_error("unsupported image data type");
349 }
350
351 OIIO::ImageSpec spec(image.getW(),
352 image.getH(),
353 image.getC(),
354 format);
355
356 if (!out->open(filename, spec))
357 throw std::runtime_error("cannot create image file: '" + filename + "'");
358 bool success = out->write_image(format, image.getHostData());
359 out->close();
360
361 #if OIIO_VERSION < 10903
362 OIIO::ImageOutput::destroy(out);
363 #endif
364
365 if (!success)
366 throw std::runtime_error("failed to write image data");
367 }
368 #endif
369
370 } // namespace

Callers 1

saveImageFunction · 0.85

Calls 7

destroyFunction · 0.85
getDataTypeMethod · 0.45
getWMethod · 0.45
getHMethod · 0.45
getCMethod · 0.45
openMethod · 0.45
closeMethod · 0.45

Tested by

no test coverage detected