Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(iba): IBA::transpose() didn't set output image's format to input #4391

Merged
merged 1 commit into from
Aug 31, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions src/include/OpenImageIO/imagebufalgo_util.h
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,12 @@ parallel_image(ROI roi, std::function<void(ROI)> f)
/// If nonzero and dst is uninitialized, then initialize it to float
/// regardless of the pixel types of the input images.
///
/// - "dst_datatype" : string (default: "")
///
/// If not empty and dst is uninitialized, then initialize it to the data
/// type indicated by the string regardless of the pixel types of any
/// input images.
///
/// - "minimize_nchannels" : int (default: 0)
///
/// If nonzero and dst is uninitialized and the multiple input images do
Expand Down
7 changes: 7 additions & 0 deletions src/libOpenImageIO/imagebufalgo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -504,6 +504,13 @@ ImageBufAlgo::IBAprep(ROI& roi, ImageBuf& dst, cspan<const ImageBuf*> srcs,
spec.nchannels = roi.chend;
spec.default_channel_names();
}

// If the user passed a dst_format, use it.
TypeDesc requested_format(options.get_string("dst_format"));
if (requested_format != TypeUnknown) {
spec.set_format(requested_format);
}

// Set the image dimensions based on ROI.
set_roi(spec, roi);
if (full_roi.defined())
Expand Down
3 changes: 2 additions & 1 deletion src/libOpenImageIO/imagebufalgo_orient.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -427,7 +427,8 @@ ImageBufAlgo::transpose(ImageBuf& dst, const ImageBuf& src, ROI roi,
ROI dst_roi(roi.ybegin, roi.yend, roi.xbegin, roi.xend, roi.zbegin,
roi.zend, roi.chbegin, roi.chend);
bool dst_initialized = dst.initialized();
if (!IBAprep(dst_roi, &dst))
ParamValue options[] = { { "dst_format", src.spec().format.c_str() } };
if (!IBAprep(dst_roi, dst, {}, options))
return false;
if (!dst_initialized) {
ROI r = src.roi_full();
Expand Down
Loading