The color class functions apply records to the InDesign® color panel.

Version :
09.11.2021, 08:27 Uhr

The color class functions apply records to the InDesign® color panel. The color can be defined using RGB, CMYK and LAB. If a color record already exists in the panel, the record remains unchanged.

The following scwatches are defined always and be addressed by their internal names. Pleae note, that you cannot change the base colors!
Internal name Swatch name
None [None]
Registration [Registration]
Black [Black]
Paper [Paper]

static int define_rgb(
  char* cname,
  int r,
  int g,
  int b,
  int type = 1,
  ItemRef createdEntry = 0)

Define a new color entry in the InDesign® color panel. If there is already an entry with this name in the panel, the request has no effect - the pre-existing color will not be changed.

Name Type Default Description
Return int   0 or Error code
cname String or char* - Name, under which the color should be applied. If the name is empty, no entry is created in the color panel. To change existing swatches, please use redefine_swatch.
r int - Red proportion of the color 0-255
g int - Green proportion of the color 0-255
b int - Blue proportion of the color 0-255
type int 1 Color type
0 Spot
1 Process
createdEntry ItemRef 0 On return it contains a reference to the used color entry. You must allocate this variable using item::alloc before!

Create the color entry 'Red' err_code = color::define_rgb ("Red", 255, 0, 0);

The color type can be defined from version 1.0.20 on. Previous versions define colors always as process colors.
createdEntry since version 1.3.4, P/R 72

priint:comet InDesign® Plug-Ins, comet_pdf

static int define(
  char* cname,
  int r,
  int g,
  int b,
  int type = 1,
  ItemRef createdEntry = 0)

Define a new color entry in the InDesign® color panel. If there is already an entry with this name in the panel, the request has no effect - the pre-existing color will not be changed.

Name Type Default Description
Return int   0 or Error code
cname String or char* - Name, under which the color should be applied. If name is empty, no entry is created in the color panel. To change existing swatches, please use redefine_swatch.
r int - Red proportion of the color 0-255
g int - Green proportion of the color 0-255
b int - Blue proportion of the color 0-255
type int 1 Color type
0 Spot
1 Process
createdEntry ItemRef 0 On return it contains a reference to the used color entry. You must allocate this variable using item::alloc before!

Create the color entry 'Red' err_code = color::define_rgb ("Red", 255, 0, 0);

The color type can be defined from version 1.0.20 on. Previous versions define colors always as process colors.

priint:comet InDesign® Plug-Ins, comet_pdf

static int define_cmyk(
  char* cname,
  float c,
  float m,
  float y,
  float k,
  int type = 1,
  ItemRef createdEntry = 0)

Define a new color entry in the InDesign® color panel. If there is already an entry with this name in the panel, the request has no effect - the pre-existing color will not be changed.

Name Type Default Description
Return int   0 or Error code
cname String or char* - Name, under which the color should be applied. If name is empty, no entry is created in the color panel. To change existing swatches, please use redefine_swatch.
c float - Cyan proportion of the color (0.0-1.0)
m float - Magenta proportion of the color (0.0-1.0)
y float - Yellow proportion of the color (0.0-1.0)
k float - Black proportion of the color (0.0-1.0)
type int 1 Color type
0 Spot
1 Process
createdEntry ItemRef 0 On return it contains a reference to the used color entry. You must allocate this variable using item::alloc before!

see define_rgb

The color type can be defined from version 1.0.20 on. Previous versions define colors always as process colors.

priint:comet InDesign® Plug-Ins, comet_pdf

static int define_lab(
  char* cname,
  float l,
  int a,
  int b,
  int type = 1,
  ItemRef createdEntry = 0)

Define a new color entry in the InDesign® color panel. If there is already an entry with this name in the panel, the request has no effect - the pre-existing color will not be changed.

Name Type Default Description
Return int   0 or Error code
cname String or char* - Name, under which the color should be applied. If name is empty, no entry is created in the color panel. To change existing swatches, please use redefine_swatch.
l float - 0.0-100.0
a int - -127 - 128
b int - -127 - 128
type int 1 Color type
0 Spot
1 Process
createdEntry ItemRef 0 On return it contains a reference to the used color entry. You must allocate this variable using item::alloc before!

The color type can be defined from version 1.0.20 on. Previous versions define colors always as process colors.

priint:comet InDesign® Plug-Ins, comet_pdf

static int count_profiles(ItemRef obj = 0, int getUsed = 1)

Get the number of available, used or embedded color profiles.

Name Type Default Description
Return int   Number of profiles found

0 : error
obj ItemRef 0 Count the profiles for this:

0 : all available color profiles
document : current/embedded profiles of the document. Use document::get_front to get a reference to the current frint document!
image frame : current/available profiles
getUsed int 1 obj == 0 : ignored

