cdisplay_colorblind.c 20.2 KB
Newer Older
1 2 3 4
/* The GIMP -- an image manipulation program
 * Copyright (C) 1995-1997 Spencer Kimball and Peter Mattis
 *
 * cdisplay_colorblind.c
5 6
 * Copyright (C) 2002-2003 Michael Natterer <mitch@gimp.org>,
 *                         Sven Neumann <sven@gimp.org>,
7 8 9
 *                         Robert Dougherty <bob@vischeck.com> and
 *                         Alex Wade <alex@vischeck.com>
 *
10 11
 * This code is an implementation of an algorithm described by Hans Brettel,
 * Francoise Vienot and John Mollon in the Journal of the Optical Society of
12
 * America V14(10), pg 2647. (See http://vischeck.com/ for more info.)
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 */

#include "config.h"

#include <string.h>

#include <gtk/gtk.h>

35 36
#include "libgimpconfig/gimpconfig.h"
#include "libgimpmath/gimpmath.h"
37 38 39 40 41 42 43 44
#include "libgimpmodule/gimpmodule.h"
#include "libgimpwidgets/gimpwidgets.h"

#include "libgimp/libgimp-intl.h"


typedef enum
{
45
  COLORBLIND_DEFICIENCY_PROTANOPIA,
46
  COLORBLIND_DEFICIENCY_DEUTERANOPIA,
47
  COLORBLIND_DEFICIENCY_TRITANOPIA
48 49
} ColorblindDeficiency;

50 51 52
#define CDISPLAY_TYPE_COLORBLIND_DEFICIENCY (cdisplay_colorblind_deficiency_type)
static GType  cdisplay_colorblind_deficiency_get_type (GTypeModule *module);

53
static const GEnumValue enum_values[] =
54 55
{
  { COLORBLIND_DEFICIENCY_PROTANOPIA,
56
    "COLORBLIND_DEFICIENCY_PROTANOPIA", "protanopia"   },
57
  { COLORBLIND_DEFICIENCY_DEUTERANOPIA,
58
    "COLORBLIND_DEFICIENCY_DEUTERANOPIA", "deuteranopia" },
59
  { COLORBLIND_DEFICIENCY_TRITANOPIA,
60
    "COLORBLIND_DEFICIENCY_TRITANOPIA", "tritanopia"   },
61 62 63
  { 0, NULL, NULL }
};

64 65 66 67 68 69 70 71 72 73
static const GimpEnumDesc enum_descs[] =
  {
    { COLORBLIND_DEFICIENCY_PROTANOPIA,
      N_("Protanopia (insensitivity to red"), NULL },
    { COLORBLIND_DEFICIENCY_DEUTERANOPIA,
      N_("Deuteranopia (insensitivity to green)"), NULL },
    { COLORBLIND_DEFICIENCY_TRITANOPIA,
      N_("Tritanopia (insensitivity to blue)"), NULL },
    { 0, NULL, NULL }
  };
74

75 76
#define DEFAULT_DEFICIENCY  COLORBLIND_DEFICIENCY_DEUTERANOPIA
#define COLOR_CACHE_SIZE    1021
77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94


#define CDISPLAY_TYPE_COLORBLIND            (cdisplay_colorblind_type)
#define CDISPLAY_COLORBLIND(obj)            (G_TYPE_CHECK_INSTANCE_CAST ((obj), CDISPLAY_TYPE_COLORBLIND, CdisplayColorblind))
#define CDISPLAY_COLORBLIND_CLASS(klass)    (G_TYPE_CHECK_CLASS_CAST ((klass), CDISPLAY_TYPE_COLORBLIND, CdisplayColorblindClass))
#define CDISPLAY_IS_COLORBLIND(obj)         (G_TYPE_CHECK_INSTANCE_TYPE ((obj), CDISPLAY_TYPE_COLORBLIND))
#define CDISPLAY_IS_COLORBLIND_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), CDISPLAY_TYPE_COLORBLIND))


typedef struct _CdisplayColorblind      CdisplayColorblind;
typedef struct _CdisplayColorblindClass CdisplayColorblindClass;

