Skip to content

Commit f9064b2

Browse files
authored
Fix the color depth returned when reading the gray.cpt master CPT. (#8522)
* Fix the color depth returned when reading the gray.cpt master CPT. * Fix typo.
1 parent 1befd6f commit f9064b2

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

src/gmt_support.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8788,6 +8788,9 @@ struct GMT_PALETTE * gmtlib_read_cpt (struct GMT_CTRL *GMT, void *source, unsign
87888788
if (n < n_alloc) X->data = gmt_M_memory (GMT, X->data, n, struct GMT_LUT);
87898789
X->n_colors = n;
87908790

8791+
/* The master gray.cpt has only one slice and hence it comes out as both gray & bw, but it can only be one of them. */
8792+
if (X->n_colors == 1 && X->is_gray && X->is_bw) X->is_bw = false; /* Prefer gray over bw (would crash grdimage with externals). */
8793+
87918794
if (X->categorical) { /* Set up fake ranges so CPT is continuous */
87928795
dz = 1.0; /* This will presumably get reset in the loop */
87938796
for (i = 0; i < X->n_colors; i++) {

0 commit comments

Comments
 (0)