lab.h 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. /*************************************************************************
  2. * Copyright (c) 2014 AT&T Intellectual Property
  3. * All rights reserved. This program and the accompanying materials
  4. * are made available under the terms of the Eclipse Public License v1.0
  5. * which accompanies this distribution, and is available at
  6. * https://www.eclipse.org/legal/epl-v10.html
  7. *
  8. * Contributors: Details at https://graphviz.org
  9. *************************************************************************/
  10. #pragma once
  11. struct rgb_struct {
  12. double r, g, b;/* 0 to 255 */
  13. };
  14. typedef struct rgb_struct color_rgb;
  15. struct xyz_struct {
  16. double x, y, z;
  17. };
  18. typedef struct xyz_struct color_xyz;
  19. struct lab_struct {
  20. double l, a, b; ///< l: 0 to 100, a,b: -128 to 128
  21. };
  22. typedef struct lab_struct color_lab;
  23. color_xyz RGB2XYZ(color_rgb color);
  24. color_rgb XYZ2RGB(color_xyz color);
  25. color_lab RGB2LAB(color_rgb color);
  26. void LAB2RGB_real_01(double *color); /* convert an array[3] of LAB colors to RGB between 0 to 1, in place */
  27. color_rgb LAB2RGB(color_lab color);
  28. color_rgb color_rgb_init(double r, double g, double b);
  29. color_xyz color_xyz_init(double x, double y, double z);
  30. color_lab color_lab_init(double l, double a, double b);
  31. QuadTree lab_gamut_quadtree(
  32. const int *lightness,
  33. int max_qtree_level); ///< construct a quadtree of the LAB gamut points
  34. double *lab_gamut(const int *lightness,
  35. int *n); ///< give a list of n points in the file defining
  36. ///< the LAB color gamut
  37. /** derive around maxpoints from a color list
  38. *
  39. * \param color_list List of the form "#ff0000,#00ff00,..."
  40. * \param maxpoints Maximum number of points to return
  41. * \return An array of size [maxpoints*3] of the form {{l,a,b},...}
  42. */
  43. double *color_blend_rgb2lab(const char *color_list, const int maxpoints);