struct _CdisplayColorblind
{
  GimpColorDisplay      parent_instance;

  ColorblindDeficiency  deficiency;

95 96 97 98
  gfloat                a1, b1, c1;
  gfloat                a2, b2, c2;
  gfloat                inflection;

99
  guint32               cache[2 * COLOR_CACHE_SIZE];
100
  gfloat                gamma_lut[256];
101 102 103 104 105 106 107 108
};

struct _CdisplayColorblindClass
{
  GimpColorDisplayClass  parent_instance;
};


109 110 111 112 113 114 115
enum
{
  PROP_0,
  PROP_DEFICIENCY
};


116 117 118
static GType       cdisplay_colorblind_get_type   (GTypeModule              *module);
static void        cdisplay_colorblind_class_init (CdisplayColorblindClass  *klass);
static void        cdisplay_colorblind_init       (CdisplayColorblind       *colorblind);
119

120 121 122 123 124 125 126 127
static void        cdisplay_colorblind_set_property  (GObject               *object,
                                                      guint                  property_id,
                                                      const GValue          *value,
                                                      GParamSpec            *pspec);
static void        cdisplay_colorblind_get_property  (GObject               *object,
                                                      guint                  property_id,
                                                      GValue                *value,
                                                      GParamSpec            *pspec);
128 129 130 131 132 133 134 135 136 137 138 139

static void        cdisplay_colorblind_convert       (GimpColorDisplay      *display,
                                                      guchar                *buf,
                                                      gint                   w,
                                                      gint                   h,
                                                      gint                   bpp,
                                                      gint                   bpl);
static GtkWidget * cdisplay_colorblind_configure      (GimpColorDisplay     *display);
static void        cdisplay_colorblind_changed        (GimpColorDisplay     *display);

static void        cdisplay_colorblind_set_deficiency (CdisplayColorblind   *colorblind,
                                                       ColorblindDeficiency  value);
140

141 142 143 144 145 146 147 148 149 150 151 152 153 154 155

  /* The RGB<->LMS transforms above are computed from the human cone
   * photo-pigment absorption spectra and the monitor phosphor
   * emission spectra. These parameters are fairly constant for most
   * humans and most montiors (at least for modern CRTs). However,
   * gamma will vary quite a bit, as it is a property of the monitor
   * (eg. amplifier gain), the video card, and even the
   * software. Further, users can adjust their gammas (either via
   * adjusting the monitor amp gains or in software). That said, the
   * following are the gamma estimates that we have used in the
   * Vischeck code. Many colorblind users have viewed our simulations
   * and told us that they "work" (simulated and original images are
   * indistinguishabled).
   */

156
static const gfloat gammaRGB = 2.1;
157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196


  /* For most modern Cathode-Ray Tube monitors (CRTs), the following
   * are good estimates of the RGB->LMS and LMS->RGB transform
   * matrices.  They are based on spectra measured on a typical CRT
   * with a PhotoResearch PR650 spectral photometer and the Stockman
   * human cone fundamentals. NOTE: these estimates will NOT work well
   * for LCDs!
   */
static const gfloat rgb2lms[9] =
{
  0.05059983,
  0.08585369,
  0.00952420,

  0.01893033,
  0.08925308,
  0.01370054,

  0.00292202,
  0.00975732,
  0.07145979
};

static const gfloat lms2rgb[9] =
{
   30.830854,
  -29.832659,
    1.610474,

   -6.481468,
   17.715578,
   -2.532642,

   -0.375690,
   -1.199062,
   14.273846
};


197
static const GimpModuleInfo cdisplay_colorblind_info =
198
{
199
  GIMP_MODULE_ABI_VERSION,
200
  N_("Color deficit simulation filter (Brettel-Vienot-Mollon algorithm)"),
201 202
  "Michael Natterer <mitch@gimp.org>, Bob Dougherty <bob@vischeck.com>, "
  "Alex Wade <alex@vischeck.com>",
203
  "v0.2",
204
  "(c) 2002-2004, released under the GPL",
205
  "January 22, 2003"
206 207
};

