diff --git a/source/blender/blenkernel/BKE_icons.h b/source/blender/blenkernel/BKE_icons.h index 417591e03c5..ae6de80d40b 100644 --- a/source/blender/blenkernel/BKE_icons.h +++ b/source/blender/blenkernel/BKE_icons.h @@ -19,7 +19,7 @@ #ifndef __BKE_ICONS_H__ #define __BKE_ICONS_H__ - +#include "DNA_userdef_types.h" /** \file * \ingroup bke * @@ -159,7 +159,8 @@ struct Icon_Geom *BKE_icon_geom_from_file(const char *filename); struct ImBuf *BKE_icon_geom_rasterize(const struct Icon_Geom *geom, const unsigned int size_x, - const unsigned int size_y); + const unsigned int size_y, + bTheme *testtheme); int BKE_icon_ensure_studio_light(struct StudioLight *sl, int id_type); diff --git a/source/blender/blenkernel/intern/icons_rasterize.c b/source/blender/blenkernel/intern/icons_rasterize.c index e87180ce732..9be17e6fc5a 100644 --- a/source/blender/blenkernel/intern/icons_rasterize.c +++ b/source/blender/blenkernel/intern/icons_rasterize.c @@ -22,12 +22,13 @@ #include "BLI_utildefines.h" #include "BLI_bitmap_draw_2d.h" #include "BLI_math_geom.h" +#include "BLI_math_color.h" #include "IMB_imbuf.h" #include "IMB_imbuf_types.h" #include "BKE_icons.h" - +#include #include "BLI_strict_flags.h" struct UserRasterInfo { @@ -81,14 +82,57 @@ static void tri_fill_smooth(int x, int x_end, int y, void *user_data) } } +static void Color_Dark(uint *col, unsigned char *char4rgba, bTheme *testtheme) +{ + float col3float[3], col4float[4]; + float col3hsv[3]; + float newcol3rgb[3]; + float newcol4rgba[4]; + + rgba_uchar_to_float(col4float, testtheme->tui.wcol_toolbar_item.inner); + for (int i = 0; i < 3; i++) { + col3float[i] = col4float[i]; + } + float BrOfBG = rgb_to_grayscale(col3float); + + rgba_uchar_to_float(col4float, (void *)col); + for (int i = 0; i < 3; i++) { + col3float[i] = col4float[i]; + // printf("%0.2f ", col3float[i]); + } + float alpha = col4float[3]; + float BrofIc = rgb_to_grayscale(col3float); + // printf(" %f ", res2); + if (BrOfBG >= .5f && BrofIc >= .5f) { + rgb_to_hsv_v(col3float, col3hsv); + col3hsv[2] = 1.0 - col3hsv[2] + 0.35; + hsv_to_rgb_v(col3hsv, newcol3rgb); + for (int i = 0; i < 3; i++) { + newcol4rgba[i] = newcol3rgb[i]; + } + newcol4rgba[3] = alpha; + rgba_float_to_uchar(char4rgba, newcol4rgba); + memcpy(col, char4rgba, 4 * (sizeof(char))); + // printf("%0.8x", *col); + printf("flip"); + } + else { + // printf("--- %0.8x col ", *col); + memcpy(char4rgba, col, 4 * (sizeof(char))); + } +}; + ImBuf *BKE_icon_geom_rasterize(const struct Icon_Geom *geom, const unsigned int size_x, - const unsigned int size_y) + const unsigned int size_y, + bTheme *testtheme) { const int coords_len = geom->coords_len; const uchar(*pos)[2] = geom->coords; const uint *col = (void *)geom->colors; + printf("%0.8x colo \n", *col); + // a = (uint *)testtheme->tui.wcol_toolbar_item.inner; /* TODO(campbell): Currently rasterizes to fixed size, then scales. * Should rasterize to double size for eg instead. */ @@ -122,11 +166,27 @@ ImBuf *BKE_icon_geom_rasterize(const struct Icon_Geom *geom, ARRAY_SET_ITEMS(data.pt[1], UNPACK2(pos[1])); ARRAY_SET_ITEMS(data.pt[2], UNPACK2(pos[2])); } + printf("old color %0.8x ", *col); + printf(" %0.8x ", *(col + 1)); + printf(" %0.8x ", *(col + 2)); + + unsigned char char4rgba0[4], char4rgba1[4], char4rgba2[4]; + + Color_Dark((void *)(col + 0), char4rgba0, testtheme); + Color_Dark((void *)(col + 1), char4rgba1, testtheme); + Color_Dark((void *)(col + 2), char4rgba2, testtheme); + + printf("modified char4rbga %0.8x ", *(uint *)char4rgba0); + printf(" %0.8x ", *(uint *)char4rgba1); + printf(" %0.8x ", *(uint *)char4rgba2); + data.color = col; if ((col[0] == col[1]) && (col[0] == col[2])) { + printf("modified color %0.8x %0.8x %0.8x\n\n", col[0], col[1], col[2]); BLI_bitmap_draw_2d_tri_v2i(UNPACK3(data.pt), tri_fill_flat, &data); } else { + printf("l block %0.8x %0.8x %0.8x \n \n", col[0], col[1], col[2]); ARRAY_SET_ITEMS(data.smooth.pt_fl[0], UNPACK2_EX((float), data.pt[0], )); ARRAY_SET_ITEMS(data.smooth.pt_fl[1], UNPACK2_EX((float), data.pt[1], )); ARRAY_SET_ITEMS(data.smooth.pt_fl[2], UNPACK2_EX((float), data.pt[2], )); diff --git a/source/blender/editors/interface/interface_icons.c b/source/blender/editors/interface/interface_icons.c index 5f25316cf25..daee8af13a8 100644 --- a/source/blender/editors/interface/interface_icons.c +++ b/source/blender/editors/interface/interface_icons.c @@ -46,6 +46,7 @@ #include "DNA_screen_types.h" #include "DNA_space_types.h" #include "DNA_workspace_types.h" +#include "DNA_userdef_types.h" #include "RNA_access.h" #include "RNA_enum_types.h" @@ -1837,7 +1838,7 @@ static void icon_draw_size(float x, if (ibuf) { IMB_freeImBuf(ibuf); } - ibuf = BKE_icon_geom_rasterize(icon->obj, w, h); + ibuf = BKE_icon_geom_rasterize(icon->obj, w, h, btheme); di->data.geom.image_cache = ibuf; }