[Bf-blender-cvs] [6f77846c683] greasepencil-object: GPencil: Use image name for palette extracted

Antonio Vazquez noreply at git.blender.org
Fri Nov 22 11:17:15 CET 2019


Commit: 6f77846c6836f18c2602ef00001cb463f82b41d1
Author: Antonio Vazquez
Date:   Fri Nov 22 11:12:05 2019 +0100
Branches: greasepencil-object
https://developer.blender.org/rB6f77846c6836f18c2602ef00001cb463f82b41d1

GPencil: Use image name for palette extracted

Now the palette name is equals to image name.

===================================================================

M	source/blender/blenkernel/BKE_paint.h
M	source/blender/blenkernel/intern/paint.c
M	source/blender/editors/gpencil/gpencil_vertex_ops.c
M	source/blender/editors/sculpt_paint/paint_ops.c

===================================================================

diff --git a/source/blender/blenkernel/BKE_paint.h b/source/blender/blenkernel/BKE_paint.h
index 0072d921328..e7975a8a0d8 100644
--- a/source/blender/blenkernel/BKE_paint.h
+++ b/source/blender/blenkernel/BKE_paint.h
@@ -132,7 +132,7 @@ void BKE_palette_clear(struct Palette *palette);
 
 void BKE_palette_sort_hsv(struct tPaletteColorHSV *color_array, const int totcol);
 void BKE_palette_sort_svh(struct tPaletteColorHSV *color_array, const int totcol);
-bool BKE_palette_from_hash(struct Main *bmain, struct GHash *color_table);
+bool BKE_palette_from_hash(struct Main *bmain, struct GHash *color_table, const char *name);
 
 /* paint curves */
 struct PaintCurve *BKE_paint_curve_add(struct Main *bmain, const char *name);
diff --git a/source/blender/blenkernel/intern/paint.c b/source/blender/blenkernel/intern/paint.c
index a95acf48bfe..457120d756d 100644
--- a/source/blender/blenkernel/intern/paint.c
+++ b/source/blender/blenkernel/intern/paint.c
@@ -773,7 +773,7 @@ void BKE_palette_sort_svh(tPaletteColorHSV *color_array, const int totcol)
   qsort(color_array, totcol, sizeof(tPaletteColorHSV), palettecolor_compare_svh);
 }
 
-bool BKE_palette_from_hash(Main *bmain, GHash *color_table)
+bool BKE_palette_from_hash(Main *bmain, GHash *color_table, const char *name)
 {
   tPaletteColorHSV *color_array = NULL;
   tPaletteColorHSV *col_elm = NULL;
@@ -809,7 +809,7 @@ bool BKE_palette_from_hash(Main *bmain, GHash *color_table)
     /* Sort by Hue and saturation. */
     BKE_palette_sort_hsv(color_array, totpal);
 
-    Palette *palette = BKE_palette_add(bmain, "Palette");
+    Palette *palette = BKE_palette_add(bmain, name);
     if (palette) {
       for (int i = 0; i < totpal; i++) {
         col_elm = &color_array[i];
diff --git a/source/blender/editors/gpencil/gpencil_vertex_ops.c b/source/blender/editors/gpencil/gpencil_vertex_ops.c
index d522a2897f9..4bd92a97b9e 100644
--- a/source/blender/editors/gpencil/gpencil_vertex_ops.c
+++ b/source/blender/editors/gpencil/gpencil_vertex_ops.c
@@ -577,7 +577,7 @@ static bool gp_extract_palette_from_vertex(bContext *C, const bool selected, con
   CTX_DATA_END;
 
   /* Create the Palette. */
-  done = BKE_palette_from_hash(bmain, color_table);
+  done = BKE_palette_from_hash(bmain, color_table, "Palette");
 
   /* Free memory. */
   BLI_ghash_free(color_table, NULL, NULL);
diff --git a/source/blender/editors/sculpt_paint/paint_ops.c b/source/blender/editors/sculpt_paint/paint_ops.c
index a4c0bee4d6e..f34d369b69f 100644
--- a/source/blender/editors/sculpt_paint/paint_ops.c
+++ b/source/blender/editors/sculpt_paint/paint_ops.c
@@ -367,7 +367,7 @@ static int palette_extract_img_exec(bContext *C, wmOperator *op)
       }
     }
 
-    done = BKE_palette_from_hash(bmain, color_table);
+    done = BKE_palette_from_hash(bmain, color_table, image->id.name + 2);
   }
 
   /* Free memory. */



More information about the Bf-blender-cvs mailing list