PTColorSpace

@interface PTColorSpace : NSObject

This abstract class is used to serve as a color space tag to identify the specific color space of a Color object. It contains methods that transform colors in a specific color space to/from several color space such as DeviceRGB and DeviceCMYK.

For purposes of the methods in this class, colors are represented as arrays of color components represented as doubles in a normalized range defined by each ColorSpace. For many ColorSpaces (e.g. DeviceRGB), this range is 0.0 to 1.0. However, some ColorSpaces have components whose values have a different range. Methods are provided to inquire per component minimum and maximum normalized values.

Note

Note that in Pattern color space (i.e. for ColorSpace::e_pattern) ‘color values’ are PDF::PatternColor objects instead of the numeric component values (i.e. ColorPt) used with other spaces.
  • Create a new DeviceGray ColorSpace object

    Declaration

    Objective-C

    + (PTColorSpace *)CreateDeviceGray;

    Swift

    class func createDeviceGray() -> PTColorSpace!
  • Create a new DeviceRGB ColorSpace object

    Declaration

    Objective-C

    + (PTColorSpace *)CreateDeviceRGB;

    Swift

    class func createDeviceRGB() -> PTColorSpace!
  • Create a new DeviceCMYK ColorSpace object

    Declaration

    Objective-C

    + (PTColorSpace *)CreateDeviceCMYK;

    Swift

    class func createDeviceCMYK() -> PTColorSpace!
  • Create a new Pattern ColorSpace object

    Declaration

    Objective-C

    + (PTColorSpace *)CreatePattern;

    Swift

    class func createPattern() -> PTColorSpace!
  • Create a PDF ‘ICCBased’ color space given an ICC profile

    Declaration

    Objective-C

    + (PTColorSpace *)CreateICCWithString:(PTSDFDoc *)doc
                                 filepath:(NSString *)filepath;

    Swift

    class func createICC(withString doc: PTSDFDoc!, filepath: String!) -> PTColorSpace!
  • Create a ColorSpace from the given SDF/Cos object listed under ColorSpaces entry in page Resource dictionary. If color_space dictionary is null, a non valid ColorSpace object is created.

    Declaration

    Objective-C

    - (instancetype)initWithColor_space:(PTObj *)color_space;

    Swift

    init!(color_space: PTObj!)

    Parameters

    color_space

    The Cos/SDF object to initialze the ColorSpace object with.

  • Undocumented

    Declaration

    Objective-C

    + (PTColorSpace*)CreateICCWithStream: (PTSDFDoc*)doc stm:  (PTFilter*)stm;

    Swift

    class func createICC(withStream doc: PTSDFDoc!, stm: PTFilter!) -> PTColorSpace!
  • Undocumented

    Declaration

    Objective-C

    + (PTColorSpace*)CreateICCWithBuf: (PTSDFDoc*)doc buf:  (NSData*)buf buf_sz:  (unsigned long)buf_sz;

    Swift

    class func createICC(withBuf doc: PTSDFDoc!, buf: Data!, buf_sz: UInt) -> PTColorSpace!
  • Declaration

    Objective-C

    - (PTColorSpaceType)GetType;

    Swift

    func getType() -> PTColorSpaceType

    Return Value

    The type of this color space

  • Declaration

    Objective-C

    - (PTObj *)GetSDFObj;

    Swift

    func getSDFObj() -> PTObj!

    Return Value

    the underlying SDF/Cos object

  • Declaration

    Objective-C

    - (int)GetComponentNum;

    Swift

    func getComponentNum() -> Int32

    Return Value

    The number of colorants (tint components) used to represent color point in this color space

  • Set color to the initial value used for this color space. The initial value depends on the color space (see 4.5.7 in PDF Ref. Manual).

    Declaration

    Objective-C

    - (void)InitColor:(PTColorPt *)out_colorants;

    Swift

    func initColor(_ out_colorants: PTColorPt!)

    Parameters

    out_colorants

    ColorPt object to initialize.

  • Initialize default ranges for each color component in the color space. For example, default ranges for DeviceRGB are [0 1 0 1 0 1] but for Lab the default values might be [0 100 -100 100 -100 100].

    Note

    the size of resulting vectors will match the number of color components in this color space.

    Declaration

    Objective-C

    - (void)InitComponentRanges:(NSMutableArray *)out_decode_low
               out_decode_range:(NSMutableArray *)out_decode_range;

    Swift

    func initComponentRanges(_ out_decode_low: NSMutableArray!, out_decode_range: NSMutableArray!)

    Parameters

    out_decode_low

    a vector of numbers representing the lower bound for each color component.

    out_decode_range

    a vector of numbers representing the difference between high and low bound for each color component.

  • A convenience function used to convert color points from the current color space to DeviceGray color space.

    Note

    the number to input colorants must match the number of colorants expected by the current color space.

    Declaration

    Objective-C

    - (PTColorPt *)Convert2Gray:(PTColorPt *)in_color;

    Swift

    func convert2Gray(_ in_color: PTColorPt!) -> PTColorPt!

    Parameters

    in_color

    input color point in the current color space

    out_color

    output color point in the DeviceGray color space

  • A convenience function used to convert color points from the current color space to DeviceRGB color space.

    Note

    the number to input colorants must match the number of colorants expected by the current color space.

    Declaration

    Objective-C

    - (PTColorPt *)Convert2RGB:(PTColorPt *)in_color;

    Swift

    func convert2RGB(_ in_color: PTColorPt!) -> PTColorPt!

    Parameters

    in_color

    input color point in the current color space

    out_color

    output color point in the DeviceRGB color space

  • A convenience function used to convert color points from the current color space to DeviceCMYK color space.

    Note

    the number to input colorants must match the number of colorants expected by the current color space.

    Declaration

    Objective-C

    - (PTColorPt *)Convert2CMYK:(PTColorPt *)in_color;

    Swift

    func convert2CMYK(_ in_color: PTColorPt!) -> PTColorPt!

    Parameters

    in_color

    input color point in the current color space

    out_color

    output color point in the DeviceCMYK color space

  • Declaration

    Objective-C

    - (PTColorSpace *)GetAlternateColorSpace;

    Swift

    func getAlternate() -> PTColorSpace!

    Return Value

    the alternate color space if it is available or NULL otherwise. Color spaces that include alternate color space are e_separation, e_device_n, and e_icc.

  • Declaration

    Objective-C

    - (PTColorSpace *)GetBaseColorSpace;

    Swift

    func getBase() -> PTColorSpace!

    Return Value

    the base color space if this is an e_indexed or e_pattern with associated base color space; NULL otherwise.

  • Note

    for color spaces other than Indexed this method throws an exception.

    Declaration

    Objective-C

    - (int)GetHighVal;

    Swift

    func getHighVal() -> Int32

    Return Value

    the highest index for the color lookup table for Indexed color space. Since the color table is indexed from zero to highval, the actual number of entries is highval + 1. For color spaces other than indexed the method returns 0.

  • Get the base color given a component value (index) in Indexed color space.

    Note

    for color spaces other than Indexed this method throws an exception.

    Declaration

    Objective-C

    - (PTColorPt *)GetBaseColor:(unsigned char)color_idx;

    Swift

    func getBaseColor(_ color_idx: UInt8) -> PTColorPt!

    Parameters

    color_idx

    color value represented in the index color space

    out_color

    the color represented in the base (associated) color space

  • Note

    for color spaces other than Separation or DeviceN this method throws an exception.

    Declaration

    Objective-C

    - (BOOL)IsNone;

    Swift

    func isNone() -> Bool

    Return Value

    True if Separation or DeviceN color space contains None colorants. For DeviceN the function returns true only if component colorant names are all None.

  • Note

    for color spaces other than Separation this method throws an exception.

    Declaration

    Objective-C

    - (BOOL)IsAll;

    Swift

    func isAll() -> Bool

    Return Value

    True if Separation color space contains the colorant All.

  • Note

    for color spaces other than Separation this method throws an exception.

    Declaration

    Objective-C

    - (PTFunction *)GetTintFunction;

    Swift

    func getTintFunction() -> PTFunction!

    Return Value

    the function that transforms tint values into color component values in the alternate color space.