WIP: IMB: Allow BW images in byte to float conversion #118622

Draft
Omar Emara wants to merge 8 commits from OmarEmaraDev/blender:refactor-imbuf-byte-to-float into main

When changing the target branch, be careful to rebase the branch in your fork to match. See documentation.
2 changed files with 8 additions and 5 deletions
Showing only changes of commit 18cc38c15e - Show all commits

View File

@ -374,11 +374,6 @@ void cpack_to_rgb(uint col, float *r_r, float *r_g, float *r_b)
*r_b = (float)((col >> 16) & 0xFF) * (1.0f / 255.0f);
}
float uchar_to_float(const uchar value)
{
return ((float)value) * (1.0f / 255.0f);
}
void rgb_uchar_to_float(float r_col[3], const uchar col_ub[3])
{
r_col[0] = ((float)col_ub[0]) * (1.0f / 255.0f);

View File

@ -776,6 +776,14 @@ void IMB_float_from_rect(ImBuf *ibuf)
return;
}
OmarEmaraDev marked this conversation as resolved Outdated

Shouldn't we initialize ibuf->channels based on the number of planes in the else branch here? Otherwise it could left uninitialized, or initialized to some default value which is not necessarily corresponding to the desired value?

Shouldn't we initialize `ibuf->channels` based on the number of planes in the `else` branch here? Otherwise it could left uninitialized, or initialized to some default value which is not necessarily corresponding to the desired value?

Yah, sorry. Was remnant from the time where I though channels was shared between both byte and float buffers.

Yah, sorry. Was remnant from the time where I though channels was shared between both byte and float buffers.
/* For color spaces other than sRGB and linear, we force full RGBA channels since color space
* conversion might introduce color shifts even for greyscale images. */
if (!(IMB_colormanagement_space_is_srgb(ibuf->byte_buffer.colorspace) ||
IMB_colormanagement_space_is_scene_linear(ibuf->byte_buffer.colorspace)))
{
ibuf->channels = 4;
}
IMB_assign_float_buffer(ibuf, rect_float, IB_TAKE_OWNERSHIP);
}