Fix T66137: added normal map for painting has wrong color space until refresh
This commit is contained in:
@@ -205,7 +205,8 @@ struct Image *BKE_image_add_generated(struct Main *bmain,
|
||||
int floatbuf,
|
||||
short gen_type,
|
||||
const float color[4],
|
||||
const bool stereo3d);
|
||||
const bool stereo3d,
|
||||
const bool is_data);
|
||||
/* adds image from imbuf, owns imbuf */
|
||||
struct Image *BKE_image_add_from_imbuf(struct Main *bmain, struct ImBuf *ibuf, const char *name);
|
||||
|
||||
|
||||
@@ -679,41 +679,48 @@ Image *BKE_image_add_generated(Main *bmain,
|
||||
int floatbuf,
|
||||
short gen_type,
|
||||
const float color[4],
|
||||
const bool stereo3d)
|
||||
const bool stereo3d,
|
||||
const bool is_data)
|
||||
{
|
||||
/* on save, type is changed to FILE in editsima.c */
|
||||
Image *ima = image_alloc(bmain, name, IMA_SRC_GENERATED, IMA_TYPE_UV_TEST);
|
||||
if (ima == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (ima) {
|
||||
int view_id;
|
||||
const char *names[2] = {STEREO_LEFT_NAME, STEREO_RIGHT_NAME};
|
||||
int view_id;
|
||||
const char *names[2] = {STEREO_LEFT_NAME, STEREO_RIGHT_NAME};
|
||||
|
||||
/* STRNCPY(ima->name, name); */ /* don't do this, this writes in ain invalid filepath! */
|
||||
ima->gen_x = width;
|
||||
ima->gen_y = height;
|
||||
ima->gen_type = gen_type;
|
||||
ima->gen_flag |= (floatbuf ? IMA_GEN_FLOAT : 0);
|
||||
ima->gen_depth = depth;
|
||||
copy_v4_v4(ima->gen_color, color);
|
||||
/* STRNCPY(ima->name, name); */ /* don't do this, this writes in ain invalid filepath! */
|
||||
ima->gen_x = width;
|
||||
ima->gen_y = height;
|
||||
ima->gen_type = gen_type;
|
||||
ima->gen_flag |= (floatbuf ? IMA_GEN_FLOAT : 0);
|
||||
ima->gen_depth = depth;
|
||||
copy_v4_v4(ima->gen_color, color);
|
||||
|
||||
for (view_id = 0; view_id < 2; view_id++) {
|
||||
ImBuf *ibuf;
|
||||
ibuf = add_ibuf_size(
|
||||
width, height, ima->name, depth, floatbuf, gen_type, color, &ima->colorspace_settings);
|
||||
image_assign_ibuf(ima, ibuf, stereo3d ? view_id : IMA_NO_INDEX, 0);
|
||||
if (is_data) {
|
||||
STRNCPY(ima->colorspace_settings.name,
|
||||
IMB_colormanagement_role_colorspace_name_get(COLOR_ROLE_DATA));
|
||||
}
|
||||
|
||||
/* image_assign_ibuf puts buffer to the cache, which increments user counter. */
|
||||
IMB_freeImBuf(ibuf);
|
||||
if (!stereo3d) {
|
||||
break;
|
||||
}
|
||||
for (view_id = 0; view_id < 2; view_id++) {
|
||||
ImBuf *ibuf;
|
||||
ibuf = add_ibuf_size(
|
||||
width, height, ima->name, depth, floatbuf, gen_type, color, &ima->colorspace_settings);
|
||||
image_assign_ibuf(ima, ibuf, stereo3d ? view_id : IMA_NO_INDEX, 0);
|
||||
|
||||
image_add_view(ima, names[view_id], "");
|
||||
/* image_assign_ibuf puts buffer to the cache, which increments user counter. */
|
||||
IMB_freeImBuf(ibuf);
|
||||
if (!stereo3d) {
|
||||
break;
|
||||
}
|
||||
|
||||
ima->ok = IMA_OK_LOADED;
|
||||
image_add_view(ima, names[view_id], "");
|
||||
}
|
||||
|
||||
ima->ok = IMA_OK_LOADED;
|
||||
|
||||
return ima;
|
||||
}
|
||||
|
||||
|
||||
@@ -6435,13 +6435,16 @@ static Image *proj_paint_image_create(wmOperator *op, Main *bmain, bool is_data)
|
||||
alpha = RNA_boolean_get(op->ptr, "alpha");
|
||||
RNA_string_get(op->ptr, "name", imagename);
|
||||
}
|
||||
ima = BKE_image_add_generated(
|
||||
bmain, width, height, imagename, alpha ? 32 : 24, use_float, gen_type, color, false);
|
||||
|
||||
if (is_data) {
|
||||
STRNCPY(ima->colorspace_settings.name,
|
||||
IMB_colormanagement_role_colorspace_name_get(COLOR_ROLE_DATA));
|
||||
}
|
||||
ima = BKE_image_add_generated(bmain,
|
||||
width,
|
||||
height,
|
||||
imagename,
|
||||
alpha ? 32 : 24,
|
||||
use_float,
|
||||
gen_type,
|
||||
color,
|
||||
false,
|
||||
is_data);
|
||||
|
||||
return ima;
|
||||
}
|
||||
|
||||
@@ -2499,7 +2499,7 @@ static int image_new_exec(bContext *C, wmOperator *op)
|
||||
}
|
||||
|
||||
ima = BKE_image_add_generated(
|
||||
bmain, width, height, name, alpha ? 32 : 24, floatbuf, gen_type, color, stereo3d);
|
||||
bmain, width, height, name, alpha ? 32 : 24, floatbuf, gen_type, color, stereo3d, false);
|
||||
|
||||
if (!ima) {
|
||||
image_new_free(op);
|
||||
|
||||
@@ -371,14 +371,15 @@ static Image *rna_Main_images_new(Main *bmain,
|
||||
int height,
|
||||
bool alpha,
|
||||
bool float_buffer,
|
||||
bool stereo3d)
|
||||
bool stereo3d,
|
||||
bool is_data)
|
||||
{
|
||||
char safe_name[MAX_ID_NAME - 2];
|
||||
rna_idname_validate(name, safe_name);
|
||||
|
||||
float color[4] = {0.0, 0.0, 0.0, 1.0};
|
||||
Image *image = BKE_image_add_generated(
|
||||
bmain, width, height, safe_name, alpha ? 32 : 24, float_buffer, 0, color, stereo3d);
|
||||
bmain, width, height, safe_name, alpha ? 32 : 24, float_buffer, 0, color, stereo3d, is_data);
|
||||
id_us_min(&image->id);
|
||||
return image;
|
||||
}
|
||||
@@ -1144,6 +1145,7 @@ void RNA_def_main_images(BlenderRNA *brna, PropertyRNA *cprop)
|
||||
RNA_def_boolean(
|
||||
func, "float_buffer", 0, "Float Buffer", "Create an image with floating point color");
|
||||
RNA_def_boolean(func, "stereo3d", 0, "Stereo 3D", "Create left and right views");
|
||||
RNA_def_boolean(func, "is_data", 0, "Is Data", "Create image with non-color data color space");
|
||||
/* return type */
|
||||
parm = RNA_def_pointer(func, "image", "Image", "", "New image data-block");
|
||||
RNA_def_function_return(func, parm);
|
||||
|
||||
Reference in New Issue
Block a user