Document :
0 : embedded profiles
1 : Currently used profiles (RGB and CMYK)

Image frame :
0 : available image color profiles
1 : current image color profile

Version 3.2.2 R2384, 05.04.2010

priint:comet InDesign® Plug-Ins

document::get_front, get_nth_profile, set_profile

static int get_nth_profile(
  ItemRef obj,
  int getUsed,
  int nth,
  char* name,
  int* class_,
  int* space,
  int* source,
  char* file,
  char* fullpath)

Farbprofil-Daten ermitteln.

Name Type Default Description
Return int   0 or error code
obj ItemRef 0 Get profile information for this:

0 : all available color profiles
document : current/embedded profiles of the document. Use document::get_front to get a reference to the current frint document! image frame : current/available profiles
getUsed int 1 obj == 0 : ignored

Document :
0 : embedded profiles
1 : Currently used profiles (RGB and CMYK)

Image frame :
0 : available image color profiles
1 : current image color profile
nth int - 0-based index
Filled on successful return (all parameters may be 0):
name String or char* 0 Allocated string for the profile name
class_ int* 0 Class of profile. One of this :

0 : Unknown
1 : Printer
2 : Scanner
3 : Monitor
4 : Generic
5 : Named color
space int* 0 Color space. One of this :

0 : Unknown
1 : Gray
2 : RGB
3 : CMYK
4 : LAB
5 : XYZ
6 : HiFi2
7 : HiFi3
8 : HiFi4
9 : HiFi5
10 : HiFi6
11 : HiFi7
12 : HiFi8
source int* 0 Source type? One of this :

0 : Unknown
1 : from disk
2 : embedded in image
3 : embedded in document
4 : built in gray
5 : built in rgb
6 : built in cmyk
7 : built in lab
8 : virtuell
file String or char* 0 Allocated string for the profile file path
fullpath String or char* 0 Allocated string for the profile file path

Get all available color profiles.

int main ()
{
    char	cname [2000];
    char	cfile	[2000];
    char	cpath	[2000];
    int		cclass;
    int		cspace;
    int		csource;
    int		profiles	= color::count_profiles (0, 1);
    int		i;
for (i = 0; i < profiles; i++) { color::get_nth_profile (0, 1, i, cname, &cclass, &cspace, &csource, cfile, cpath); wlog ("", "Color profile %d\t: %d %d '%s' '%s'\n", i, cclass, cspace, cname, cfile); }
return 0; }

Get a documents color profiles.

int main ()
{
    ItemRef	docref	= document::get_front ();
    char	cname [2000];
    char	cfile	[2000];
    char	cpath	[2000];
    int		cclass;
    int		cspace;
    int		csource;
    int		profiles;
    int		i;
wlog ("", "Used profiles\n"); profiles = color::count_profiles (docref, 1); for (i = 0; i < profiles; i++) { color::get_nth_profile (docref, 1, i, cname, &cclass, &cspace, &csource, cfile, cpath); wlog ("", "Color profile %d\t: %d %d '%s'\n", i, cclass, cspace, cname); }
wlog ("", "Embedded profiles\n"); profiles = color::count_profiles (docref, 0); for (i = 0; i < profiles; i++) { color::get_nth_profile (docref, 0, i, cname, &cclass, &cspace, &csource, cfile, cpath); wlog ("", "Color profile %d\t: %d %d '%s'\n", i, cclass, cspace, cname); } }

Get the profiles of an image.

int main ()
{
    char		cname [2000];
    char		cfile	[2000];
    char		cpath	 [2000];
    int		cclass;
    int		cspace;
    int		csource;
    int		profiles;
    int		i;
    wlog ("", "Current color profile\n");
    profiles	= color::count_profiles (gFrame, 1);
    for (i = 0; i < profiles; i++)
    {
        color::get_nth_profile (gFrame, 1, i, cname, &cclass, &cspace, &csource, cfile, cpath);
        wlog ("", "Color profile %d\t: %d %d '%s'\n", i, cclass, cspace, cname);
    }
wlog ("", "Available color profiles\n"); profiles = color::count_profiles (gFrame, 0); for (i = 0; i < profiles; i++) { color::get_nth_profile (gFrame, 0, i, cname, &cclass, &cspace, &csource, cfile, cpath); wlog ("", "Color profile %d\t: %d %d '%s'\n", i, cclass, cspace, cname); }
return 0; }

Version 3.2.2 R2384, 05.04.2010

priint:comet InDesign® Plug-Ins

document::get_front, count_profiles, set_profile

static int set_profile(
  ItemRef obj,
  char* profileName,
  int space,
  int renderPrio = -1,
  int imageRenderPrio = -1,
  int postTransparenzPrio = -1)

Set color profile and rendering values for documents and images. You may change the following values :

