Skip to content

Commit 82133cf

Browse files
committed
Fix RGB EXR images
1 parent 9c4d843 commit 82133cf

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

src/io/oiio.rs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,7 @@ impl ImageOutput {
8989
/// Note: `image` dimensions and type will take precendence over the ImageSpec
9090
pub fn write<T: Type, C: Color>(mut self, image: &Image<T, C>) -> Result<(), Error> {
9191
let base_type = T::BASE;
92+
let name = C::NAME.as_bytes().as_ptr() as *const _;
9293
let path: &std::path::Path = self.path.as_ref();
9394
let path_str = std::ffi::CString::new(path.to_string_lossy().as_bytes().to_vec()).unwrap();
9495
let filename = path_str.as_ptr();
@@ -97,11 +98,16 @@ impl ImageOutput {
9798
let out = self.image_output;
9899
let spec = &mut self.spec;
99100
unsafe {
100-
cpp!([out as "ImageOutput*", filename as "const char *", base_type as "TypeDesc::BASETYPE", spec as "ImageSpec *", width as "size_t", height as "size_t", channels as "size_t", pixels as "const void*"] {
101+
cpp!([out as "ImageOutput*", name as "const char *", filename as "const char *", base_type as "TypeDesc::BASETYPE", spec as "ImageSpec *", width as "size_t", height as "size_t", channels as "size_t", pixels as "const void*"] {
101102
ImageSpec outspec (*spec);
102103
outspec.width = width;
103104
outspec.height = height;
104105
outspec.nchannels = channels;
106+
auto x = std::vector<std::string>(channels);
107+
for (int i = 0; i < channels; i++){
108+
x[i] = std::string(1, name[i]);
109+
}
110+
outspec.channelnames = x;
105111
outspec.set_format(TypeDesc(base_type));
106112
out->open (filename, outspec);
107113
out->write_image (base_type, pixels);

0 commit comments

Comments
 (0)