From 29f3af95272590d26f610ae828b2eeee89c82a00 Mon Sep 17 00:00:00 2001 From: Antonio Vazquez Date: Mon, 9 Mar 2020 16:27:24 +0100 Subject: GPencil: Refactor of Draw Engine, Vertex Paint and all internal functions This commit is a full refactor of the grease pencil modules including Draw Engine, Modifiers, VFX, depsgraph update, improvements in operators and conversion of Sculpt and Weight paint tools to real brushes. Also, a huge code cleanup has been done at all levels. Thanks to @fclem for his work and yo @pepeland and @mendio for the testing and help in the development. Differential Revision: https://developer.blender.org/D6293 --- source/blender/imbuf/IMB_imbuf.h | 3 +++ source/blender/imbuf/intern/imageprocess.c | 17 +++++++++++++++++ 2 files changed, 20 insertions(+) (limited to 'source/blender/imbuf') diff --git a/source/blender/imbuf/IMB_imbuf.h b/source/blender/imbuf/IMB_imbuf.h index 8ac9b2e2e16..83ef910d0bb 100644 --- a/source/blender/imbuf/IMB_imbuf.h +++ b/source/blender/imbuf/IMB_imbuf.h @@ -601,6 +601,9 @@ void bilinear_interpolation_color_wrap( void IMB_alpha_under_color_float(float *rect_float, int x, int y, float backcol[3]); void IMB_alpha_under_color_byte(unsigned char *rect, int x, int y, float backcol[3]); +void IMB_sampleImageAtLocation( + struct ImBuf *ibuf, float x, float y, bool make_linear_rgb, float color[4]); + /** * * \attention defined in readimage.c diff --git a/source/blender/imbuf/intern/imageprocess.c b/source/blender/imbuf/intern/imageprocess.c index 6a234232a35..4cd47d19e62 100644 --- a/source/blender/imbuf/intern/imageprocess.c +++ b/source/blender/imbuf/intern/imageprocess.c @@ -37,6 +37,7 @@ #include "IMB_imbuf_types.h" #include "IMB_imbuf.h" +#include "IMB_colormanagement.h" #include /* Only this one is used liberally here, and in imbuf */ @@ -490,3 +491,19 @@ void IMB_alpha_under_color_byte(unsigned char *rect, int x, int y, float backcol cp += 4; } } + +/* Sample pixel of image using NEAREST method. */ +void IMB_sampleImageAtLocation(ImBuf *ibuf, float x, float y, bool make_linear_rgb, float color[4]) +{ + if (ibuf->rect_float) { + nearest_interpolation_color(ibuf, NULL, color, x, y); + } + else { + unsigned char byte_color[4]; + nearest_interpolation_color(ibuf, byte_color, NULL, x, y); + rgba_uchar_to_float(color, byte_color); + if (make_linear_rgb) { + IMB_colormanagement_colorspace_to_scene_linear_v4(color, false, ibuf->rect_colorspace); + } + } +} -- cgit v1.2.3