From 3926ec6aa1bc6981fc7e2e07a94b1d92d8518111 Mon Sep 17 00:00:00 2001 From: Jeroen Bakker Date: Fri, 8 Jun 2018 12:10:29 +0200 Subject: Studiolight: Segment when using float based matcaps --- source/blender/blenkernel/intern/studiolight.c | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) (limited to 'source/blender/blenkernel/intern/studiolight.c') diff --git a/source/blender/blenkernel/intern/studiolight.c b/source/blender/blenkernel/intern/studiolight.c index da3cc97c43f..e4b49656907 100644 --- a/source/blender/blenkernel/intern/studiolight.c +++ b/source/blender/blenkernel/intern/studiolight.c @@ -584,15 +584,19 @@ static uint *studiolight_matcap_preview(StudioLight *sl, int icon_size) BKE_studiolight_ensure_flag(sl, STUDIOLIGHT_EXTERNAL_IMAGE_LOADED); uint *rect = MEM_mallocN(icon_size * icon_size * sizeof(uint), __func__); + const uint alphamask = 0xff000000; + float color[4]; + float fx, fy; int offset = 0; ImBuf *ibuf = sl->equirectangular_radiance_buffer; for (int y = 0; y < icon_size; y++) { for (int x = 0; x < icon_size; x++) { - uint pixelresult = 0x0; - float fx = x * ibuf->x / icon_size; - float fy = y * ibuf->y / icon_size; - nearest_interpolation_color(ibuf, (uchar *)&pixelresult, NULL, fx, fy); - rect[offset++] = pixelresult; + fx = x * ibuf->x / icon_size; + fy = y * ibuf->y / icon_size; + nearest_interpolation_color(ibuf, NULL, color, fx, fy); + rect[offset++] = rgb_to_cpack(linearrgb_to_srgb(color[0]), + linearrgb_to_srgb(color[1]), + linearrgb_to_srgb(color[2])) | alphamask; } } return rect; @@ -834,4 +838,4 @@ void BKE_studiolight_refresh(void) { BKE_studiolight_free(); BKE_studiolight_init(); -} \ No newline at end of file +} -- cgit v1.2.3