208 209 210
static GType                  cdisplay_colorblind_type            = 0;
static GType                  cdisplay_colorblind_deficiency_type = 0;
static GimpColorDisplayClass *parent_class                        = NULL;
211 212 213 214 215 216 217 218 219 220 221 222


G_MODULE_EXPORT const GimpModuleInfo *
gimp_module_query (GTypeModule *module)
{
  return &cdisplay_colorblind_info;
}

G_MODULE_EXPORT gboolean
gimp_module_register (GTypeModule *module)
{
  cdisplay_colorblind_get_type (module);
223
  cdisplay_colorblind_deficiency_get_type (module);
224 225 226 227 228 229 230 231 232

  return TRUE;
}

static GType
cdisplay_colorblind_get_type (GTypeModule *module)
{
  if (! cdisplay_colorblind_type)
    {
233
      static const GTypeInfo display_info =
234 235
      {
        sizeof (CdisplayColorblindClass),
236 237 238 239 240 241 242 243
        (GBaseInitFunc) NULL,
        (GBaseFinalizeFunc) NULL,
        (GClassInitFunc) cdisplay_colorblind_class_init,
        NULL,           /* class_finalize */
        NULL,           /* class_data     */
        sizeof (CdisplayColorblind),
        0,              /* n_preallocs    */
        (GInstanceInitFunc) cdisplay_colorblind_init,
244 245 246 247 248 249
      };

      cdisplay_colorblind_type =
        g_type_module_register_type (module,
                                     GIMP_TYPE_COLOR_DISPLAY,
                                     "CdisplayColorblind",
250
                                     &display_info, 0);
251 252 253 254 255
    }

  return cdisplay_colorblind_type;
}

256 257 258 259 260

static GType
cdisplay_colorblind_deficiency_get_type (GTypeModule *module)
{
  if (! cdisplay_colorblind_deficiency_type)
261 262
    {
      cdisplay_colorblind_deficiency_type =
263 264
        g_type_module_register_enum (module, "CDisplayColorblindDeficiency",
                                     enum_values);
265 266 267 268

      gimp_enum_set_value_descriptions (cdisplay_colorblind_deficiency_type,
                                        enum_descs);
    }
269 270 271 272

  return cdisplay_colorblind_deficiency_type;
}

273 274 275
static void
cdisplay_colorblind_class_init (CdisplayColorblindClass *klass)
{
276 277
  GObjectClass          *object_class  = G_OBJECT_CLASS (klass);
  GimpColorDisplayClass *display_class = GIMP_COLOR_DISPLAY_CLASS (klass);
278 279 280

  parent_class = g_type_class_peek_parent (klass);

281 282
  object_class->get_property = cdisplay_colorblind_get_property;
  object_class->set_property = cdisplay_colorblind_set_property;
283

284 285 286 287
  GIMP_CONFIG_INSTALL_PROP_ENUM (object_class, PROP_DEFICIENCY,
                                 "deficiency", NULL,
                                 CDISPLAY_TYPE_COLORBLIND_DEFICIENCY,
                                 DEFAULT_DEFICIENCY,
288
                                 0);
289

290 291 292 293 294
  display_class->name        = _("Color Deficient Vision");
  display_class->help_id     = "gimp-colordisplay-colorblind";
  display_class->convert     = cdisplay_colorblind_convert;
  display_class->configure   = cdisplay_colorblind_configure;
  display_class->changed     = cdisplay_colorblind_changed;
295 296 297 298 299
}

static void
cdisplay_colorblind_init (CdisplayColorblind *colorblind)
{
300
  gint i;
301

302
  for (i = 0; i < 256; i++)
303
    colorblind->gamma_lut[i] = pow (i, 1.0 / gammaRGB);
304 305
}

306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343
static void
cdisplay_colorblind_get_property (GObject    *object,
                                  guint       property_id,
                                  GValue     *value,
                                  GParamSpec *pspec)
{
  CdisplayColorblind *colorblind = CDISPLAY_COLORBLIND (object);

  switch (property_id)
    {
    case PROP_DEFICIENCY:
      g_value_set_enum (value, colorblind->deficiency);
      break;
    default:
      G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
      break;
    }
}