Name Type Default Description
Return int   0 or error code
obj ItemRef - Document or image frame
profileName String or char* - Valid color profile name (in case of documents you can only use RGB and CMYK profiles!)

"ignore" : do not change color profile
space int - Color space. Unused for image frames, otherwise

0 : RGB
1 : CMYK
renderPrio int -1 0 : Perceptual (Images)
1 : Saturation (Graphics)
2 : Relative Colorimetric
3 : Absolute Colorimetric
20 : Use color settings intent/Use Document Image Intent
imageRenderPrio int -1 0 : Perceptual (Images)
1 : Saturation (Graphics)
2 : Relative Colorimetric
3 : Absolute Colorimetric
20 : Use color settings intent/Use Document Image Intent
postTransparenzPrio int -1 0 : Perceptual (Images)
1 : Saturation (Graphics)
2 : Relative Colorimetric
3 : Absolute Colorimetric
20 : Use color settings intent/Use Document Image Intent

Change a documents color profile setting :

int main ()
{
    ItemRef	docref	= document::get_front ();
    int res;
res = color::set_profile (docref, "Display", 0); res = color::set_profile (docref, "Euroscale Coated v2", 1, 1, 2, 3);
return 0; }

Change the color profile for an image.

int main ()
{
    color::set_profile (gFrame, "CIE RGB", 0, 3);
    return 0;
}

Version 3.2.2 R2384, 05.04.2010

priint:comet InDesign® Plug-Ins

document::get_front, count_profiles, get_nth_profile

static int count_swatches(ItemRef docRef)

Number of visible color swatches of o document.

Name Type Default Description
Return int   Number of visible color swatches of o document.

0 : error
docRef ItemRef - Document
0 : current front document

#include "internal/types.h"
		
#include "internal/types.h"
int main () { int i; int space; int type; char name [512]; float colors [4];
wlog ("", "--------------- Swatches of current document ---------------\n"); for (i = 0; i < color::count_swatches (0); i++) { strcpy (name, color::get_nth_swatch (0, i)); space = color::get_space (0, name); type = color::get_type (0, name); color::get_colors (0, name, colors, colors+1, colors+2, colors+3);
wlog ("", "%d : %s\n", i, name); if (space == kColorTypeRGB) wlog ("", "\t ColSpace : RGB\n"); else if (space == kColorTypeCMYK) wlog ("", "\t ColSpace : CMYK\n"); else if (space == kColorTypeLAB) wlog ("", "\t ColSpace : Lab\n"); else wlog ("", "\t ColSpace : %d\n", color::get_space (0, name));
wlog ("", "\t Spot : %d\n", color::is_spot (0, name)); wlog ("", "\t Locked : %d\n", color::is_locked (0, name)); wlog ("", "\t Reserv : %d\n", color::is_reserved (0, name));
if (type == kSwatchTypeBaseColor) wlog ("", "\t Type : Base color\n"); else if (type == kSwatchTypeTintColor) wlog ("", "\t Type : Tint color\n"); else if (type == kSwatchTypeGradient) wlog ("", "\t Type : Gradient\n"); else wlog ("", "\t Type : %d\n", type);
wlog ("", "\t Cols : %f, %f, %f, %f\n", colors[0], colors[1], colors[2], colors[3]); }
return 0; }

v3.4 R6000, 20. Oct. 2014

priint:comet InDesign® Plug-Ins, comet_pdf

static char* get_nth_swatch(ItemRef docRef, int n)

Name of n-th visible swatch of a given document.

Name Type Default Description
Return char*   Name of n-th visible swatch of a given document
0 : error

The return value is read only, do NOT CHANGE. The result will be overridden on following calls to the function. Learn more about functions returning r/o char* values.

docRef ItemRef - Document
0 : current front document
n int - 0-based index of the swatch

v3.4 R6000, 20. Oct. 2014

priint:comet InDesign® Plug-Ins, comet_pdf

count_swatches

static int get_space(ItemRef docRef, char* swatchName)

Color space of a swatch.

Name Type Default Description
Return int   kColorTypeInvalid : error
kColorTypeFromDisk
kColorTypeEmbeddedInImage
kColorTypeEmbeddedInDocument
kColorTypeGray
kColorTypeRGB : RGB swatch
kColorTypeCMYK : CMYK swatch
kColorTypeLAB : Lab swatch
kColorTypeVirtual
docRef ItemRef - Document
0 : current front document
swatchName String or char* - Name of visible swatch or base color.

#include "internal/types.h"

v3.4 R6000, 20. Oct. 2014

priint:comet InDesign® Plug-Ins, comet_pdf

count_swatches, get_nth_swatch

static float get_tint(ItemRef docRef, char* swatchName)

Tint of a swatch.

