Color management: display color managed RGB values in color sample line
Makes it possible to investigate color managed ranges. Not ideal but it's the quickest thing which could be done to remove current grading stoppers for Mango.
This commit is contained in:
@@ -39,6 +39,7 @@ struct ToolSettings;
|
||||
struct uiBlock;
|
||||
struct wmWindowManager;
|
||||
struct ARegion;
|
||||
struct Scene;
|
||||
|
||||
/* image_edit.c, exported for transform */
|
||||
struct Image *ED_space_image(struct SpaceImage *sima);
|
||||
@@ -79,7 +80,7 @@ int ED_space_image_maskedit_mask_poll(struct bContext *C);
|
||||
/* UI level image (texture) updating... render calls own stuff (too) */
|
||||
void ED_image_update_frame(const struct Main *mainp, int cfra);
|
||||
|
||||
void ED_image_draw_info(struct ARegion *ar, int color_manage, int channels, int x, int y,
|
||||
void ED_image_draw_info(struct Scene *scene, struct ARegion *ar, int color_manage, int channels, int x, int y,
|
||||
const unsigned char cp[4], const float fp[4], int *zp, float *zpf);
|
||||
|
||||
#endif /* __ED_IMAGE_H__ */
|
||||
|
||||
@@ -124,7 +124,7 @@ static void draw_render_info(Scene *scene, Image *ima, ARegion *ar)
|
||||
}
|
||||
|
||||
/* used by node view too */
|
||||
void ED_image_draw_info(ARegion *ar, int color_manage, int channels, int x, int y,
|
||||
void ED_image_draw_info(Scene *scene, ARegion *ar, int color_manage, int channels, int x, int y,
|
||||
const unsigned char cp[4], const float fp[4], int *zp, float *zpf)
|
||||
{
|
||||
char str[256];
|
||||
@@ -221,6 +221,18 @@ void ED_image_draw_info(ARegion *ar, int color_manage, int channels, int x, int
|
||||
BLF_draw_ascii(blf_mono_font, str, sizeof(str));
|
||||
dx += BLF_width(blf_mono_font, str);
|
||||
}
|
||||
|
||||
/* OCIO_TODO: make it fit better to overall color interaction */
|
||||
if (fp && channels == 4) {
|
||||
float pixel[4];
|
||||
|
||||
IMB_display_buffer_pixel(pixel, fp, &scene->view_settings, &scene->display_settings);
|
||||
|
||||
BLI_snprintf(str, sizeof(str), " | CM R:%-.4f G:%-.4f B:%-.4f", pixel[0], pixel[1], pixel[2]);
|
||||
BLF_position(blf_mono_font, dx, 6, 0);
|
||||
BLF_draw_ascii(blf_mono_font, str, sizeof(str));
|
||||
dx += BLF_width(blf_mono_font, str);
|
||||
}
|
||||
}
|
||||
|
||||
/* color rectangle */
|
||||
|
||||
@@ -1987,12 +1987,14 @@ typedef struct ImageSampleInfo {
|
||||
int draw;
|
||||
} ImageSampleInfo;
|
||||
|
||||
static void image_sample_draw(const bContext *UNUSED(C), ARegion *ar, void *arg_info)
|
||||
static void image_sample_draw(const bContext *C, ARegion *ar, void *arg_info)
|
||||
{
|
||||
ImageSampleInfo *info = arg_info;
|
||||
if (info->draw) {
|
||||
Scene *scene = CTX_data_scene(C);
|
||||
|
||||
/* no color management needed for images (color_manage=0) */
|
||||
ED_image_draw_info(ar, 0, info->channels, info->x, info->y, info->colp, info->colfp, info->zp, info->zfp);
|
||||
ED_image_draw_info(scene, ar, 0, info->channels, info->x, info->y, info->colp, info->colfp, info->zp, info->zfp);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -341,7 +341,7 @@ static void sample_draw(const bContext *C, ARegion *ar, void *arg_info)
|
||||
ImageSampleInfo *info = arg_info;
|
||||
|
||||
if (info->draw) {
|
||||
ED_image_draw_info(ar, (scene->r.color_mgt_flag & R_COLOR_MANAGEMENT), info->channels,
|
||||
ED_image_draw_info(scene, ar, (scene->r.color_mgt_flag & R_COLOR_MANAGEMENT), info->channels,
|
||||
info->x, info->y, info->col, info->colf,
|
||||
NULL, NULL /* zbuf - unused for nodes */
|
||||
);
|
||||
|
||||
@@ -78,7 +78,7 @@ static void sample_draw(const bContext *C, ARegion *ar, void *arg_info)
|
||||
ImageSampleInfo *info = arg_info;
|
||||
|
||||
if (info->draw) {
|
||||
ED_image_draw_info(ar, (scene->r.color_mgt_flag & R_COLOR_MANAGEMENT), info->channels,
|
||||
ED_image_draw_info(scene, ar, (scene->r.color_mgt_flag & R_COLOR_MANAGEMENT), info->channels,
|
||||
info->x, info->y, info->col, info->colf, NULL, NULL);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -71,6 +71,9 @@ unsigned char *IMB_display_buffer_acquire(struct ImBuf *ibuf, const struct Color
|
||||
const struct ColorManagedDisplaySettings *display_settings, void **cache_handle);
|
||||
unsigned char *IMB_display_buffer_acquire_ctx(const struct bContext *C, struct ImBuf *ibuf, void **cache_handle);
|
||||
|
||||
void IMB_display_buffer_pixel(float result[4], const float pixel[4], const struct ColorManagedViewSettings *view_settings,
|
||||
const struct ColorManagedDisplaySettings *display_settings);
|
||||
|
||||
void IMB_display_buffer_to_imbuf_rect(struct ImBuf *ibuf, const struct ColorManagedViewSettings *view_settings,
|
||||
const struct ColorManagedDisplaySettings *display_settings);
|
||||
|
||||
|
||||
@@ -1315,6 +1315,23 @@ unsigned char *IMB_display_buffer_acquire_ctx(const bContext *C, ImBuf *ibuf, vo
|
||||
return IMB_display_buffer_acquire(ibuf, view_settings, display_settings, cache_handle);
|
||||
}
|
||||
|
||||
void IMB_display_buffer_pixel(float result[4], const float pixel[4], const ColorManagedViewSettings *view_settings,
|
||||
const ColorManagedDisplaySettings *display_settings)
|
||||
{
|
||||
ConstProcessorRcPtr *processor;
|
||||
const float gamma = view_settings->gamma;
|
||||
const float exposure = view_settings->exposure;
|
||||
const char *view_transform = view_settings->view_transform;
|
||||
const char *display = display_settings->display_device;
|
||||
|
||||
copy_v4_v4(result, pixel);
|
||||
|
||||
processor = create_display_buffer_processor(view_transform, display, exposure, gamma);
|
||||
|
||||
if (processor)
|
||||
OCIO_processorApplyRGBA(processor, result);
|
||||
}
|
||||
|
||||
void IMB_display_buffer_to_imbuf_rect(ImBuf *ibuf, const ColorManagedViewSettings *view_settings,
|
||||
const ColorManagedDisplaySettings *display_settings)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user