static void
cdisplay_colorblind_set_property (GObject      *object,
                                  guint         property_id,
                                  const GValue *value,
                                  GParamSpec   *pspec)
{
  CdisplayColorblind *colorblind = CDISPLAY_COLORBLIND (object);

  switch (property_id)
    {
    case PROP_DEFICIENCY:
      cdisplay_colorblind_set_deficiency (colorblind,
                                          g_value_get_enum (value));
      break;
    default:
      G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
      break;
    }
}
344

345 346 347 348 349 350 351 352 353 354

/*
 * This function performs a binary search in the gamma LUT.  It
 * assumes a monotone gamma function and it simply clips out of gamut
 * values. It would be better to desaturate instead of clipping.
 */
static inline guchar
lut_lookup (gfloat        value,
            const gfloat *lut)
{
355
  guchar offset = 127;
Sven Neumann's avatar
Sven Neumann committed
356
  guchar step   = 64;
357

358
  while (step)
359
    {
360
      if (lut[offset] > value)
361
        {
362
          offset -= step;
363 364 365
        }
      else
        {
366 367
          if (lut[offset + 1] > value)
            return offset;
368

369
          offset += step;
370
        }
371 372

      step /= 2;
373
    }
374

375 376 377 378
  /*  the algorithm above can't reach 255  */
  if (offset == 254 && lut[255] < value)
    return 255;

379
  return offset;
380 381
}

382 383 384 385 386 387 388 389
static void
cdisplay_colorblind_convert (GimpColorDisplay *display,
                             guchar           *buf,
                             gint              width,
                             gint              height,
                             gint              bpp,
                             gint              bpl)
{
390
  CdisplayColorblind *colorblind = CDISPLAY_COLORBLIND (display);
391 392 393 394 395 396
  const gfloat        a1 = colorblind->a1;
  const gfloat        b1 = colorblind->b1;
  const gfloat        c1 = colorblind->c1;
  const gfloat        a2 = colorblind->a2;
  const gfloat        b2 = colorblind->b2;
  const gfloat        c2 = colorblind->c2;
397
  gfloat              tmp;
398 399 400
  gfloat              red, green, blue;
  gfloat              redOld, greenOld;
  guchar             *b;
401
  gint                x, y;
402

403
  /* Require 3 bytes per pixel (assume RGB) */
404 405 406
  if (bpp != 3)
    return;

407 408 409 410 411 412 413 414 415 416 417 418 419
  for (y = 0; y < height; y++, buf += bpl)
    for (x = 0, b = buf; x < width; x++, b += bpp)
      {
        guint32 pixel;
        guint   index;

        /* First check our cache */
        pixel = b[0] << 16 | b[1] << 8 | b[2];
        index = pixel % COLOR_CACHE_SIZE;

        if (colorblind->cache[2 * index] == pixel)
          {
            pixel = colorblind->cache[2 * index + 1];
420

421 422 423 424 425 426 427 428
            b[2] = pixel & 0xFF; pixel >>= 8;
            b[1] = pixel & 0xFF; pixel >>= 8;
            b[0] = pixel & 0xFF;

            continue;
          }

        /* Remove gamma to linearize RGB intensities */
429 430 431
        red   = colorblind->gamma_lut[b[0]];
        green = colorblind->gamma_lut[b[1]];
        blue  = colorblind->gamma_lut[b[2]];
432

433 434 435
        /* Convert to LMS (dot product with transform matrix) */
        redOld   = red;
        greenOld = green;
436

437 438 439
        red   = redOld * rgb2lms[0] + greenOld * rgb2lms[1] + blue * rgb2lms[2];
        green = redOld * rgb2lms[3] + greenOld * rgb2lms[4] + blue * rgb2lms[5];
        blue  = redOld * rgb2lms[6] + greenOld * rgb2lms[7] + blue * rgb2lms[8];
440

441 442
        switch (colorblind->deficiency)
          {
443
          case COLORBLIND_DEFICIENCY_DEUTERANOPIA:
444 445 446
            tmp = blue / red;
            /* See which side of the inflection line we fall... */
            if (tmp < colorblind->inflection)
447
              green = -(a1 * red + c1 * blue) / b1;
448 449 450 451
            else
              green = -(a2 * red + c2 * blue) / b2;
            break;

452
          case COLORBLIND_DEFICIENCY_PROTANOPIA:
453 454 455 456 457 458 459
            tmp = blue / green;
            /* See which side of the inflection line we fall... */
            if (tmp < colorblind->inflection)
              red = -(b1 * green + c1 * blue) / a1;
            else
              red = -(b2 * green + c2 * blue) / a2;
            break;
460

461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476
          case COLORBLIND_DEFICIENCY_TRITANOPIA:
            tmp = green / red;
            /* See which side of the inflection line we fall... */
            if (tmp < colorblind->inflection)
              blue = -(a1 * red + b1 * green) / c1;
            else
              blue = -(a2 * red + b2 * green) / c2;
            break;

          default:
            break;
          }

        /* Convert back to RGB (cross product with transform matrix) */
        redOld   = red;
        greenOld = green;
477

478 479 480
        red   = redOld * lms2rgb[0] + greenOld * lms2rgb[1] + blue * lms2rgb[2];
        green = redOld * lms2rgb[3] + greenOld * lms2rgb[4] + blue * lms2rgb[5];
        blue  = redOld * lms2rgb[6] + greenOld * lms2rgb[7] + blue * lms2rgb[8];
481

482
        /* Apply gamma to go back to non-linear intensities */
483 484 485
        b[0] = lut_lookup (red,   colorblind->gamma_lut);
        b[1] = lut_lookup (green, colorblind->gamma_lut);
        b[2] = lut_lookup (blue,  colorblind->gamma_lut);
486

487 488 489 490
        /* Put the result into our cache */
        colorblind->cache[2 * index]     = pixel;
        colorblind->cache[2 * index + 1] = b[0] << 16 | b[1] << 8 | b[2];
      }
491 492 493 494 495
}

