Merge branch 'blender-v4.0-release'
This commit is contained in:
@@ -301,13 +301,28 @@ bool imb_oiio_write(const WriteContext &ctx, const char *filepath, const ImageSp
|
||||
|
||||
/* Grayscale images need to be based on luminance weights rather than only
|
||||
* using a single channel from the source. */
|
||||
if (file_spec.nchannels == 1) {
|
||||
if (ctx.ibuf->channels > 1 && file_spec.nchannels == 1) {
|
||||
float weights[4]{};
|
||||
IMB_colormanagement_get_luminance_coefficients(weights);
|
||||
ImageBufAlgo::channel_sum(final_buf, orig_buf, {weights, orig_buf.nchannels()});
|
||||
}
|
||||
else {
|
||||
final_buf = std::move(orig_buf);
|
||||
/* If we are moving from an 1-channel format to n-channel we need to
|
||||
* ensure the orignal data is copied into the higher channels. */
|
||||
if (ctx.ibuf->channels == 1 && file_spec.nchannels > 1) {
|
||||
final_buf = ImageBuf(file_spec, InitializePixels::No);
|
||||
ImageBufAlgo::paste(final_buf, 0, 0, 0, 0, orig_buf);
|
||||
ImageBufAlgo::paste(final_buf, 0, 0, 0, 1, orig_buf);
|
||||
ImageBufAlgo::paste(final_buf, 0, 0, 0, 2, orig_buf);
|
||||
if (file_spec.alpha_channel == 3) {
|
||||
ROI alpha_roi = file_spec.roi();
|
||||
alpha_roi.chbegin = file_spec.alpha_channel;
|
||||
ImageBufAlgo::fill(final_buf, {0, 0, 0, 1.0f}, alpha_roi);
|
||||
}
|
||||
}
|
||||
else {
|
||||
final_buf = std::move(orig_buf);
|
||||
}
|
||||
}
|
||||
|
||||
bool write_ok = false;
|
||||
|
||||
Reference in New Issue
Block a user