Name Type Default Description
Return int   0.0 - 1.0

comet_pdf : Always 1.0
docRef ItemRef - Document
0 : current front document
swatchName String or char* - Name of visible swatch or base color

v3.4 R6000, 20. Oct. 2014

priint:comet InDesign® Plug-Ins, comet_pdf

count_swatches, get_nth_swatch

static int get_colors(
  ItemRef docRef,
  char* swatchName,
  float & c1,
  float & c2,
  float & c3,
  float & c4)

Color values of a swatch.

Name Type Default Description
Return int   0 or error code
docRef ItemRef - Document
0 : current front document
swatchName String oder char* - Name of visible swatch or base color
c1, c1, c3, c4 float*, float*, float*, float* -, -, -, - Color values

0.0 - 255.0 : RGB. Only c1, c2, c3 are used.

0.0 - 1.0 : CMYK

0.0-100, -127.0-128, -127-128.0 : Lab. Only c1, c2, c3 are used.

all values < 0.0 : Color [None]

Please take care, ALL the parameters are float pointers!

v3.4 R6000, 20. Oct. 2014

priint:comet InDesign® Plug-Ins, comet_pdf

count_swatches, get_nth_swatch

static int is_spot(ItemRef docRef, char* swatchName)

Is a given swatch a process color?

Name Type Default Description
Return int   0 : No
1 : Yes, process color
docRef ItemRef - Document
0 : current front document
swatchName String or char* - Name of visible swatch or base color

v3.4 R6000, 20. Oct. 2014

priint:comet InDesign® Plug-Ins, comet_pdf

count_swatches, get_nth_swatch

static int is_locked(ItemRef docRef, char* swatchName)

Is a given swatch locked?

Name Type Default Description
Return int   0 : No
1 : Yes, locked

comet_pdf : Immer 0
docRef ItemRef - Document
0 : current front document
swatchName String or char* - Name of visible swatch or base color

v3.4 R6000, 20. Oct. 2014

priint:comet InDesign® Plug-Ins, comet_pdf

count_swatches, get_nth_swatch

static int is_reserved(ItemRef docRef, char* swatchName)

Is a given swatch reserved by InDesign®?

Name Type Default Description
Return int   0 : No
1 : Yes, reserved

comet_pdf : Immer 0
docRef ItemRef - Document
0 : current front document
swatchName String or char* - Name of visible swatch or base color

v3.4 R6000, 20. Oct. 2014

priint:comet InDesign® Plug-Ins, comet_pdf

count_swatches, get_nth_swatch

static int get_type(ItemRef docRef, char* swatchName)

Get the type of a swatch.

Name Type Default Description
Return int   kSwatchTypeNone : error
kSwatchTypeBaseColor standard swatch
kSwatchTypeTintColor
kSwatchTypeMixedInkColor
kSwatchTypeLinkedMixedInkColor
kSwatchTypeMixedInkParent
kSwatchTypeGradient
kSwatchTypeBlackBoxPaint
kSwatchTypeOther
docRef ItemRef - Document
0 : current front document
swatchName String or char* - Name of visible swatch or base color

#include "internal/types.h"

v3.4 R6000, 20. Oct. 2014

priint:comet InDesign® Plug-Ins, comet_pdf

count_swatches, get_nth_swatch

static int redefine_swatch(
  ItemRef docRef,
  char* swatchName,
  int targetSpace,
  float c1,
  float c2,
  float c3,
  float c4,
  int is_process = 1)

Change the defintion of swatches of type kSwatchTypeBaseColor. Please take care not to change reserved swatches. This may cause serious errors!

Name Type Default Description
Return int   0 or error code
docRef ItemRef - Document
0 : current front document
swatchName String or char* - Name of visible swatch. The function cannot change the base colors.
targetSpace int - Color space of color values c1-c4. The folllowing values are possible:

kColorTypeRGB
kColorTypeCMYK
kColorTypeLAB
c1, c1, c3, c4 float, float, float, float -, -, -, - New color values

0.0 - 255.0 : RGB. Only c1, c2, c3 are used.

0.0 - 1.0 : CMYK

0.0-100, -127.0-128, -127-128.0 : Lab. Only c1, c2, c3 are used.
is_process int - Define as normal process color or as spot color?

1 : Normal process color
0 : Spot color

#include "internal/types.h"
color::redefine_swatch (0, "Rot", kColorTypeRGB, 255.0, (float)123, 77.77, 0.0);

v3.4 R6000, 20. Oct. 2014

priint:comet InDesign® Plug-Ins, comet_pdf

count_swatches, get_nth_swatch

This class has no child classes.

Author
Paul Seidel
Version
09.11.2021, 08:27 Uhr
Since
Plugin Version 1.0.10

Alphabetic index HTML hierarchy of classes or Java