static GtkWidget *
cdisplay_colorblind_configure (GimpColorDisplay *display)
{
Sven Neumann's avatar
Sven Neumann committed
496
  CdisplayColorblind *colorblind = CDISPLAY_COLORBLIND (display);
497
  GtkWidget          *hbox;
498
  GtkWidget          *label;
499
  GtkWidget          *combo;
500

501
  hbox = gtk_hbox_new (FALSE, 6);
502

503
  label = gtk_label_new_with_mnemonic (_("Color _Deficiency Type:"));
504
  gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0);
505 506
  gtk_widget_show (label);

507 508
  combo =
    gimp_prop_enum_combo_box_new (G_OBJECT (colorblind), "deficiency", 0, 0);
509

510
  gtk_box_pack_start (GTK_BOX (hbox), combo, TRUE, TRUE, 0);
511
  gtk_widget_show (combo);
512

513
  gtk_label_set_mnemonic_widget (GTK_LABEL (label), combo);
514

515
  return hbox;
516 517
}

518 519 520
static void
cdisplay_colorblind_changed (GimpColorDisplay *display)
{
Sven Neumann's avatar
Sven Neumann committed
521
  CdisplayColorblind *colorblind = CDISPLAY_COLORBLIND (display);
522 523 524 525
  gfloat              anchor_e[3];
  gfloat              anchor[12];

  /*  This function performs initialisations that are dependant
526
   *  on the type of color deficiency.
527 528
   */

529
  /* Performs protan, deutan or tritan color image simulation based on
530 531 532 533 534 535 536 537 538 539
   * Brettel, Vienot and Mollon JOSA 14/10 1997
   *  L,M,S for lambda=475,485,575,660
   *
   * Load the LMS anchor-point values for lambda = 475 & 485 nm (for
   * protans & deutans) and the LMS values for lambda = 575 & 660 nm
   * (for tritans)
   */
  anchor[0] = 0.08008;  anchor[1]  = 0.1579;    anchor[2]  = 0.5897;
  anchor[3] = 0.1284;   anchor[4]  = 0.2237;    anchor[5]  = 0.3636;
  anchor[6] = 0.9856;   anchor[7]  = 0.7325;    anchor[8]  = 0.001079;
540 541
  anchor[9] = 0.0914;   anchor[10] = 0.007009;  anchor[11] = 0.0;

542 543 544 545
  /* We also need LMS for RGB=(1,1,1)- the equal-energy point (one of
   * our anchors) (we can just peel this out of the rgb2lms transform
   * matrix)
   */
546 547 548
  anchor_e[0] = rgb2lms[0] + rgb2lms[1] + rgb2lms[2];
  anchor_e[1] = rgb2lms[3] + rgb2lms[4] + rgb2lms[5];
  anchor_e[2] = rgb2lms[6] + rgb2lms[7] + rgb2lms[8];
549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584

  switch (colorblind->deficiency)
    {
    case COLORBLIND_DEFICIENCY_DEUTERANOPIA:
      /* find a,b,c for lam=575nm and lam=475 */
      colorblind->a1 = anchor_e[1] * anchor[8] - anchor_e[2] * anchor[7];
      colorblind->b1 = anchor_e[2] * anchor[6] - anchor_e[0] * anchor[8];
      colorblind->c1 = anchor_e[0] * anchor[7] - anchor_e[1] * anchor[6];
      colorblind->a2 = anchor_e[1] * anchor[2] - anchor_e[2] * anchor[1];
      colorblind->b2 = anchor_e[2] * anchor[0] - anchor_e[0] * anchor[2];
      colorblind->c2 = anchor_e[0] * anchor[1] - anchor_e[1] * anchor[0];
      colorblind->inflection = (anchor_e[2] / anchor_e[0]);
      break;

    case COLORBLIND_DEFICIENCY_PROTANOPIA:
      /* find a,b,c for lam=575nm and lam=475 */
      colorblind->a1 = anchor_e[1] * anchor[8] - anchor_e[2] * anchor[7];
      colorblind->b1 = anchor_e[2] * anchor[6] - anchor_e[0] * anchor[8];
      colorblind->c1 = anchor_e[0] * anchor[7] - anchor_e[1] * anchor[6];
      colorblind->a2 = anchor_e[1] * anchor[2] - anchor_e[2] * anchor[1];
      colorblind->b2 = anchor_e[2] * anchor[0] - anchor_e[0] * anchor[2];
      colorblind->c2 = anchor_e[0] * anchor[1] - anchor_e[1] * anchor[0];
      colorblind->inflection = (anchor_e[2] / anchor_e[1]);
      break;

    case COLORBLIND_DEFICIENCY_TRITANOPIA:
      /* Set 1: regions where lambda_a=575, set 2: lambda_a=475 */
      colorblind->a1 = anchor_e[1] * anchor[11] - anchor_e[2] * anchor[10];
      colorblind->b1 = anchor_e[2] * anchor[9]  - anchor_e[0] * anchor[11];
      colorblind->c1 = anchor_e[0] * anchor[10] - anchor_e[1] * anchor[9];
      colorblind->a2 = anchor_e[1] * anchor[5]  - anchor_e[2] * anchor[4];
      colorblind->b2 = anchor_e[2] * anchor[3]  - anchor_e[0] * anchor[5];
      colorblind->c2 = anchor_e[0] * anchor[4]  - anchor_e[1] * anchor[3];
      colorblind->inflection = (anchor_e[1] / anchor_e[0]);
      break;
    }
585 586 587

  /* Invalidate the cache */
  memset (colorblind->cache, 0, sizeof (colorblind->cache));
588 589
}

590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608
static void
cdisplay_colorblind_set_deficiency (CdisplayColorblind   *colorblind,
                                    ColorblindDeficiency  value)
{
  if (value != colorblind->deficiency)
    {
      GEnumClass *enum_class;

      enum_class = g_type_class_peek (CDISPLAY_TYPE_COLORBLIND_DEFICIENCY);

      if (! g_enum_get_value (enum_class, value))
        return;

      colorblind->deficiency = value;

      g_object_notify (G_OBJECT (colorblind), "deficiency");
      gimp_color_display_changed (GIMP_COLOR_DISPLAY (colorblind));
    }
}