lcms2

package module
v0.0.0-...-f6af7cf Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 27, 2026 License: MIT Imports: 12 Imported by: 0

README

golittlecms

A pure-Go port of Little-CMS (lcms2), the ICC-based colour-management engine. It reads and writes ICC profiles, builds colour transforms between them, and applies those transforms to pixel buffers — matching the C library's results bit-for-bit on the integer paths.

import "github.com/mgilbir/golittlecms"

Why

  • Pure Go, standard library only. No cgo, no third-party modules, no assembly. It builds and cross-compiles like any Go package.
  • Never panics. Every failure — including malformed, untrusted profiles — is returned as an error, never a panic. The profile, tag, and IT8 parsers are fuzz-tested for this.
  • Faithful to lcms2 2.19. Algorithms, tables, and rounding are ported from the reference (pinned at commit e2c0840), which is also used as a differential-testing oracle. Integer transform and profile-I/O paths are bit-exact; float paths match within the reference testbed's tolerances.

Status

Feature-complete against the lcms2 core public API: profile I/O for every ICC tag type (with byte-identical serialization and MD5 profile IDs), tone curves, interpolation, pipelines, the transform engine (all intents, optimized fast paths, soft-proofing, gamut check, alpha), virtual profiles, CIECAM02, IT8.7/CGATS, PostScript CSA/CRD generation, and the .cube device-link reader.

The optional lcms2 plugins (fast_float, threaded, GPU) are GPL-3.0, a different licence from the MIT core, and are deliberately not ported so this library can stay MIT. The built-in optimizer already provides the matrix-shaper and CLUT fast paths, and transforms are safe to drive from multiple goroutines if you need parallelism.

Usage

Transform pixels between two profiles
package main

import (
	"fmt"

	lcms2 "github.com/mgilbir/golittlecms"
)

func main() {
	in, err := lcms2.Create_sRGBProfile()
	if err != nil {
		panic(err)
	}
	out, err := lcms2.OpenProfileFromFile("USWebCoatedSWOP.icc", "r")
	if err != nil {
		panic(err)
	}

	xform, err := lcms2.CreateTransform(
		in, lcms2.TypeRGB8,
		out, lcms2.TypeCMYK8,
		lcms2.IntentPerceptual, 0,
	)
	if err != nil {
		panic(err)
	}

	rgb := []byte{255, 128, 0} // one pixel
	cmyk := make([]byte, 4)
	xform.DoTransform(rgb, cmyk, 1)
	fmt.Println(cmyk)
}

A *Transform is safe for concurrent DoTransform calls, so you can split a large image across goroutines. Profiles are opened from a file (OpenProfileFromFile), from memory (OpenProfileFromMem), or created as virtual profiles (Create_sRGBProfile, CreateLab4Profile, CreateXYZProfile, CreateGrayProfile, …).

Pixel formats

Refer to a format by name, or compose one with the *SH builders (same encoding as the C TYPE_* macros and *_SH bitfields):

lcms2.TypeRGB8    // 8-bit RGB
lcms2.TypeRGBA8   // 8-bit RGB + alpha
lcms2.TypeCMYK16  // 16-bit CMYK
lcms2.TypeLab16   // 16-bit CIELab
lcms2.TypeRGBFlt  // 32-bit float RGB

// Custom: 16-bit, 3-channel RGB with one extra (alpha) channel
custom := lcms2.ColorspaceSH(lcms2.PTRGB) | lcms2.ExtraSH(1) |
	lcms2.ChannelsSH(3) | lcms2.BytesSH(2)

Use lcms2.FlagsCopyAlpha to carry extra channels through, and lcms2.FlagsBlackPointCompensation, lcms2.FlagsSoftProofing, lcms2.FlagsGamutCheck, etc. as the transform flags argument.

Errors

All fallible calls return a plain error. Recover the library's error class with errors.As:

_, err := lcms2.OpenProfileFromMem(data)
var e *lcms2.Error
if errors.As(err, &e) && e.Code == lcms2.ErrBadSignature {
	// not an ICC profile
}

More runnable examples live alongside the code as Go Example functions (see go doc).

Testing

go test ./... runs the unit tests and replays committed golden vectors, so it passes without any C toolchain. For differential testing against the reference, build the oracle harness once:

scripts/build-oracle.sh   # fetches the pinned lcms2 and builds bin/lcms2_oracle
go test ./...             # differential tests now run live; they skip if absent
Fuzzing

The fuzz targets cover the parsers of untrusted input and the public entry points that take adversarial scalar arguments:

  • ProfilesFuzzOpenProfileFromMem (header, tag table, raw tag reads).
  • Tag-type decodersFuzzAllTagTypeDecoders drives all 36 registered built-in decoders generically, and eleven of them also have dedicated targets with type-specific seeds: FuzzTypeCurveRead, FuzzTypeMLURead, FuzzTypeTextDescriptionRead, FuzzTypeNamedColor2Read, FuzzDictRead, FuzzTypeLUT8Read, FuzzTypeLUT16Read, FuzzTypeLUTA2BRead, FuzzTypeLUTB2ARead, FuzzTypeMPERead, FuzzPipelineCLut.
  • Other file formatsFuzzIT8LoadFromMem (IT8/CGATS), FuzzParseCube (.cube LUTs), FuzzGDBSectors (gamut-boundary descriptors).
  • Transforms and pixel formatsFuzzTransformFromProfiles (builds a transform from two fuzzed profiles), FuzzDoTransform, FuzzOptimizedDoTransform, FuzzFormatters, FuzzGetPostScriptCSA.
  • ConstructorsFuzzToneCurveConstructors, FuzzStageConstructors (adversarial entry counts, segment parameters, channel counts, grid sizes).

The invariant every target checks is the same: no panic and no unbounded allocation, however malformed the input — failures must come back as an *lcms2.Error.

go test -fuzz only accepts a pattern that matches exactly one target, so name one at a time:

go test -run '^$' -fuzz '^FuzzOpenProfileFromMem$' -fuzztime 60s

To sweep them all, loop over the list:

for t in $(go test -list '^Fuzz' ./... | grep '^Fuzz'); do
  go test -run '^$' -fuzz "^$t\$" -fuzztime 60s || break
done

Inputs that fail are written to testdata/fuzz/<Target>/ and are committed as regression cases; plain go test ./... replays them as ordinary seeds.

Licence

MIT. This is a derivative work of Little-CMS and retains its copyright notice; see LICENSE. The GPL-3.0 lcms2 plugins are not included.

Documentation

Overview

Package lcms2 is a pure-Go port of Little-CMS 2 (https://github.com/mm2/Little-CMS), the ICC-based colour-management engine. It reads and writes ICC profiles, builds colour transforms between them, and applies those transforms to pixel buffers.

The port targets the lcms2 2.19 core public API and uses the reference C implementation as a differential-testing oracle. It depends only on the Go standard library — no cgo, no third-party modules — and never panics: every failure, including malformed or untrusted input, is returned as an error (see Error). Integer transform and profile-I/O paths are bit-exact with the C library; floating-point paths match within the reference testbed tolerances.

Transforms

Open or create two profiles, build a Transform between them for a given pixel format and rendering intent, then apply it:

in, _ := lcms2.Create_sRGBProfile()
out, _ := lcms2.OpenProfileFromFile("USWebCoatedSWOP.icc", "r")
xform, err := lcms2.CreateTransform(
	in, lcms2.TypeRGB8,
	out, lcms2.TypeCMYK8,
	lcms2.IntentPerceptual, 0)
if err != nil {
	// handle error
}
xform.DoTransform(rgb, cmyk, nPixels)

A Transform is safe for concurrent DoTransform calls, so a large image can be split across goroutines.

Pixel formats

Pixel formats are uint32 values encoded exactly as the C TYPE_* macros. Use a named constant such as TypeRGB8, TypeCMYK16, or TypeRGBFlt, or compose one with the bitfield builders, for example ColorspaceSH(PTRGB) | ChannelsSH(3) | BytesSH(2).

Scope

The core library is covered: profile I/O for every ICC tag type, tone curves, interpolation, pipelines, the transform engine (all intents, optimization, soft-proofing, gamut check, alpha), virtual profiles, CIECAM02, IT8.7/CGATS, PostScript CSA/CRD generation, and the .cube device-link reader. The GPL-3.0 lcms2 plugins (fast_float, threaded, GPU) are not included, keeping this library MIT-licensed.

Index

Examples

Constants

View Source
const (
	AvgSurround      = 1 // AVG_SURROUND
	DimSurround      = 2 // DIM_SURROUND
	DarkSurround     = 3 // DARK_SURROUND
	CutsheetSurround = 4 // CUTSHEET_SURROUND

	// DCalculate signals cmsCIECAM02Init to compute D from the luminance
	// (D_CALCULATE == -1).
	DCalculate = -1.0
)

Surround constants (lcms2.h): AVG/DIM/DARK/CUTSHEET.

View Source
const (
	IntentPreserveKOnlyPerceptual            uint32 = 10
	IntentPreserveKOnlyRelativeColorimetric  uint32 = 11
	IntentPreserveKOnlySaturation            uint32 = 12
	IntentPreserveKPlanePerceptual           uint32 = 13
	IntentPreserveKPlaneRelativeColorimetric uint32 = 14
	IntentPreserveKPlaneSaturation           uint32 = 15
)

Non-ICC black-preserving rendering intents, mirroring the INTENT_PRESERVE_* macros in include/lcms2.h.

View Source
const (
	TypeGray8           uint32 = 196617   // TYPE_GRAY_8
	TypeGray8Rev        uint32 = 204809   // TYPE_GRAY_8_REV
	TypeGray16          uint32 = 196618   // TYPE_GRAY_16
	TypeGray16Rev       uint32 = 204810   // TYPE_GRAY_16_REV
	TypeGray16SE        uint32 = 198666   // TYPE_GRAY_16_SE
	TypeGRAYA8          uint32 = 196745   // TYPE_GRAYA_8
	TypeGRAYA8Premul    uint32 = 8585353  // TYPE_GRAYA_8_PREMUL
	TypeGRAYA16         uint32 = 196746   // TYPE_GRAYA_16
	TypeGRAYA16Premul   uint32 = 8585354  // TYPE_GRAYA_16_PREMUL
	TypeGRAYA16SE       uint32 = 198794   // TYPE_GRAYA_16_SE
	TypeGRAYA8Planar    uint32 = 200841   // TYPE_GRAYA_8_PLANAR
	TypeGRAYA16Planar   uint32 = 200842   // TYPE_GRAYA_16_PLANAR
	TypeRGB8            uint32 = 262169   // TYPE_RGB_8
	TypeRGB8Planar      uint32 = 266265   // TYPE_RGB_8_PLANAR
	TypeBGR8            uint32 = 263193   // TYPE_BGR_8
	TypeBGR8Planar      uint32 = 267289   // TYPE_BGR_8_PLANAR
	TypeRGB16           uint32 = 262170   // TYPE_RGB_16
	TypeRGB16Planar     uint32 = 266266   // TYPE_RGB_16_PLANAR
	TypeRGB16SE         uint32 = 264218   // TYPE_RGB_16_SE
	TypeBGR16           uint32 = 263194   // TYPE_BGR_16
	TypeBGR16Planar     uint32 = 267290   // TYPE_BGR_16_PLANAR
	TypeBGR16SE         uint32 = 265242   // TYPE_BGR_16_SE
	TypeRGBA8           uint32 = 262297   // TYPE_RGBA_8
	TypeRGBA8Premul     uint32 = 8650905  // TYPE_RGBA_8_PREMUL
	TypeRGBA8Planar     uint32 = 266393   // TYPE_RGBA_8_PLANAR
	TypeRGBA16          uint32 = 262298   // TYPE_RGBA_16
	TypeRGBA16Premul    uint32 = 8650906  // TYPE_RGBA_16_PREMUL
	TypeRGBA16Planar    uint32 = 266394   // TYPE_RGBA_16_PLANAR
	TypeRGBA16SE        uint32 = 264346   // TYPE_RGBA_16_SE
	TypeARGB8           uint32 = 278681   // TYPE_ARGB_8
	TypeARGB8Premul     uint32 = 8667289  // TYPE_ARGB_8_PREMUL
	TypeARGB8Planar     uint32 = 282777   // TYPE_ARGB_8_PLANAR
	TypeARGB16          uint32 = 278682   // TYPE_ARGB_16
	TypeARGB16Premul    uint32 = 8667290  // TYPE_ARGB_16_PREMUL
	TypeABGR8           uint32 = 263321   // TYPE_ABGR_8
	TypeABGR8Premul     uint32 = 8651929  // TYPE_ABGR_8_PREMUL
	TypeABGR8Planar     uint32 = 267417   // TYPE_ABGR_8_PLANAR
	TypeABGR16          uint32 = 263322   // TYPE_ABGR_16
	TypeABGR16Premul    uint32 = 8651930  // TYPE_ABGR_16_PREMUL
	TypeABGR16Planar    uint32 = 267418   // TYPE_ABGR_16_PLANAR
	TypeABGR16SE        uint32 = 265370   // TYPE_ABGR_16_SE
	TypeBGRA8           uint32 = 279705   // TYPE_BGRA_8
	TypeBGRA8Premul     uint32 = 8668313  // TYPE_BGRA_8_PREMUL
	TypeBGRA8Planar     uint32 = 283801   // TYPE_BGRA_8_PLANAR
	TypeBGRA16          uint32 = 279706   // TYPE_BGRA_16
	TypeBGRA16Premul    uint32 = 8668314  // TYPE_BGRA_16_PREMUL
	TypeBGRA16SE        uint32 = 281754   // TYPE_BGRA_16_SE
	TypeCMY8            uint32 = 327705   // TYPE_CMY_8
	TypeCMY8Planar      uint32 = 331801   // TYPE_CMY_8_PLANAR
	TypeCMY16           uint32 = 327706   // TYPE_CMY_16
	TypeCMY16Planar     uint32 = 331802   // TYPE_CMY_16_PLANAR
	TypeCMY16SE         uint32 = 329754   // TYPE_CMY_16_SE
	TypeCMYK8           uint32 = 393249   // TYPE_CMYK_8
	TypeCMYKA8          uint32 = 393377   // TYPE_CMYKA_8
	TypeCMYK8Rev        uint32 = 401441   // TYPE_CMYK_8_REV
	TypeYUVK8           uint32 = 401441   // TYPE_YUVK_8
	TypeCMYK8Planar     uint32 = 397345   // TYPE_CMYK_8_PLANAR
	TypeCMYK16          uint32 = 393250   // TYPE_CMYK_16
	TypeCMYK16Rev       uint32 = 401442   // TYPE_CMYK_16_REV
	TypeYUVK16          uint32 = 401442   // TYPE_YUVK_16
	TypeCMYK16Planar    uint32 = 397346   // TYPE_CMYK_16_PLANAR
	TypeCMYK16SE        uint32 = 395298   // TYPE_CMYK_16_SE
	TypeKYMC8           uint32 = 394273   // TYPE_KYMC_8
	TypeKYMC16          uint32 = 394274   // TYPE_KYMC_16
	TypeKYMC16SE        uint32 = 396322   // TYPE_KYMC_16_SE
	TypeKCMY8           uint32 = 409633   // TYPE_KCMY_8
	TypeKCMY8Rev        uint32 = 417825   // TYPE_KCMY_8_REV
	TypeKCMY16          uint32 = 409634   // TYPE_KCMY_16
	TypeKCMY16Rev       uint32 = 417826   // TYPE_KCMY_16_REV
	TypeKCMY16SE        uint32 = 411682   // TYPE_KCMY_16_SE
	TypeCMYK58          uint32 = 1245225  // TYPE_CMYK5_8
	TypeCMYK516         uint32 = 1245226  // TYPE_CMYK5_16
	TypeCMYK516SE       uint32 = 1247274  // TYPE_CMYK5_16_SE
	TypeKYMC58          uint32 = 1246249  // TYPE_KYMC5_8
	TypeKYMC516         uint32 = 1246250  // TYPE_KYMC5_16
	TypeKYMC516SE       uint32 = 1248298  // TYPE_KYMC5_16_SE
	TypeCMYK68          uint32 = 1310769  // TYPE_CMYK6_8
	TypeCMYK68Planar    uint32 = 1314865  // TYPE_CMYK6_8_PLANAR
	TypeCMYK616         uint32 = 1310770  // TYPE_CMYK6_16
	TypeCMYK616Planar   uint32 = 1314866  // TYPE_CMYK6_16_PLANAR
	TypeCMYK616SE       uint32 = 1312818  // TYPE_CMYK6_16_SE
	TypeCMYK78          uint32 = 1376313  // TYPE_CMYK7_8
	TypeCMYK716         uint32 = 1376314  // TYPE_CMYK7_16
	TypeCMYK716SE       uint32 = 1378362  // TYPE_CMYK7_16_SE
	TypeKYMC78          uint32 = 1377337  // TYPE_KYMC7_8
	TypeKYMC716         uint32 = 1377338  // TYPE_KYMC7_16
	TypeKYMC716SE       uint32 = 1379386  // TYPE_KYMC7_16_SE
	TypeCMYK88          uint32 = 1441857  // TYPE_CMYK8_8
	TypeCMYK816         uint32 = 1441858  // TYPE_CMYK8_16
	TypeCMYK816SE       uint32 = 1443906  // TYPE_CMYK8_16_SE
	TypeKYMC88          uint32 = 1442881  // TYPE_KYMC8_8
	TypeKYMC816         uint32 = 1442882  // TYPE_KYMC8_16
	TypeKYMC816SE       uint32 = 1444930  // TYPE_KYMC8_16_SE
	TypeCMYK98          uint32 = 1507401  // TYPE_CMYK9_8
	TypeCMYK916         uint32 = 1507402  // TYPE_CMYK9_16
	TypeCMYK916SE       uint32 = 1509450  // TYPE_CMYK9_16_SE
	TypeKYMC98          uint32 = 1508425  // TYPE_KYMC9_8
	TypeKYMC916         uint32 = 1508426  // TYPE_KYMC9_16
	TypeKYMC916SE       uint32 = 1510474  // TYPE_KYMC9_16_SE
	TypeCMYK108         uint32 = 1572945  // TYPE_CMYK10_8
	TypeCMYK1016        uint32 = 1572946  // TYPE_CMYK10_16
	TypeCMYK1016SE      uint32 = 1574994  // TYPE_CMYK10_16_SE
	TypeKYMC108         uint32 = 1573969  // TYPE_KYMC10_8
	TypeKYMC1016        uint32 = 1573970  // TYPE_KYMC10_16
	TypeKYMC1016SE      uint32 = 1576018  // TYPE_KYMC10_16_SE
	TypeCMYK118         uint32 = 1638489  // TYPE_CMYK11_8
	TypeCMYK1116        uint32 = 1638490  // TYPE_CMYK11_16
	TypeCMYK1116SE      uint32 = 1640538  // TYPE_CMYK11_16_SE
	TypeKYMC118         uint32 = 1639513  // TYPE_KYMC11_8
	TypeKYMC1116        uint32 = 1639514  // TYPE_KYMC11_16
	TypeKYMC1116SE      uint32 = 1641562  // TYPE_KYMC11_16_SE
	TypeCMYK128         uint32 = 1704033  // TYPE_CMYK12_8
	TypeCMYK1216        uint32 = 1704034  // TYPE_CMYK12_16
	TypeCMYK1216SE      uint32 = 1706082  // TYPE_CMYK12_16_SE
	TypeKYMC128         uint32 = 1705057  // TYPE_KYMC12_8
	TypeKYMC1216        uint32 = 1705058  // TYPE_KYMC12_16
	TypeKYMC1216SE      uint32 = 1707106  // TYPE_KYMC12_16_SE
	TypeXYZ16           uint32 = 589850   // TYPE_XYZ_16
	TypeLab8            uint32 = 655385   // TYPE_Lab_8
	TypeLabV28          uint32 = 1966105  // TYPE_LabV2_8
	TypeALab8           uint32 = 671897   // TYPE_ALab_8
	TypeALabV28         uint32 = 1982617  // TYPE_ALabV2_8
	TypeLab16           uint32 = 655386   // TYPE_Lab_16
	TypeLabV216         uint32 = 1966106  // TYPE_LabV2_16
	TypeYxy16           uint32 = 917530   // TYPE_Yxy_16
	TypeYCbCr8          uint32 = 458777   // TYPE_YCbCr_8
	TypeYCbCr8Planar    uint32 = 462873   // TYPE_YCbCr_8_PLANAR
	TypeYCbCr16         uint32 = 458778   // TYPE_YCbCr_16
	TypeYCbCr16Planar   uint32 = 462874   // TYPE_YCbCr_16_PLANAR
	TypeYCbCr16SE       uint32 = 460826   // TYPE_YCbCr_16_SE
	TypeYUV8            uint32 = 524313   // TYPE_YUV_8
	TypeYUV8Planar      uint32 = 528409   // TYPE_YUV_8_PLANAR
	TypeYUV16           uint32 = 524314   // TYPE_YUV_16
	TypeYUV16Planar     uint32 = 528410   // TYPE_YUV_16_PLANAR
	TypeYUV16SE         uint32 = 526362   // TYPE_YUV_16_SE
	TypeHLS8            uint32 = 851993   // TYPE_HLS_8
	TypeHLS8Planar      uint32 = 856089   // TYPE_HLS_8_PLANAR
	TypeHLS16           uint32 = 851994   // TYPE_HLS_16
	TypeHLS16Planar     uint32 = 856090   // TYPE_HLS_16_PLANAR
	TypeHLS16SE         uint32 = 854042   // TYPE_HLS_16_SE
	TypeHSV8            uint32 = 786457   // TYPE_HSV_8
	TypeHSV8Planar      uint32 = 790553   // TYPE_HSV_8_PLANAR
	TypeHSV16           uint32 = 786458   // TYPE_HSV_16
	TypeHSV16Planar     uint32 = 790554   // TYPE_HSV_16_PLANAR
	TypeHSV16SE         uint32 = 788506   // TYPE_HSV_16_SE
	TypeNAMEDCOLORINDEX uint32 = 10       // TYPE_NAMED_COLOR_INDEX
	TypeXYZFlt          uint32 = 4784156  // TYPE_XYZ_FLT
	TypeLabFlt          uint32 = 4849692  // TYPE_Lab_FLT
	TypeLabAFlt         uint32 = 4849820  // TYPE_LabA_FLT
	TypeGrayFlt         uint32 = 4390924  // TYPE_GRAY_FLT
	TypeGRAYAFlt        uint32 = 4391052  // TYPE_GRAYA_FLT
	TypeGRAYAFltPremul  uint32 = 12779660 // TYPE_GRAYA_FLT_PREMUL
	TypeRGBFlt          uint32 = 4456476  // TYPE_RGB_FLT
	TypeRGBAFlt         uint32 = 4456604  // TYPE_RGBA_FLT
	TypeRGBAFltPremul   uint32 = 12845212 // TYPE_RGBA_FLT_PREMUL
	TypeARGBFlt         uint32 = 4472988  // TYPE_ARGB_FLT
	TypeARGBFltPremul   uint32 = 12861596 // TYPE_ARGB_FLT_PREMUL
	TypeBGRFlt          uint32 = 4457500  // TYPE_BGR_FLT
	TypeBGRAFlt         uint32 = 4474012  // TYPE_BGRA_FLT
	TypeBGRAFltPremul   uint32 = 12862620 // TYPE_BGRA_FLT_PREMUL
	TypeABGRFlt         uint32 = 4457628  // TYPE_ABGR_FLT
	TypeABGRFltPremul   uint32 = 12846236 // TYPE_ABGR_FLT_PREMUL
	TypeCMYKFlt         uint32 = 4587556  // TYPE_CMYK_FLT
	TypeXYZDbl          uint32 = 4784152  // TYPE_XYZ_DBL
	TypeLabDbl          uint32 = 4849688  // TYPE_Lab_DBL
	TypeGrayDbl         uint32 = 4390920  // TYPE_GRAY_DBL
	TypeRGBDbl          uint32 = 4456472  // TYPE_RGB_DBL
	TypeBGRDbl          uint32 = 4457496  // TYPE_BGR_DBL
	TypeCMYKDbl         uint32 = 4587552  // TYPE_CMYK_DBL
	TypeOKLABDbl        uint32 = 5308440  // TYPE_OKLAB_DBL
	TypeGrayHalfFlt     uint32 = 4390922  // TYPE_GRAY_HALF_FLT
	TypeRGBHalfFlt      uint32 = 4456474  // TYPE_RGB_HALF_FLT
	TypeCMYKHalfFlt     uint32 = 4587554  // TYPE_CMYK_HALF_FLT
	TypeRGBAHalfFlt     uint32 = 4456602  // TYPE_RGBA_HALF_FLT
	TypeARGBHalfFlt     uint32 = 4472986  // TYPE_ARGB_HALF_FLT
	TypeBGRHalfFlt      uint32 = 4457498  // TYPE_BGR_HALF_FLT
	TypeBGRAHalfFlt     uint32 = 4474010  // TYPE_BGRA_HALF_FLT
	TypeABGRHalfFlt     uint32 = 4457498  // TYPE_ABGR_HALF_FLT
)

Named pixel formats, mirroring the TYPE_* macros in lcms2.h.

View Source
const (
	IntentPerceptual           uint32 = 0
	IntentRelativeColorimetric uint32 = 1
	IntentSaturation           uint32 = 2
	IntentAbsoluteColorimetric uint32 = 3
)

Rendering intents, mirroring the INTENT_* macros in include/lcms2.h.

View Source
const (
	UsedAsInput  uint32 = 0
	UsedAsOutput uint32 = 1
	UsedAsProof  uint32 = 2
)

LUT usage directions, mirroring LCMS_USED_AS_INPUT/OUTPUT/PROOF.

View Source
const (
	VX = 0
	VY = 1
	VZ = 2
)

Axis indices into a VEC3. No specific meaning; mirrors VX/VY/VZ in include/lcms2_plugin.h.

View Source
const (
	PackFlags16Bits uint32 = 0x0000 // CMS_PACK_FLAGS_16BITS
	PackFlagsFloat  uint32 = 0x0001 // CMS_PACK_FLAGS_FLOAT
)

Packing precision flags for the formatter lookup.

View Source
const (
	// MagicNumber is the ICC profile magic 'acsp' found at offset 36 of every
	// profile header (cmsMagicNumber).
	MagicNumber uint32 = 0x61637370 // 'acsp'
	// LcmsSignature is Little CMS's own four-byte signature 'lcms'
	// (lcmsSignature), used as the default CMM and creator.
	LcmsSignature uint32 = 0x6c636d73 // 'lcms'
	// MaxChannels mirrors cmsMAXCHANNELS.
	MaxChannels = maxChannels
)

ICC container constants (include/lcms2.h).

View Source
const (
	PTANY   = 0 // PT_ANY: matches any color space (T_COLORSPACE wildcard)
	PTGray  = 3
	PTRGB   = 4
	PTCMY   = 5
	PTCMYK  = 6
	PTYCbCr = 7
	PTYUV   = 8 // Lu'v'
	PTXYZ   = 9
	PTLab   = 10
	PTYUVK  = 11 // Lu'v'K
	PTHSV   = 12
	PTHLS   = 13
	PTYxy   = 14
	PTMCH1  = 15
	PTMCH2  = 16
	PTMCH3  = 17
	PTMCH4  = 18
	PTMCH5  = 19
	PTMCH6  = 20
	PTMCH7  = 21
	PTMCH8  = 22
	PTMCH9  = 23
	PTMCH10 = 24
	PTMCH11 = 25
	PTMCH12 = 26
	PTMCH13 = 27
	PTMCH14 = 28
	PTMCH15 = 29
	PTLabV2 = 30 // Identical to PT_Lab, but using the V2 old encoding
)

Pixel-type notations, mirroring the PT_* macros in include/lcms2.h. These are lcms2's internal color-space enumeration used by _cmsICCcolorSpace / _cmsLCMScolorSpace.

View Source
const (
	FlagsHighResPrecalc = 0x0400 // cmsFLAGS_HIGHRESPRECALC
	FlagsLowResPrecalc  = 0x0800 // cmsFLAGS_LOWRESPRECALC
)

Transform flags (subset) used by _cmsReasonableGridpointsByColorspace.

View Source
const (
	D50X = 0.9642
	D50Y = 1.0
	D50Z = 0.8249
)

D50 tristimulus values, mirroring the cmsD50X/Y/Z macros in include/lcms2.h.

View Source
const (
	FlagsNoWhiteOnWhiteFixup    uint32 = 0x0004     // cmsFLAGS_NOWHITEONWHITEFIXUP
	Flags8BitsDeviceLink        uint32 = 0x0008     // cmsFLAGS_8BITS_DEVICELINK
	FlagsGuessDeviceClass       uint32 = 0x0020     // cmsFLAGS_GUESSDEVICECLASS
	FlagsNoCache                uint32 = 0x0040     // cmsFLAGS_NOCACHE
	FlagsKeepSequence           uint32 = 0x0080     // cmsFLAGS_KEEP_SEQUENCE
	FlagsNoOptimize             uint32 = 0x0100     // cmsFLAGS_NOOPTIMIZE
	FlagsNullTransform          uint32 = 0x0200     // cmsFLAGS_NULLTRANSFORM
	FlagsGamutCheck             uint32 = 0x1000     // cmsFLAGS_GAMUTCHECK
	FlagsBlackPointCompensation uint32 = 0x2000     // cmsFLAGS_BLACKPOINTCOMPENSATION
	FlagsSoftProofing           uint32 = 0x4000     // cmsFLAGS_SOFTPROOFING
	FlagsNoNegatives            uint32 = 0x8000     // cmsFLAGS_NONEGATIVES
	FlagsForceCLUT              uint32 = 0x0002     // cmsFLAGS_FORCE_CLUT
	FlagsCLUTPostLinearization  uint32 = 0x0001     // cmsFLAGS_CLUT_POST_LINEARIZATION
	FlagsCLUTPreLinearization   uint32 = 0x0010     // cmsFLAGS_CLUT_PRE_LINEARIZATION
	FlagsNoDefaultResourceDef   uint32 = 0x01000000 // cmsFLAGS_NODEFAULTRESOURCEDEF
	FlagsCanChangeFormatter     uint32 = 0x02000000 // cmsFLAGS_CAN_CHANGE_FORMATTER
	FlagsCopyAlpha              uint32 = 0x04000000 // cmsFLAGS_COPY_ALPHA
)
View Source
const Version = 2190

Version is the level of ICC format supported, encoded as in the C implementation's LCMS_VERSION (2.19 -> 2190).

Variables

This section is empty.

Functions

func BFDdeltaE

func BFDdeltaE(lab1, lab2 CIELab) float64

BFDdeltaE returns the BFD(1:1) difference between two Lab values (cmsBFDdeltaE).

func BytesSH

func BytesSH(b uint32) uint32

BytesSH encodes the bytes per channel (0 encodes 8-byte double).

func CIE94DeltaE

func CIE94DeltaE(lab1, lab2 CIELab) float64

CIE94DeltaE returns the CIE94 deltaE (cmsCIE94DeltaE).

func CIE2000DeltaE

func CIE2000DeltaE(lab1, lab2 CIELab, kl, kc, kh float64) float64

CIE2000DeltaE returns the CIEDE2000 difference between two Lab values. The weightings Kl, Kc and Kh tune the relative importance of lightness, chroma and hue (cmsCIE2000DeltaE).

func CIECAM02Init

func CIECAM02Init(pVC *ViewingConditions) *cmsCIECAM02

CIECAM02Init ports cmsCIECAM02Init on the default context.

func CMCdeltaE

func CMCdeltaE(lab1, lab2 CIELab, l, c float64) float64

CMCdeltaE returns the CMC(l:c) difference between two Lab values (cmsCMCdeltaE).

func ChannelsOf

func ChannelsOf(colorSpace ColorSpaceSignature) uint32

ChannelsOf returns the number of channels for a color space, defaulting to 3 for unknown spaces. DEPRECATED in the reference; provided for compatibility (cmsChannelsOf).

func ChannelsOfColorSpace

func ChannelsOfColorSpace(colorSpace ColorSpaceSignature) int32

ChannelsOfColorSpace returns the number of channels for a color space, or -1 for unknown (cmsChannelsOfColorSpace).

func ChannelsSH

func ChannelsSH(c uint32) uint32

ChannelsSH encodes the number of colour channels.

func ColorspaceSH

func ColorspaceSH(s uint32) uint32

ColorspaceSH encodes the colour space (a PT* value).

func DeltaE

func DeltaE(lab1, lab2 CIELab) float64

DeltaE returns the CIE76 deltaE between two Lab values (cmsDeltaE).

func DesaturateLab

func DesaturateLab(lab *CIELab, amax, amin, bmax, bmin float64) bool

DesaturateLab ports cmsDesaturateLab: carefully clamp on CIELab space.

func DetectRGBProfileGamma

func DetectRGBProfileGamma(p *Profile, threshold float64) float64

DetectRGBProfileGamma ports cmsDetectRGBProfileGamma on the default context.

func DetectTAC

func DetectTAC(p *Profile) float64

DetectTAC ports cmsDetectTAC on the default/profile context.

func DoSwapSH

func DoSwapSH(e uint32) uint32

DoSwapSH encodes the channel-reversal flag (e.g. BGR).

func EndPointsBySpace

func EndPointsBySpace(space ColorSpaceSignature) (white, black []uint16, nOutputs uint32, ok bool)

EndPointsBySpace returns the white and black end points (and channel count) for the most common color spaces, and ok=false for others (_cmsEndPointsBySpace). The returned slices alias package-level tables and must not be mutated by callers.

func Endian16SH

func Endian16SH(e uint32) uint32

Endian16SH encodes the 16-bit big-endian flag.

func ExtraSH

func ExtraSH(e uint32) uint32

ExtraSH encodes the number of extra (e.g. alpha) channels.

func FlagsGridPoints

func FlagsGridPoints(n uint32) uint32

FlagsGridPoints ports cmsFLAGS_GRIDPOINTS(n).

func FlavorSH

func FlavorSH(s uint32) uint32

FlavorSH encodes the flavour flag (min-is-white vs min-is-black).

func Float2LabEncoded

func Float2LabEncoded(fLab CIELab) [3]uint16

Float2LabEncoded encodes Lab into an ICC V4 16-bit encoding (cmsFloat2LabEncoded).

func Float2LabEncodedV2

func Float2LabEncodedV2(fLab CIELab) [3]uint16

Float2LabEncodedV2 encodes Lab into an ICC V2 16-bit encoding (cmsFloat2LabEncodedV2).

func Float2XYZEncoded

func Float2XYZEncoded(fXYZ CIEXYZ) [3]uint16

Float2XYZEncoded encodes XYZ into three 1.15 fixed-point words, clamping to the encodeable range (cmsFloat2XYZEncoded).

func FloatSH

func FloatSH(a uint32) uint32

FloatSH encodes the floating-point-sample flag.

func FormatterForColorspaceOfProfile

func FormatterForColorspaceOfProfile(profile *Profile, nBytes uint32, isFloat bool) uint32

FormatterForColorspaceOfProfile ports cmsFormatterForColorspaceOfProfile: build a formatter code for a profile's device color space. Returns 0 for an unsupported color space.

func FormatterForPCSOfProfile

func FormatterForPCSOfProfile(profile *Profile, nBytes uint32, isFloat bool) uint32

FormatterForPCSOfProfile ports cmsFormatterForPCSOfProfile: build a formatter code for a profile's PCS. Returns 0 for an unsupported color space.

func FormatterIs8bit

func FormatterIs8bit(typ uint32) bool

FormatterIs8bit ports _cmsFormatterIs8bit.

func FormatterIsFloat

func FormatterIsFloat(typ uint32) bool

FormatterIsFloat ports _cmsFormatterIsFloat.

func GBDAlloc

func GBDAlloc() *cmsGDB

GBDAlloc ports cmsGBDAlloc on the default context.

func GetAlarmCodes

func GetAlarmCodes() [maxChannels]uint16

GetAlarmCodes returns the alarm codes of the default context, mirroring cmsGetAlarmCodes.

func GetContextUserData

func GetContextUserData() any

GetContextUserData returns the user data of the default context.

func GetEncodedCMMVersion

func GetEncodedCMMVersion() int

GetEncodedCMMVersion mirrors cmsGetEncodedCMMversion.

func GetPostScriptCRD

func GetPostScriptCRD(p *Profile, intent, dwFlags uint32) ([]byte, error)

GetPostScriptCRD is the default-context form of (*Context).GetPostScriptCRD.

func GetPostScriptCSA

func GetPostScriptCSA(p *Profile, intent, dwFlags uint32) ([]byte, error)

GetPostScriptCSA is the default-context form of (*Context).GetPostScriptCSA.

Example
p, err := OpenProfileFromFile("testdata/test5.icc", "r")
if err != nil {
	fmt.Println(err)
	return
}
csa, err := GetPostScriptCSA(p, IntentPerceptual, 0)
if err != nil {
	fmt.Println(err)
	return
}
// The first line names the CIEBased colour-space array flavour.
fmt.Printf("%s\n", bytes.SplitN(csa, []byte("\n"), 2)[0])
Output:
[ /CIEBasedABC

func GetPostScriptColorResource

func GetPostScriptColorResource(typ PSResourceType, p *Profile, intent, dwFlags uint32) ([]byte, error)

GetPostScriptColorResource is the default-context form.

func GetSupportedIntents

func GetSupportedIntents(nMax uint32) (total uint32, codes []uint32, descriptions []string)

GetSupportedIntents queries the default context, mirroring cmsGetSupportedIntents.

func LCMScolorSpace

func LCMScolorSpace(profileSpace ColorSpaceSignature) int

LCMScolorSpace translates from an ICC color space signature to lcms2's internal PT_* notation (_cmsLCMScolorSpace). Returns 0 for unknown values.

func MAT3IsIdentity

func MAT3IsIdentity(a MAT3) bool

MAT3IsIdentity reports whether a is (numerically) the identity matrix (_cmsMAT3isIdentity).

func OptimizedSH

func OptimizedSH(s uint32) uint32

OptimizedSH encodes the already-optimized flag (internal).

func PlanarSH

func PlanarSH(p uint32) uint32

PlanarSH encodes the planar (vs chunky) layout flag.

func PremulSH

func PremulSH(m uint32) uint32

Pixel-format bitfield builders, mirroring the *_SH macros in lcms2.h. Compose them with bitwise OR to build a format value. PremulSH encodes the premultiplied-alpha flag.

func ReasonableGridpointsByColorspace

func ReasonableGridpointsByColorspace(colorspace ColorSpaceSignature, dwFlags uint32) uint32

ReasonableGridpointsByColorspace returns the number of CLUT grid points to use for a color space, honoring precalc flags (_cmsReasonableGridpointsByColorspace).

func RegisterPlugin

func RegisterPlugin(plugin Plugin) error

RegisterPlugin installs a plug-in chain into the default context, mirroring cmsPlugin.

func SetAdaptationState

func SetAdaptationState(d float64) float64

SetAdaptationState sets the adaptation state of the default context, mirroring cmsSetAdaptationState.

func SetAlarmCodes

func SetAlarmCodes(codes [maxChannels]uint16)

SetAlarmCodes sets the alarm codes of the default context, mirroring cmsSetAlarmCodes.

func SetLogErrorHandler

func SetLogErrorHandler(fn LogErrorHandlerFunc)

SetLogErrorHandler installs fn as the error logger for the default context, mirroring cmsSetLogErrorHandler.

func SliceSpace16

func SliceSpace16(nInputs uint32, clutPoints []uint32, sampler Sampler16, cargo any) bool

SliceSpace16 ports cmsSliceSpace16: sweep the whole input space defined by clutPoints (one node count per input) and call sampler at each knot with the quantized 16-bit coordinates. The sampler receives a nil output slice (this sweep only produces inputs). Returns false when the sweep is aborted by the sampler or the geometry is invalid.

func SliceSpaceFloat

func SliceSpaceFloat(nInputs uint32, clutPoints []uint32, sampler SamplerFloat, cargo any) bool

SliceSpaceFloat ports cmsSliceSpaceFloat: the floating-point counterpart of SliceSpace16. Coordinates are quantized to 16 bits then scaled to 0..1.

func SwapFirstSH

func SwapFirstSH(s uint32) uint32

SwapFirstSH encodes the swap-first flag (e.g. ARGB vs RGBA).

func TempFromWhitePoint

func TempFromWhitePoint(whitePoint CIExyY) (float64, error)

TempFromWhitePoint computes the correlated color temperature (kelvin) for a white point using Robertson's method (cmsTempFromWhitePoint). It returns an ErrRange error when no isotemperature line brackets the input; the C reference returns FALSE without signalling in that case.

func UnregisterPlugins

func UnregisterPlugins()

UnregisterPlugins reverts the default context's plug-in families to their built-in state, mirroring cmsUnregisterPlugins.

func VEC3Distance

func VEC3Distance(a, b VEC3) float64

VEC3Distance returns the Euclidean distance between a and b (_cmsVEC3distance).

func VEC3Dot

func VEC3Dot(u, v VEC3) float64

VEC3Dot returns the dot product u . v (_cmsVEC3dot).

func VEC3Length

func VEC3Length(a VEC3) float64

VEC3Length returns the Euclidean length of a (_cmsVEC3length).

Types

type CIELCh

type CIELCh struct {
	L, C, H float64
}

CIELCh is a color in CIE LCh cylindrical space (cmsCIELCh).

func Lab2LCh

func Lab2LCh(lab CIELab) CIELCh

Lab2LCh converts Lab to LCh. No range check is performed, so negative values are allowed (cmsLab2LCh).

type CIELab

type CIELab struct {
	L, A, B float64
}

CIELab is a color in CIE L*a*b* space (cmsCIELab).

func LCh2Lab

func LCh2Lab(lch CIELCh) CIELab

LCh2Lab converts LCh to Lab. No range check is performed (cmsLCh2Lab).

func LabEncoded2Float

func LabEncoded2Float(wLab [3]uint16) CIELab

LabEncoded2Float decodes an ICC V4 16-bit Lab encoding (cmsLabEncoded2Float).

func LabEncoded2FloatV2

func LabEncoded2FloatV2(wLab [3]uint16) CIELab

LabEncoded2FloatV2 decodes an ICC V2 16-bit Lab encoding (cmsLabEncoded2FloatV2).

func XYZ2Lab

func XYZ2Lab(whitePoint *CIEXYZ, xyz CIEXYZ) CIELab

XYZ2Lab converts XYZ to Lab relative to whitePoint. A nil whitePoint means D50 (cmsXYZ2Lab). It can handle some negative XYZ inputs.

type CIEXYZ

type CIEXYZ struct {
	X, Y, Z float64
}

CIEXYZ is a color in CIE XYZ tristimulus space (cmsCIEXYZ).

func AdaptToIlluminant

func AdaptToIlluminant(sourceWhitePt, illuminant, value CIEXYZ) (CIEXYZ, bool)

AdaptToIlluminant adapts a color to a given illuminant. The original color is expected to have the sourceWhitePt white point (cmsAdaptToIlluminant). ok=false indicates the adaptation matrix could not be built.

func D50XYZ

func D50XYZ() CIEXYZ

D50XYZ returns the D50 white point in XYZ (cmsD50_XYZ).

func Lab2XYZ

func Lab2XYZ(whitePoint *CIEXYZ, lab CIELab) CIEXYZ

Lab2XYZ converts Lab to XYZ relative to whitePoint. A nil whitePoint means D50 (cmsLab2XYZ). It can return some negative XYZ values.

func XYZEncoded2Float

func XYZEncoded2Float(xyz [3]uint16) CIEXYZ

XYZEncoded2Float decodes three 1.15 fixed-point words into XYZ (cmsXYZEncoded2Float).

func XyY2XYZ

func XyY2XYZ(src CIExyY) CIEXYZ

XyY2XYZ converts xyY to XYZ (cmsxyY2XYZ).

type CIEXYZTRIPLE

type CIEXYZTRIPLE struct {
	Red, Green, Blue CIEXYZ
}

CIEXYZTRIPLE is a triple of XYZ colors, e.g. RGB primaries (cmsCIEXYZTRIPLE).

type CIExyY

type CIExyY struct {
	X, Y, YY float64 // C fields: x, y, Y
}

CIExyY is a color in CIE xyY space (cmsCIExyY).

func D50xyY

func D50xyY() CIExyY

D50xyY returns the D50 white point in xyY (cmsD50_xyY).

func WhitePointFromTemp

func WhitePointFromTemp(tempK float64) (CIExyY, error)

WhitePointFromTemp computes a white point (in xyY) from a correlated color temperature in kelvin (cmsWhitePointFromTemp). It returns an ErrRange error for temperatures outside 4000K..25000K.

func XYZ2xyY

func XYZ2xyY(src CIEXYZ) CIExyY

XYZ2xyY converts XYZ to xyY (cmsXYZ2xyY).

type CIExyYTRIPLE

type CIExyYTRIPLE struct {
	Red, Green, Blue CIExyY
}

CIExyYTRIPLE is a triple of xyY colors, e.g. RGB primaries (cmsCIExyYTRIPLE).

type ColorSpaceSignature

type ColorSpaceSignature uint32

ColorSpaceSignature mirrors cmsColorSpaceSignature: an ICC four-byte color space signature.

const (
	SigXYZData     ColorSpaceSignature = 0x58595A20 // 'XYZ '
	SigLabData     ColorSpaceSignature = 0x4C616220 // 'Lab '
	SigLuvData     ColorSpaceSignature = 0x4C757620 // 'Luv '
	SigYCbCrData   ColorSpaceSignature = 0x59436272 // 'YCbr'
	SigYxyData     ColorSpaceSignature = 0x59787920 // 'Yxy '
	SigRgbData     ColorSpaceSignature = 0x52474220 // 'RGB '
	SigGrayData    ColorSpaceSignature = 0x47524159 // 'GRAY'
	SigHsvData     ColorSpaceSignature = 0x48535620 // 'HSV '
	SigHlsData     ColorSpaceSignature = 0x484C5320 // 'HLS '
	SigCmykData    ColorSpaceSignature = 0x434D594B // 'CMYK'
	SigCmyData     ColorSpaceSignature = 0x434D5920 // 'CMY '
	SigMCH1Data    ColorSpaceSignature = 0x4D434831 // 'MCH1'
	SigMCH2Data    ColorSpaceSignature = 0x4D434832 // 'MCH2'
	SigMCH3Data    ColorSpaceSignature = 0x4D434833 // 'MCH3'
	SigMCH4Data    ColorSpaceSignature = 0x4D434834 // 'MCH4'
	SigMCH5Data    ColorSpaceSignature = 0x4D434835 // 'MCH5'
	SigMCH6Data    ColorSpaceSignature = 0x4D434836 // 'MCH6'
	SigMCH7Data    ColorSpaceSignature = 0x4D434837 // 'MCH7'
	SigMCH8Data    ColorSpaceSignature = 0x4D434838 // 'MCH8'
	SigMCH9Data    ColorSpaceSignature = 0x4D434839 // 'MCH9'
	SigMCHAData    ColorSpaceSignature = 0x4D434841 // 'MCHA'
	SigMCHBData    ColorSpaceSignature = 0x4D434842 // 'MCHB'
	SigMCHCData    ColorSpaceSignature = 0x4D434843 // 'MCHC'
	SigMCHDData    ColorSpaceSignature = 0x4D434844 // 'MCHD'
	SigMCHEData    ColorSpaceSignature = 0x4D434845 // 'MCHE'
	SigMCHFData    ColorSpaceSignature = 0x4D434846 // 'MCHF'
	Sig1colorData  ColorSpaceSignature = 0x31434C52 // '1CLR'
	Sig2colorData  ColorSpaceSignature = 0x32434C52 // '2CLR'
	Sig3colorData  ColorSpaceSignature = 0x33434C52 // '3CLR'
	Sig4colorData  ColorSpaceSignature = 0x34434C52 // '4CLR'
	Sig5colorData  ColorSpaceSignature = 0x35434C52 // '5CLR'
	Sig6colorData  ColorSpaceSignature = 0x36434C52 // '6CLR'
	Sig7colorData  ColorSpaceSignature = 0x37434C52 // '7CLR'
	Sig8colorData  ColorSpaceSignature = 0x38434C52 // '8CLR'
	Sig9colorData  ColorSpaceSignature = 0x39434C52 // '9CLR'
	Sig10colorData ColorSpaceSignature = 0x41434C52 // 'ACLR'
	Sig11colorData ColorSpaceSignature = 0x42434C52 // 'BCLR'
	Sig12colorData ColorSpaceSignature = 0x43434C52 // 'CCLR'
	Sig13colorData ColorSpaceSignature = 0x44434C52 // 'DCLR'
	Sig14colorData ColorSpaceSignature = 0x45434C52 // 'ECLR'
	Sig15colorData ColorSpaceSignature = 0x46434C52 // 'FCLR'
	SigLuvKData    ColorSpaceSignature = 0x4C75764B // 'LuvK'
)

ICC color space signatures (subset). Values are the big-endian four-character codes exactly as defined in include/lcms2.h.

const SigNamedData ColorSpaceSignature = 0x6e6d636c // 'nmcl'

SigNamedData ('nmcl') mirrors cmsSigNamedData in the color-space enumeration; it is defined here to complete the set started below.

func ICCcolorSpace

func ICCcolorSpace(ourNotation int) ColorSpaceSignature

ICCcolorSpace translates from lcms2's internal PT_* notation to an ICC color space signature (_cmsICCcolorSpace). Returns 0 for unknown values.

func (ColorSpaceSignature) String

func (s ColorSpaceSignature) String() string

String renders the color-space signature as four ASCII characters (big-endian order).

type Context

type Context struct {
	// contains filtered or unexported fields
}

Context is the pure-Go replacement for the C cmsContext. It holds all per-context state: the user data pointer, the error logger, the alarm codes and adaptation state used by transforms, and one registry per plug-in family.

A Context is safe for concurrent use by multiple goroutines: all mutable state is guarded by mu. Registries are copied on Dup, so a duplicated context is fully isolated from its parent. Callers that never create an explicit context can use the package-level functions, which operate on a shared default context.

func DefaultContext

func DefaultContext() *Context

DefaultContext returns the shared context used by all package-level functions. It is the analogue of passing a NULL cmsContext to the C API.

func NewContext

func NewContext(plugin Plugin, userData any) (*Context, error)

NewContext creates a new context with an optional plug-in chain and optional user data, mirroring cmsCreateContext(Plugin, UserData). Pass a nil plugin to create a context with only the built-in behaviour. If any plug-in in the chain is malformed (bad magic, or a required newer library version, or an unknown type) NewContext returns the corresponding *Error and no context.

func (*Context) AllocNamedColorList

func (ctx *Context) AllocNamedColorList(n, colorantCount uint32, prefix, suffix string) *NamedColorList

AllocNamedColorList ports cmsAllocNamedColorList on a context.

func (*Context) AllocProfileSequenceDescription

func (ctx *Context) AllocProfileSequenceDescription(n uint32) *ProfileSequence

AllocProfileSequenceDescription ports cmsAllocProfileSequenceDescription: n must be in 1..255.

func (*Context) BuildGamma

func (ctx *Context) BuildGamma(gamma float64) (*ToneCurve, error)

BuildGamma ports cmsBuildGamma on a context: a pure power curve X = Y^gamma.

func (*Context) BuildKToneCurve

func (ctx *Context) BuildKToneCurve(nPoints, nProfiles uint32, intents []uint32,
	profiles []*Profile, bpc []bool, adaptationStates []float64, dwFlags uint32) *ToneCurve

BuildKToneCurve ports _cmsBuildKToneCurve: compute the black tone curve on a CMYK -> CMYK chain by joining the K -> L* curves of the input and output sides. Returns nil if the chain is not CMYK -> CMYK output, or if the joined curve is non-monotonic.

func (*Context) BuildParametricToneCurve

func (ctx *Context) BuildParametricToneCurve(typ int32, params []float64) (*ToneCurve, error)

BuildParametricToneCurve ports cmsBuildParametricToneCurve on a context. Type selects a parametric function (built-in or plug-in); a negative Type requests the analytic inverse. Returns an error for an unknown type.

func (*Context) BuildSegmentedToneCurve

func (ctx *Context) BuildSegmentedToneCurve(segments []CurveSegment) (*ToneCurve, error)

BuildSegmentedToneCurve ports cmsBuildSegmentedToneCurve on a context. It builds the floating-point segment description, then samples it into the 16-bit optimization table.

func (*Context) BuildTabulatedToneCurve16

func (ctx *Context) BuildTabulatedToneCurve16(values []uint16) (*ToneCurve, error)

BuildTabulatedToneCurve16 ports cmsBuildTabulatedToneCurve16 on a context: a limited-precision curve defined purely by a 16-bit table (no floating-point description).

func (*Context) BuildTabulatedToneCurveFloat

func (ctx *Context) BuildTabulatedToneCurveFloat(values []float32) (*ToneCurve, error)

BuildTabulatedToneCurveFloat ports cmsBuildTabulatedToneCurveFloat on a context: a floating-point sample table is wrapped in a 3-segment curve whose middle segment is sampled and whose flanks hold the first/last sample.

func (*Context) CIECAM02Init

func (ctx *Context) CIECAM02Init(pVC *ViewingConditions) *cmsCIECAM02

CIECAM02Init ports cmsCIECAM02Init: build a model handle from the viewing conditions. Returns nil on allocation-style failure (never in the pure-Go port, but the signature mirrors the reference contract).

func (*Context) CompileProfileSequence

func (ctx *Context) CompileProfileSequence(profiles []*Profile) *ProfileSequence

CompileProfileSequence ports _cmsCompileProfileSequence: build a sequence descriptor from an array of profiles.

func (*Context) CreateBCHSWabstractProfile

func (ctx *Context) CreateBCHSWabstractProfile(nLUTPoints uint32,
	bright, contrast, hue, saturation float64,
	tempSrc, tempDest uint32) (*Profile, error)

CreateBCHSWabstractProfile ports cmsCreateBCHSWabstractProfileTHR: an abstract Lab profile for brightness, contrast, hue, saturation and white-point displacement (via source/destination color temperatures).

func (*Context) CreateDeviceLinkFromCubeFile

func (ctx *Context) CreateDeviceLinkFromCubeFile(fileName string) (*Profile, error)

CreateDeviceLinkFromCubeFile builds an RGB->RGB device-link profile from a .cube file on disk (the C cmsCreateDeviceLinkFromCubeFileTHR).

func (*Context) CreateDeviceLinkFromCubeMem

func (ctx *Context) CreateDeviceLinkFromCubeMem(data []byte) (*Profile, error)

CreateDeviceLinkFromCubeMem builds an RGB->RGB device-link profile from the bytes of a .cube (Adobe/IRIDAS) LUT held in memory. It is the idiomatic counterpart of the reference's cmsCreateDeviceLinkFromCubeFileTHR (our IT8 core loads from memory).

func (*Context) CreateExtendedTransform

func (ctx *Context) CreateExtendedTransform(
	nProfiles uint32, profiles []*Profile,
	bpc []bool, intents []uint32, adaptationStates []float64,
	gamutProfile *Profile, nGamutPCSposition uint32,
	inputFormat, outputFormat, dwFlags uint32) (*Transform, error)

CreateExtendedTransform ports cmsCreateExtendedTransform: the fully-parameterised transform builder that every other constructor funnels into.

func (*Context) CreateGrayProfile

func (ctx *Context) CreateGrayProfile(whitePoint *CIExyY, transferFunction *ToneCurve) (*Profile, error)

CreateGrayProfile ports cmsCreateGrayProfileTHR: a gray display profile with a white point and a single gray transfer function.

func (ctx *Context) CreateInkLimitingDeviceLink(colorSpace ColorSpaceSignature,
	limit float64) (*Profile, error)

CreateInkLimitingDeviceLink ports cmsCreateInkLimitingDeviceLinkTHR: a CMYK device link that enforces a total-ink limit (percent, 1..400).

func (*Context) CreateLab2Profile

func (ctx *Context) CreateLab2Profile(whitePoint *CIExyY) (*Profile, error)

CreateLab2Profile ports cmsCreateLab2ProfileTHR: a fake Lab v2 identity abstract profile. whitePoint may be nil (D50).

func (*Context) CreateLab4Profile

func (ctx *Context) CreateLab4Profile(whitePoint *CIExyY) (*Profile, error)

CreateLab4Profile ports cmsCreateLab4ProfileTHR: a fake Lab v4 identity abstract profile. whitePoint may be nil (D50).

func (ctx *Context) CreateLinearizationDeviceLink(colorSpace ColorSpaceSignature,
	transferFunctions []*ToneCurve) (*Profile, error)

CreateLinearizationDeviceLink ports cmsCreateLinearizationDeviceLinkTHR: a device link operating in colorSpace with one transfer function per channel.

func (*Context) CreateMultiprofileTransform

func (ctx *Context) CreateMultiprofileTransform(profiles []*Profile, nProfiles,
	inputFormat, outputFormat, intent, dwFlags uint32) (*Transform, error)

CreateMultiprofileTransform ports cmsCreateMultiprofileTransformTHR.

func (*Context) CreateNULLProfile

func (ctx *Context) CreateNULLProfile() (*Profile, error)

CreateNULLProfile ports cmsCreateNULLProfileTHR: a fake profile whose single output channel is always 0. Useful only for gamut-checking tricks.

func (*Context) CreateProfilePlaceholder

func (ctx *Context) CreateProfilePlaceholder() *Profile

CreateProfilePlaceholder builds an empty profile with the reference defaults, mirroring cmsCreateProfilePlaceholder.

func (*Context) CreateProofingTransform

func (ctx *Context) CreateProofingTransform(
	input *Profile, inputFormat uint32,
	output *Profile, outputFormat uint32,
	proofing *Profile, nIntent, proofingIntent, dwFlags uint32) (*Transform, error)

CreateProofingTransform ports cmsCreateProofingTransformTHR.

func (*Context) CreateRGBProfile

func (ctx *Context) CreateRGBProfile(whitePoint *CIExyY, primaries *CIExyYTRIPLE,
	transferFunction []*ToneCurve) (*Profile, error)

CreateRGBProfile ports cmsCreateRGBProfileTHR: build a display RGB profile from a white point, primaries and per-channel transfer functions. Any of the three may be nil (mirroring the C NULL arguments), producing a partial profile. When transferFunction is non-nil it must hold exactly three curves.

func (*Context) CreateTransform

func (ctx *Context) CreateTransform(input *Profile, inputFormat uint32,
	output *Profile, outputFormat, intent, dwFlags uint32) (*Transform, error)

CreateTransform ports cmsCreateTransformTHR.

func (*Context) CreateXYZProfile

func (ctx *Context) CreateXYZProfile() (*Profile, error)

CreateXYZProfile ports cmsCreateXYZProfileTHR: a fake XYZ identity abstract profile.

func (*Context) Create_OkLabProfile

func (ctx *Context) Create_OkLabProfile() (*Profile, error)

Create_OkLabProfile ports cmsCreate_OkLabProfile: an experimental OkLab color space profile. Note (as in the reference) that this virtual profile cannot be serialized to an ICC file — it is only usable in-memory for transforms.

func (*Context) Create_sRGBProfile

func (ctx *Context) Create_sRGBProfile() (*Profile, error)

Create_sRGBProfile ports cmsCreate_sRGBProfileTHR: the ICC virtual profile for the sRGB color space (Rec.709 primaries, D65 white, the sRGB TRC).

func (*Context) DefaultICCintents

func (ctx *Context) DefaultICCintents(nProfiles uint32, theIntents []uint32, profiles []*Profile,
	bpc []bool, adaptationStates []float64, dwFlags uint32) (*Pipeline, error)

DefaultICCintents ports DefaultICCintents / _cmsDefaultICCintents: build the device-link pipeline that chains nProfiles profiles for the given per-profile intents. Returns the pipeline or an error.

func (*Context) Delete

func (ctx *Context) Delete()

Delete releases ctx. Under the Go garbage collector there is nothing to free, so this only reverts the context to its pristine, plug-in-free state; it exists for symmetry with cmsDeleteContext. The context must not be used concurrently with Delete.

func (*Context) DictAlloc

func (ctx *Context) DictAlloc() *Dict

DictAlloc ports cmsDictAlloc on a context.

func (*Context) Dup

func (ctx *Context) Dup(newUserData any) (*Context, error)

Dup duplicates ctx together with all of its per-context state and registered plug-ins, mirroring cmsDupContext(ContextID, NewUserData). If newUserData is non-nil it becomes the new context's user data; otherwise the parent's user data pointer is inherited. The returned context is fully isolated: mutating its state or registries does not affect ctx.

func (*Context) GBDAlloc

func (ctx *Context) GBDAlloc() *cmsGDB

GBDAlloc ports cmsGBDAlloc: allocate a gamut boundary descriptor.

func (*Context) GetAlarmCodes

func (ctx *Context) GetAlarmCodes() [maxChannels]uint16

GetAlarmCodes returns the current 16 out-of-gamut alarm codes for ctx, mirroring cmsGetAlarmCodesTHR.

func (*Context) GetFormatter

func (ctx *Context) GetFormatter(typ uint32, dir FormatterDirection, dwFlags uint32) Formatter

GetFormatter ports _cmsGetFormatter. It consults the registered formatter factories (newest-first) and falls back to the stock tables. A format with zero channels yields the zero Formatter, exactly as in C.

The returned Fmt16/FmtFloat must be called with a working-values slice of at least MaxChannels elements; see Formatter16. A shorter slice can be indexed out of range by formatters that expand fewer channels into more slots.

func (*Context) GetPostScriptCRD

func (ctx *Context) GetPostScriptCRD(p *Profile, intent, dwFlags uint32) ([]byte, error)

GetPostScriptCRD ports cmsGetPostScriptCRD: it returns the ColorRenderingDictionary as bytes.

func (*Context) GetPostScriptCSA

func (ctx *Context) GetPostScriptCSA(p *Profile, intent, dwFlags uint32) ([]byte, error)

GetPostScriptCSA ports cmsGetPostScriptCSA: it returns the ColorSpaceArray as bytes.

func (*Context) GetPostScriptColorResource

func (ctx *Context) GetPostScriptColorResource(typ PSResourceType, p *Profile, intent, dwFlags uint32) ([]byte, error)

GetPostScriptColorResource ports cmsGetPostScriptColorResource: it generates the requested PostScript colour resource (CSA or CRD) for the profile and returns the generated bytes.

func (*Context) GetSupportedIntents

func (ctx *Context) GetSupportedIntents(nMax uint32) (total uint32, codes []uint32, descriptions []string)

GetSupportedIntents ports cmsGetSupportedIntentsTHR: return up to nMax intent codes and descriptions, and the total number of supported intents (which may exceed nMax). The built-in intents come first, then any plug-in intents.

func (*Context) JoinToneCurve

func (ctx *Context) JoinToneCurve(x, y *ToneCurve, nResultingPoints uint32) (*ToneCurve, error)

JoinToneCurve ports cmsJoinToneCurve on a context: build y = Y^-1(X(t)) by sampling X forward and Y reversed over nResultingPoints. X and Y should be monotonic.

func (*Context) LinkProfiles

func (ctx *Context) LinkProfiles(nProfiles uint32, theIntents []uint32, profiles []*Profile,
	bpc []bool, adaptationStates []float64, dwFlags uint32) (*Pipeline, error)

LinkProfiles ports _cmsLinkProfiles: validate arguments, adjust BPC per the Adobe rules, find the handler for the first intent, and dispatch.

func (*Context) NewMLU

func (ctx *Context) NewMLU(nItems uint32) *MLU

NewMLU ports cmsMLUalloc on a context: an empty MLU pre-sized for nItems entries (a non-positive request becomes 2, matching the reference). It returns nil where cmsMLUalloc would return NULL, i.e. when the entry directory would exceed the memory manager's allocation limit; callers passing a computed nItems must check for it.

func (*Context) OpenIOhandlerFromFile

func (ctx *Context) OpenIOhandlerFromFile(fileName, accessMode string) (*IOHandler, error)

OpenIOhandlerFromFile opens FileName for reading ("r") or writing ("w") and returns a file-backed handler, mirroring cmsOpenIOhandlerFromFile. Only the 'r' and 'w' modes are meaningful in the Go port; the 'e' (close-on-exec) and 'b' (binary) modifiers the C code recognises are no-ops here since Go always opens in binary mode and manages descriptors itself.

func (*Context) OpenIOhandlerFromMem

func (ctx *Context) OpenIOhandlerFromMem(buf []byte, write bool) (*IOHandler, error)

OpenIOhandlerFromMem creates a memory-backed handler. When write is false the bytes in buf are copied into a private read buffer (so the caller may free buf afterwards) and ReportedSize is set to len(buf); when write is true buf is the destination and writes are truncated to its length, mirroring the "r"/"w" branches of cmsOpenIOhandlerFromMem.

func (*Context) OpenIOhandlerFromNULL

func (ctx *Context) OpenIOhandlerFromNULL() *IOHandler

OpenIOhandlerFromNULL creates a handler that counts bytes without storing them, mirroring cmsOpenIOhandlerFromNULL.

func (*Context) OpenProfileFromFile

func (ctx *Context) OpenProfileFromFile(fileName, access string) (*Profile, error)

OpenProfileFromFile opens an ICC profile from disk, mirroring cmsOpenProfileFromFileTHR. Only read access ("r") parses a header; write access ("w") returns a placeholder bound to the file.

func (*Context) OpenProfileFromMem

func (ctx *Context) OpenProfileFromMem(buf []byte) (*Profile, error)

OpenProfileFromMem opens an ICC profile from a memory block, mirroring cmsOpenProfileFromMemTHR. The bytes are copied, so the caller may reuse buf.

func (*Context) PipelineAlloc

func (ctx *Context) PipelineAlloc(inputChannels, outputChannels uint32) (*Pipeline, error)

PipelineAlloc ports cmsPipelineAlloc: a value of zero channels is allowed as a placeholder.

func (*Context) RegisterPlugins

func (ctx *Context) RegisterPlugins(plugin Plugin) error

RegisterPlugins installs the plug-in chain starting at plugin into ctx, mirroring cmsPluginTHR. It walks the Next chain and, for each entry, validates the magic number and the expected version, then dispatches on the type. A malformed header (bad magic, a version newer than this library, or an unrecognised type) aborts the whole call and returns the corresponding *Error, exactly as the C code returns FALSE after logging cmsERROR_UNKNOWN_EXTENSION. A nil plugin is accepted as a no-op.

func (*Context) SetAdaptationState

func (ctx *Context) SetAdaptationState(d float64) float64

SetAdaptationState sets the observer adaptation state used by absolute colorimetric intent for ctx and returns the previous value, mirroring cmsSetAdaptationStateTHR. A negative d leaves the state unchanged (used to query the current value); the previous value is always returned.

func (*Context) SetAlarmCodes

func (ctx *Context) SetAlarmCodes(codes [maxChannels]uint16)

SetAlarmCodes sets the 16 out-of-gamut alarm codes for ctx, mirroring cmsSetAlarmCodesTHR. Values are meant to be encoded in 16 bits.

func (*Context) SetLogErrorHandler

func (ctx *Context) SetLogErrorHandler(fn LogErrorHandlerFunc)

SetLogErrorHandler installs fn as the error logger for ctx, mirroring cmsSetLogErrorHandlerTHR. A nil fn reverts to the no-op default handler.

func (*Context) StageAllocCLut16bit

func (ctx *Context) StageAllocCLut16bit(nGridPoints, inputChan, outputChan uint32, table []uint16) (*Stage, error)

StageAllocCLut16bit ports cmsStageAllocCLut16bit: a uniform-grid 16-bit CLUT.

func (*Context) StageAllocCLut16bitGranular

func (ctx *Context) StageAllocCLut16bitGranular(clutPoints []uint32, inputChan, outputChan uint32, table []uint16) (*Stage, error)

StageAllocCLut16bitGranular ports cmsStageAllocCLut16bitGranular.

func (*Context) StageAllocCLutFloat

func (ctx *Context) StageAllocCLutFloat(nGridPoints, inputChan, outputChan uint32, table []float32) (*Stage, error)

StageAllocCLutFloat ports cmsStageAllocCLutFloat: a uniform-grid float CLUT.

func (*Context) StageAllocCLutFloatGranular

func (ctx *Context) StageAllocCLutFloatGranular(clutPoints []uint32, inputChan, outputChan uint32, table []float32) (*Stage, error)

StageAllocCLutFloatGranular ports cmsStageAllocCLutFloatGranular.

func (*Context) StageAllocIdentity

func (ctx *Context) StageAllocIdentity(nChannels uint32) *Stage

StageAllocIdentity ports cmsStageAllocIdentity.

func (*Context) StageAllocMatrix

func (ctx *Context) StageAllocMatrix(rows, cols uint32, matrix, offset []float64) (*Stage, error)

StageAllocMatrix ports cmsStageAllocMatrix. matrix has Rows*Cols entries (row-major); offset has Rows entries or is nil.

func (*Context) StageAllocToneCurves

func (ctx *Context) StageAllocToneCurves(nChannels uint32, curves []*ToneCurve) (*Stage, error)

StageAllocToneCurves ports cmsStageAllocToneCurves. A nil curves slice forces identity gamma curves.

func (*Context) UnregisterPlugins

func (ctx *Context) UnregisterPlugins()

UnregisterPlugins reverts every plug-in family of ctx to its pristine, built-in state, mirroring cmsUnregisterPluginsTHR. As in C there is no way to remove a single plug-in, since one RegisterPlugins call may install many.

func (*Context) UserData

func (ctx *Context) UserData() any

UserData returns the user data associated with ctx, or nil if none was supplied. Mirrors cmsGetContextUserData.

type CurveSegment

type CurveSegment struct {
	X0, X1        float32     // Domain; for x0 < x <= x1
	Type          int32       // Parametric type; 0 means sampled, negatives reserved
	Params        [10]float64 // Parameters if Type != 0
	NGridPoints   uint32      // Number of grid points if Type == 0
	SampledPoints []float32   // Sample array if Type == 0
}

CurveSegment mirrors cmsCurveSegment: one segment of a segmented tone curve. A segment applies for x0 < x <= x1. Type==0 marks a sampled segment (SampledPoints/NGridPoints); any other Type selects a parametric function evaluated with Params.

type DateTimeNumber

type DateTimeNumber struct {
	Year, Month, Day, Hours, Minutes, Seconds uint16
}

DateTimeNumber mirrors cmsDateTimeNumber: the six 16-bit fields of an ICC date/time, stored as their natural (decoded) values (Year is the full year, Month is 1..12).

type Dict

type Dict struct {
	// contains filtered or unexported fields
}

Dict mirrors _cmsDICT: the linked-list head plus its context.

func DictAlloc

func DictAlloc() *Dict

DictAlloc on the default context.

func (*Dict) AddEntry

func (d *Dict) AddEntry(name, value []rune, displayName, displayValue *MLU) bool

AddEntry ports cmsDictAddEntry: prepend a new entry. Name must be non-nil.

func (*Dict) Dup

func (d *Dict) Dup() *Dict

Dup ports cmsDictDup: a copy whose iteration order is the reverse of the original's, exactly as the reference walk-and-prepend produces.

func (*Dict) GetEntryList

func (d *Dict) GetEntryList() *DictEntry

GetEntryList ports cmsDictGetEntryList: the head of the linked list.

type DictEntry

type DictEntry struct {
	Next         *DictEntry
	DisplayName  *MLU
	DisplayValue *MLU
	Name         []rune
	Value        []rune
}

DictEntry mirrors cmsDICTentry: a name/value pair with optional localized display strings. Name and Value hold code points (Value may be nil).

func (*DictEntry) NextEntry

func (e *DictEntry) NextEntry() *DictEntry

NextEntry ports cmsDictNextEntry.

type Error

type Error struct {
	Code ErrorCode
	Msg  string
}

Error is the error type returned by all fallible operations in this package. It carries the lcms2 error class and a human-readable message matching the reference implementation's wording where practical.

All exported APIs declare their return type as the plain error interface, so this package composes with standard Go error handling; use errors.As to recover the *Error and inspect its Code. Internal constructors (errorf, signalError) never return a nil *Error, so no typed-nil interface can leak.

func (*Error) Error

func (e *Error) Error() string

func (*Error) Is

func (e *Error) Is(target error) bool

Is reports whether target matches this error by code, so callers can use errors.Is with a sentinel &Error{Code: c}.

type ErrorCode

type ErrorCode uint32

ErrorCode identifies the class of a library error, mirroring the C cmsERROR_* constants.

const (
	ErrUndefined          ErrorCode = 0  // cmsERROR_UNDEFINED
	ErrFile               ErrorCode = 1  // cmsERROR_FILE
	ErrRange              ErrorCode = 2  // cmsERROR_RANGE
	ErrInternal           ErrorCode = 3  // cmsERROR_INTERNAL
	ErrNull               ErrorCode = 4  // cmsERROR_NULL
	ErrRead               ErrorCode = 5  // cmsERROR_READ
	ErrSeek               ErrorCode = 6  // cmsERROR_SEEK
	ErrWrite              ErrorCode = 7  // cmsERROR_WRITE
	ErrUnknownExtension   ErrorCode = 8  // cmsERROR_UNKNOWN_EXTENSION
	ErrColorspaceCheck    ErrorCode = 9  // cmsERROR_COLORSPACE_CHECK
	ErrAlreadyDefined     ErrorCode = 10 // cmsERROR_ALREADY_DEFINED
	ErrBadSignature       ErrorCode = 11 // cmsERROR_BAD_SIGNATURE
	ErrCorruptionDetected ErrorCode = 12 // cmsERROR_CORRUPTION_DETECTED
	ErrNotSuitable        ErrorCode = 13 // cmsERROR_NOT_SUITABLE
)

type Formatter

type Formatter struct {
	Fmt16    Formatter16
	FmtFloat FormatterFloat
}

Formatter is the tagged analogue of the cmsFormatter union: exactly one of Fmt16 / FmtFloat is non-nil (or both nil when no formatter matched).

func GetFormatter

func GetFormatter(typ uint32, dir FormatterDirection, dwFlags uint32) Formatter

GetFormatter looks up a formatter in the default context (package-level convenience mirroring _cmsGetFormatter(NULL, ...)).

type Formatter16

type Formatter16 func(info *FormatterInfo, values []uint16, buf []byte, stride int) int

Formatter16 unpacks (input) or packs (output) one pixel using the 16-bit working array. It mirrors cmsFormatter16.

The values slice is the per-pixel working buffer and must have at least MaxChannels elements: some formatters write more slots than the format has channels (for example the grayscale unpacker replicates its single sample across three), so sizing values by channel count is not sufficient and would index out of range. The transform engine always supplies a full-width buffer; callers using GetFormatter directly are responsible for the same.

type FormatterDirection

type FormatterDirection int

FormatterDirection mirrors cmsFormatterDirection.

const (
	FormatterInput  FormatterDirection = 0 // cmsFormatterInput
	FormatterOutput FormatterDirection = 1 // cmsFormatterOutput
)

Formatter directions.

type FormatterFactory

type FormatterFactory func(typ uint32, dir FormatterDirection, flags uint32) Formatter

FormatterFactory mirrors cmsFormatterFactory: a plug-in supplied function that returns a Formatter for a given format, direction and flags, or a zero Formatter to decline (so the next factory / the stock table is consulted).

type FormatterFloat

type FormatterFloat func(info *FormatterInfo, values []float32, buf []byte, stride int) int

FormatterFloat is the float32 analogue, mirroring cmsFormatterFloat. The same working-buffer contract as Formatter16 applies: values must have at least MaxChannels elements.

type FormatterInfo

type FormatterInfo struct {
	InputFormat  uint32
	OutputFormat uint32
}

FormatterInfo carries the two transform fields the pixel formatters consult. In the C reference the formatter receives the whole _cmsTRANSFORM; cmspack.c reads only InputFormat and OutputFormat from it. W12 (xform.go) will populate one from its Transform. buf is the slice starting at the current pixel; a formatter returns the number of bytes by which the accumulator advanced (the per-pixel loop then reslices buf = buf[delta:]).

type ICCData

type ICCData struct {
	Flag uint32 // 0 = ASCII, 1 = binary
	Data []byte
}

ICCData mirrors cmsICCData: the payload of a dataType tag.

type ICCMeasurementConditions

type ICCMeasurementConditions struct {
	Observer       uint32
	Backing        CIEXYZ
	Geometry       uint32
	Flare          float64
	IlluminantType uint32
}

ICCMeasurementConditions mirrors cmsICCMeasurementConditions.

type ICCViewingConditions

type ICCViewingConditions struct {
	IlluminantXYZ  CIEXYZ
	SurroundXYZ    CIEXYZ
	IlluminantType uint32
}

ICCViewingConditions mirrors cmsICCViewingConditions.

type IOHandler

type IOHandler struct {
	ContextID    *Context
	UsedSpace    uint32
	ReportedSize uint32
	PhysicalFile string
	// contains filtered or unexported fields
}

IOHandler is the pure-Go replacement for cmsIOHANDLER. It abstracts reading and writing over a memory block, an *os.File, or a byte counter (the NULL handler), so the profile container code is agnostic to the storage medium.

func OpenIOhandlerFromNULL

func OpenIOhandlerFromNULL() *IOHandler

OpenIOhandlerFromNULL creates a NULL handler on the default context.

func (*IOHandler) Close

func (io *IOHandler) Close() error

Close releases the handler, mirroring cmsCloseIOhandler.

func (*IOHandler) Read

func (io *IOHandler) Read(buf []byte, size, count uint32) uint32

Read reads count elements of size bytes each into buf and returns the number of elements read (0 on error), mirroring io->Read.

func (*IOHandler) Seek

func (io *IOHandler) Seek(offset uint32) bool

Seek positions the handler at offset from the start and reports success, mirroring io->Seek (SEEK_SET semantics).

func (*IOHandler) Tell

func (io *IOHandler) Tell() uint32

Tell returns the current position, mirroring io->Tell.

func (*IOHandler) Write

func (io *IOHandler) Write(size uint32, buf []byte) bool

Write writes the first size bytes of buf and reports success, mirroring io->Write. It updates UsedSpace like the C handlers.

type IT8

type IT8 struct {
	// contains filtered or unexported fields
}

IT8 is the pure-Go replacement for the C cmsIT8 handle. It holds the parsed (or being-built) sheet: its tables, the parser state machine, and the shared keyword/sample-id vocabularies.

func IT8Alloc

func IT8Alloc(ctx *Context) *IT8

IT8Alloc creates an empty IT8 container (the C cmsIT8Alloc). A nil context uses the default context.

func IT8LoadFromFile

func IT8LoadFromFile(ctx *Context, fileName string) (*IT8, error)

IT8LoadFromFile parses an IT8/CGATS sheet from a file (the C cmsIT8LoadFromFile).

func IT8LoadFromMem

func IT8LoadFromMem(ctx *Context, data []byte) (*IT8, error)

IT8LoadFromMem parses an IT8/CGATS sheet from memory (the C cmsIT8LoadFromMem). It returns an error when the input is not recognized or a syntax error is found.

func (*IT8) DefineDblFormat

func (it8 *IT8) DefineDblFormat(formatter string)

DefineDblFormat sets the printf-style formatter for doubles (the C cmsIT8DefineDblFormat). An empty formatter restores the default.

func (*IT8) EnumDataFormat

func (it8 *IT8) EnumDataFormat() ([]string, int)

EnumDataFormat returns the current table's column labels and count (the C cmsIT8EnumDataFormat).

func (*IT8) EnumProperties

func (it8 *IT8) EnumProperties() []string

EnumProperties returns the property names of the current table in order (the C cmsIT8EnumProperties).

func (*IT8) EnumPropertyMulti

func (it8 *IT8) EnumPropertyMulti(prop string) []string

EnumPropertyMulti returns the subkey names of a multi property (the C cmsIT8EnumPropertyMulti). It mirrors the C quirk of reporting the head node's subkey for each subkey link.

func (*IT8) FindDataFormat

func (it8 *IT8) FindDataFormat(cSample string) int

FindDataFormat returns the column index of a sample name (the C cmsIT8FindDataFormat).

func (*IT8) Free

func (it8 *IT8) Free()

Free releases the container. Under the Go GC nothing is freed; it exists for symmetry with cmsIT8Free and is safe to call on nil.

func (*IT8) GetData

func (it8 *IT8) GetData(cPatch, cSample string) (string, bool)

GetData returns a cell by patch+sample name, with a present flag (the C cmsIT8GetData).

func (*IT8) GetDataDbl

func (it8 *IT8) GetDataDbl(cPatch, cSample string) float64

GetDataDbl returns a cell by patch+sample parsed as a double (the C cmsIT8GetDataDbl).

func (*IT8) GetDataRowCol

func (it8 *IT8) GetDataRowCol(row, col int) (string, bool)

GetDataRowCol returns a cell by row/col, with a present flag (the C cmsIT8GetDataRowCol, which returns NULL when absent).

func (*IT8) GetDataRowColDbl

func (it8 *IT8) GetDataRowColDbl(row, col int) float64

GetDataRowColDbl returns a cell parsed as a double, or 0 (the C cmsIT8GetDataRowColDbl).

func (*IT8) GetPatchByName

func (it8 *IT8) GetPatchByName(cPatch string) int

GetPatchByName returns the patch index for a SAMPLE_ID (the C cmsIT8GetPatchByName).

func (*IT8) GetPatchName

func (it8 *IT8) GetPatchName(nPatch int) (string, bool)

GetPatchName returns the SAMPLE_ID of patch nPatch, with a present flag (the C cmsIT8GetPatchName).

func (*IT8) GetProperty

func (it8 *IT8) GetProperty(key string) (string, bool)

GetProperty returns a property value and whether it exists (the C cmsIT8GetProperty, which returns NULL when absent).

func (*IT8) GetPropertyDbl

func (it8 *IT8) GetPropertyDbl(prop string) float64

GetPropertyDbl returns a property parsed as a double, or 0 when absent (the C cmsIT8GetPropertyDbl).

func (*IT8) GetPropertyMulti

func (it8 *IT8) GetPropertyMulti(key, subKey string) (string, bool)

GetPropertyMulti returns a subkey value and whether it exists (the C cmsIT8GetPropertyMulti).

func (*IT8) GetSheetType

func (it8 *IT8) GetSheetType() string

GetSheetType returns the current table's sheet type (the C cmsIT8GetSheetType).

func (*IT8) SaveToFile

func (it8 *IT8) SaveToFile(fileName string) error

SaveToFile writes the sheet to a file (the C cmsIT8SaveToFile), erroring when any table lacks its data or data-format section.

func (*IT8) SaveToMem

func (it8 *IT8) SaveToMem() ([]byte, error)

SaveToMem serializes the whole sheet to a byte slice, byte-for-byte identical to the C cmsIT8SaveToMem text excluding the trailing NUL C appends (which equals the C cmsIT8SaveToFile output).

func (*IT8) SetComment

func (it8 *IT8) SetComment(val string) bool

SetComment adds a comment line to the current table (the C cmsIT8SetComment).

func (*IT8) SetData

func (it8 *IT8) SetData(cPatch, cSample, val string) bool

SetData writes a cell by patch+sample name (the C cmsIT8SetData). When the table is empty it allocates format+data and, for SAMPLE_ID, appends a patch.

func (*IT8) SetDataDbl

func (it8 *IT8) SetDataDbl(cPatch, cSample string, val float64) bool

SetDataDbl writes a cell by patch+sample formatted with the double formatter (the C cmsIT8SetDataDbl).

func (*IT8) SetDataFormat

func (it8 *IT8) SetDataFormat(n int, sample string) bool

SetDataFormat sets the label of column n (the C cmsIT8SetDataFormat).

func (*IT8) SetDataRowCol

func (it8 *IT8) SetDataRowCol(row, col int, val string) bool

SetDataRowCol writes a cell by row/col (the C cmsIT8SetDataRowCol).

func (*IT8) SetDataRowColDbl

func (it8 *IT8) SetDataRowColDbl(row, col int, val float64) bool

SetDataRowColDbl writes a cell formatted with the double formatter (the C cmsIT8SetDataRowColDbl).

func (*IT8) SetIndexColumn

func (it8 *IT8) SetIndexColumn(cSample string) bool

SetIndexColumn selects the column used as the patch index (the C cmsIT8SetIndexColumn).

func (*IT8) SetPropertyDbl

func (it8 *IT8) SetPropertyDbl(prop string, val float64) bool

SetPropertyDbl sets a numeric property formatted with the double formatter (the C cmsIT8SetPropertyDbl).

func (*IT8) SetPropertyHex

func (it8 *IT8) SetPropertyHex(prop string, val uint32) bool

SetPropertyHex sets a hexadecimal property (the C cmsIT8SetPropertyHex). The value is stored decimal and re-rendered as 0xNN on save.

func (*IT8) SetPropertyMulti

func (it8 *IT8) SetPropertyMulti(key, subKey, buffer string) bool

SetPropertyMulti sets a subkey/value pair property (the C cmsIT8SetPropertyMulti).

func (*IT8) SetPropertyStr

func (it8 *IT8) SetPropertyStr(key, val string) bool

SetPropertyStr sets a string property (the C cmsIT8SetPropertyStr).

func (*IT8) SetPropertyUncooked

func (it8 *IT8) SetPropertyUncooked(key, buffer string) bool

SetPropertyUncooked sets a verbatim property (the C cmsIT8SetPropertyUncooked).

func (*IT8) SetSheetType

func (it8 *IT8) SetSheetType(typ string) bool

SetSheetType sets the current table's sheet type (the C cmsIT8SetSheetType).

func (*IT8) SetTable

func (it8 *IT8) SetTable(nTable uint32) int

SetTable selects (and, when nTable == TablesCount, appends) a table, returning the table index or -1 on error (the C cmsIT8SetTable).

func (*IT8) SetTableByLabel

func (it8 *IT8) SetTableByLabel(cSet, cField, expectedType string) int

SetTableByLabel resolves the LABEL extension, selecting the referenced table (the C cmsIT8SetTableByLabel). Returns the selected table index or -1.

func (*IT8) TableCount

func (it8 *IT8) TableCount() uint32

TableCount returns the number of tables (the C cmsIT8TableCount).

type InfoType

type InfoType int

InfoType selects which descriptive MLU tag a profile-info accessor reads, mirroring cmsInfoType.

const (
	InfoDescription InfoType = iota
	InfoManufacturer
	InfoModel
	InfoCopyright
)

type IntentFn

type IntentFn func(ctx *Context, nProfiles uint32, intents []uint32, profiles []*Profile,
	bpc []bool, adaptationStates []float64, dwFlags uint32) (*Pipeline, error)

IntentFn is the Go analogue of cmsIntentFn: an intent handler that builds the device-link pipeline chaining nProfiles profiles. The slices carry one entry per profile (intents, profiles, BPC flags, adaptation states).

type InterpFn16

type InterpFn16 func(input, output []uint16, p *InterpParams)

InterpFn16 is the 16-bit forward interpolation callback, mirroring _cmsInterpFn16. It reads len==nInputs samples from input and writes len==nOutputs samples to output.

type InterpFnFactory

type InterpFnFactory func(nInputChannels, nOutputChannels, dwFlags uint32) InterpFunction

InterpFnFactory mirrors cmsInterpFnFactory: given the channel counts and the selection flags it returns the interpolator to use, or a zero InterpFunction if the combination is unsupported.

type InterpFnFloat

type InterpFnFloat func(input, output []float32, p *InterpParams)

InterpFnFloat is the float32 forward interpolation callback, mirroring _cmsInterpFnFloat.

type InterpFunction

type InterpFunction struct {
	Lerp16    InterpFn16    // forward interpolation in 16 bits
	LerpFloat InterpFnFloat // forward interpolation in floating point
}

InterpFunction mirrors the cmsInterpFunction union: a holder for either a 16-bit or a float32 interpolator. Unlike the C union the two callbacks live in separate fields; the "which member is set" test in _cmsSetInterpolationRoutine is reproduced by checking both fields (see setInterpolationRoutine).

type InterpParams

type InterpParams struct {
	ContextID *Context // the owning context

	Flags      uint32 // original flags (CMS_LERP_FLAGS_*)
	NumInputs  uint32 // number of input channels
	NumOutputs uint32 // number of output channels

	NumSamples [maxInputDimensions]uint32 // nodes per input direction
	Domain     [maxInputDimensions]uint32 // Domain = nSamples - 1
	Opta       [maxInputDimensions]uint32 // grid strides, premultiplied per dimension

	Interpolation InterpFunction // the selected interpolator
	// contains filtered or unexported fields
}

InterpParams mirrors cmsInterpParams (the public interpolation descriptor in include/lcms2_plugin.h). It precomputes everything the interpolators need: the per-dimension domain (nodes minus one) and the opta strides that index the flattened CLUT. The table is held as one of two typed views; exactly one of table16/tableFloat is set, matching the const void* Table union in C.

func (*InterpParams) Eval16

func (p *InterpParams) Eval16(input, output []uint16)

Eval16 runs the selected 16-bit interpolator; input has NumInputs samples and output receives NumOutputs samples.

func (*InterpParams) EvalFloat

func (p *InterpParams) EvalFloat(input, output []float32)

EvalFloat runs the selected float32 interpolator.

func (*InterpParams) Table16

func (p *InterpParams) Table16() []uint16

Table16 returns the 16-bit CLUT view, or nil for a float table.

func (*InterpParams) TableFloat

func (p *InterpParams) TableFloat() []float32

TableFloat returns the float32 CLUT view, or nil for a 16-bit table.

type JCh

type JCh struct {
	J, C float64
	// contains filtered or unexported fields
}

JCh is a color in the CIECAM02 J (lightness), C (chroma), h (hue) space (cmsJCh).

type LogErrorHandlerFunc

type LogErrorHandlerFunc func(ctx *Context, code ErrorCode, text string)

LogErrorHandlerFunc is the optional per-context error logger. It mirrors the C cmsLogErrorHandlerFunction callback: it is invoked with the originating context, the error class, and an English description whenever the library signals an error. The returned *Error remains the primary error channel; a handler is a passive observer and must not terminate the program.

type MAT3

type MAT3 [3]VEC3

MAT3 is a 3x3 matrix of float64, stored as three row vectors (cmsMAT3).

func MAT3Identity

func MAT3Identity() MAT3

MAT3Identity returns the 3x3 identity matrix (_cmsMAT3identity).

func MAT3Inverse

func MAT3Inverse(a MAT3) (b MAT3, ok bool)

MAT3Inverse returns b = a^(-1) and ok=true, or ok=false when a is singular (|det| < matrixDetTolerance). Mirrors _cmsMAT3inverse, which returns cmsBool with no error signalling; a bool is used here rather than an error to match that hot-path semantics.

func MAT3Per

func MAT3Per(a, b MAT3) MAT3

MAT3Per returns the matrix product a*b (_cmsMAT3per). The multiply-accumulate order matches the C ROWCOL macro exactly.

type MHC2Type

type MHC2Type struct {
	CurveEntries  uint32
	RedCurve      []float64
	GreenCurve    []float64
	BlueCurve     []float64
	MinLuminance  float64
	PeakLuminance float64
	XYZ2XYZmatrix [3][4]float64
}

MHC2Type mirrors cmsMHC2Type (Microsoft's MHC2 tag).

type MLU

type MLU struct {
	// contains filtered or unexported fields
}

MLU mirrors cmsMLU (struct _cms_MLU_struct): a set of localized strings keyed by language/country, stored in a shared pool of code points.

func NewMLU

func NewMLU(nItems uint32) *MLU

NewMLU allocates an MLU on the default context.

func (*MLU) Dup

func (mlu *MLU) Dup() *MLU

Dup ports cmsMLUdup: an independent copy. A nil receiver duplicates to nil.

func (*MLU) GetASCII

func (mlu *MLU) GetASCII(lang, cntry string) string

GetASCII ports cmsMLUgetASCII for callers wanting a Go string (terminator stripped). An absent translation yields "".

func (*MLU) GetTranslation

func (mlu *MLU) GetTranslation(lang, cntry string) (obtainedLang, obtainedCntry string, ok bool)

GetTranslation ports cmsMLUgetTranslation: the language/country actually used for a requested pair, or ok=false when there is no match.

func (*MLU) GetUTF8

func (mlu *MLU) GetUTF8(lang, cntry string) string

GetUTF8 ports cmsMLUgetUTF8 for callers wanting a Go string.

func (*MLU) GetWide

func (mlu *MLU) GetWide(lang, cntry string) []rune

GetWide ports cmsMLUgetWide for callers wanting the code points (terminator stripped).

func (*MLU) SetASCII

func (mlu *MLU) SetASCII(lang, cntry, s string) bool

SetASCII ports cmsMLUsetASCII: add an ASCII string for a language/country. An empty string is stored as a single NUL code point (no terminator is added for non-empty strings, per ICC1v43 clause 4.1).

func (*MLU) SetUTF8

func (mlu *MLU) SetUTF8(lang, cntry, s string) bool

SetUTF8 ports cmsMLUsetUTF8: add a UTF-8 string.

func (*MLU) SetWide

func (mlu *MLU) SetWide(lang, cntry string, wide []rune) bool

SetWide ports cmsMLUsetWide: add a wide (code-point) string. An empty string is stored as a single NUL code point.

func (*MLU) SetWideString

func (mlu *MLU) SetWideString(lang, cntry, s string) bool

SetWideString is a convenience wrapper of SetWide taking a Go string.

func (*MLU) TranslationsCodes

func (mlu *MLU) TranslationsCodes(idx uint32) (lang, cntry string, ok bool)

TranslationsCodes ports cmsMLUtranslationsCodes: the language/country of the idx-th entry.

func (*MLU) TranslationsCount

func (mlu *MLU) TranslationsCount() uint32

TranslationsCount ports cmsMLUtranslationsCount.

type NamedColorList

type NamedColorList struct {
	// contains filtered or unexported fields
}

NamedColorList mirrors cmsNAMEDCOLORLIST: an ordered list of named colors with a shared prefix/suffix and a fixed colorant count.

func AllocNamedColorList

func AllocNamedColorList(n, colorantCount uint32, prefix, suffix string) *NamedColorList

AllocNamedColorList allocates a named color list on the default context.

func (*NamedColorList) AppendNamedColor

func (v *NamedColorList) AppendNamedColor(name string, pcs *[3]uint16, colorant *[maxChannels]uint16) bool

AppendNamedColor ports cmsAppendNamedColor. A nil colorant/PCS stores zeros.

func (*NamedColorList) ColorantCount

func (v *NamedColorList) ColorantCount() uint32

ColorantCount reports the number of device coordinates per color.

func (*NamedColorList) Count

func (v *NamedColorList) Count() uint32

Count ports cmsNamedColorCount.

func (*NamedColorList) Dup

func (v *NamedColorList) Dup() *NamedColorList

Dup ports cmsDupNamedColorList.

func (*NamedColorList) Index

func (v *NamedColorList) Index(name string) int32

Index ports cmsNamedColorIndex: the position of a color by name (ASCII case-insensitive), or -1.

func (*NamedColorList) Info

func (v *NamedColorList) Info(nColor uint32) (name, prefix, suffix string, pcs [3]uint16, colorant [maxChannels]uint16, ok bool)

Info ports cmsNamedColorInfo: the name/prefix/suffix/PCS/colorant of a color.

func (*NamedColorList) Prefix

func (v *NamedColorList) Prefix() string

Prefix/Suffix expose the shared name affixes.

func (*NamedColorList) Suffix

func (v *NamedColorList) Suffix() string

type OptimizeFn

type OptimizeFn func(ctx *Context, lut **Pipeline, intent uint32,
	inputFormat, outputFormat, dwFlags *uint32) bool

OptimizeFn mirrors _cmsOPToptimizeFn: an optimizer receives the pipeline by double pointer (it may replace it) and may adjust the formats and flags. It returns true when it installed an optimized evaluator.

type PSResourceType

type PSResourceType int

PSResourceType selects the kind of PostScript colour resource, mirroring cmsPSResourceType.

const (
	// PSResourceCSA is a PostScript ColorSpaceArray (cmsPS_RESOURCE_CSA).
	PSResourceCSA PSResourceType = 0
	// PSResourceCRD is a PostScript ColorRenderingDictionary (cmsPS_RESOURCE_CRD).
	PSResourceCRD PSResourceType = 1
)

type PSeqDesc

type PSeqDesc struct {
	DeviceMfg    uint32
	DeviceModel  uint32
	Attributes   uint64
	Technology   uint32
	ProfileID    [16]byte
	Manufacturer *MLU
	Model        *MLU
	Description  *MLU
}

PSeqDesc mirrors cmsPSEQDESC: one profile's identification within a sequence.

type Pipeline

type Pipeline struct {
	InputChannels  uint32
	OutputChannels uint32
	// contains filtered or unexported fields
}

Pipeline mirrors cmsPipeline (struct _cmsPipeline_struct).

func PipelineAlloc

func PipelineAlloc(inputChannels, outputChannels uint32) (*Pipeline, error)

PipelineAlloc builds a pipeline on the default context.

func (*Pipeline) Cat

func (lut *Pipeline) Cat(l2 *Pipeline) error

Cat ports cmsPipelineCat: append a deep copy of l2's stages to lut.

func (*Pipeline) CheckAndRetrieveStages

func (lut *Pipeline) CheckAndRetrieveStages(types ...StageSignature) ([]*Stage, bool)

CheckAndRetrieveStages ports cmsPipelineCheckAndRetreiveStages: if the pipeline's stage types match types exactly (in order), return the stages and true; otherwise nil and false.

func (*Pipeline) ContextID

func (lut *Pipeline) ContextID() *Context

ContextID ports cmsGetPipelineContextID.

func (*Pipeline) Dup

func (lut *Pipeline) Dup() (*Pipeline, error)

Dup ports cmsPipelineDup: a deep, independent copy.

func (*Pipeline) Eval16

func (lut *Pipeline) Eval16(in, out []uint16)

Eval16 ports cmsPipelineEval16.

func (*Pipeline) EvalFloat

func (lut *Pipeline) EvalFloat(in, out []float32)

EvalFloat ports cmsPipelineEvalFloat. Note the asymmetry with Eval16: the reference passes the pipeline itself here (only the 16-bit path receives lut->Data), so an optimization plug-in's private data feeds the 16-bit evaluator only.

func (*Pipeline) EvalReverseFloat

func (lut *Pipeline) EvalReverseFloat(target, result, hint []float32) bool

EvalReverseFloat ports cmsPipelineEvalReverseFloat: Newton-Raphson reverse evaluation for 3->3 and 4->3 pipelines. Returns false when the pipeline is not invertible in this way or the Jacobian is singular.

func (*Pipeline) Free

func (lut *Pipeline) Free()

Free ports cmsPipelineFree: a no-op under the Go garbage collector (the optional FreeDataFn is still honoured for parity with optimization plug-ins).

func (*Pipeline) GetPtrToFirstStage

func (lut *Pipeline) GetPtrToFirstStage() *Stage

GetPtrToFirstStage ports cmsPipelineGetPtrToFirstStage.

func (*Pipeline) GetPtrToLastStage

func (lut *Pipeline) GetPtrToLastStage() *Stage

GetPtrToLastStage ports cmsPipelineGetPtrToLastStage.

func (*Pipeline) InputChannelsCount

func (lut *Pipeline) InputChannelsCount() uint32

InputChannelsCount ports cmsPipelineInputChannels.

func (*Pipeline) InsertStage

func (lut *Pipeline) InsertStage(loc StageLoc, mpe *Stage) error

InsertStage ports cmsPipelineInsertStage.

func (*Pipeline) OutputChannelsCount

func (lut *Pipeline) OutputChannelsCount() uint32

OutputChannelsCount ports cmsPipelineOutputChannels.

func (*Pipeline) SetSaveAs8bitsFlag

func (lut *Pipeline) SetSaveAs8bitsFlag(on bool) bool

SetSaveAs8bitsFlag ports cmsPipelineSetSaveAs8bitsFlag: sets the flag and returns its previous value.

func (*Pipeline) StageCount

func (lut *Pipeline) StageCount() uint32

StageCount ports cmsPipelineStageCount.

func (*Pipeline) UnlinkStage

func (lut *Pipeline) UnlinkStage(loc StageLoc) *Stage

UnlinkStage ports cmsPipelineUnlinkStage: remove a stage and return it.

type PlatformSignature

type PlatformSignature uint32

PlatformSignature mirrors cmsPlatformSignature: the primary platform in the header.

const (
	SigMacintosh PlatformSignature = 0x4150504C // 'APPL'
	SigMicrosoft PlatformSignature = 0x4D534654 // 'MSFT'
	SigSolaris   PlatformSignature = 0x53554E57 // 'SUNW'
	SigSGI       PlatformSignature = 0x53474920 // 'SGI '
	SigTaligent  PlatformSignature = 0x54474E54 // 'TGNT'
	SigUnices    PlatformSignature = 0x2A6E6978 // '*nix'
)

ICC platform signatures (cmsPlatformSignature, include/lcms2.h).

func (PlatformSignature) String

func (s PlatformSignature) String() string

String renders the signature as four ASCII characters (big-endian order).

type Plugin

type Plugin interface {
	// Base returns the embedded plug-in header (magic, version, type, next).
	Base() *PluginBase
}

Plugin is the Go analogue of a pointer to cmsPluginBase. Concrete plug-in types embed PluginBase, so a pointer to them satisfies this interface and carries the family-specific payload that later phases interpret.

type PluginBase

type PluginBase struct {
	Magic           uint32 // must equal pluginMagicNumber ('acpp')
	ExpectedVersion uint32 // minimum library version the plug-in needs
	Type            uint32 // one of the pluginXxxSig family signatures
	Next            Plugin // next plug-in in the bundle, or nil
}

PluginBase mirrors cmsPluginBase (the _cmsPluginBaseStruct header). Every concrete plug-in embeds it as its first field and is reached through the Plugin interface. Next chains multiple plug-ins so a single RegisterPlugins call can install several at once, exactly like the C Next pointer.

func (*PluginBase) Base

func (b *PluginBase) Base() *PluginBase

Base returns the plug-in header. It lets a *PluginBase (and, by embedding, any concrete plug-in) satisfy the Plugin interface.

type PluginFormatters

type PluginFormatters struct {
	PluginBase
	FormattersFactory FormatterFactory
}

PluginFormatters mirrors cmsPluginFormatters: registers one formatter factory. A pointer to it satisfies Plugin.

func NewPluginFormatters

func NewPluginFormatters(factory FormatterFactory) *PluginFormatters

NewPluginFormatters builds a formatters plug-in with the standard header.

type PluginInterpolation

type PluginInterpolation struct {
	PluginBase
	Factory InterpFnFactory
}

PluginInterpolation mirrors cmsPluginInterpolation: a plug-in that replaces the built-in interpolator-selection factory. Register it through (*Context).RegisterPlugins; the newest registered factory wins and, when it returns an empty InterpFunction, the built-in factory is used as a fallback.

type PluginOptimization

type PluginOptimization struct {
	PluginBase
	OptimizePtr OptimizeFn
}

PluginOptimization mirrors cmsPluginOptimization: registers a new optimizer. Register it through (*Context).RegisterPlugins; the newest registered optimizer is consulted first, before the built-in collection.

type PluginParametricCurves

type PluginParametricCurves struct {
	PluginBase
	NFunctions     uint32
	FunctionTypes  []int32
	ParameterCount []uint32
	Evaluator      parametricEvaluator
}

PluginParametricCurves mirrors cmsPluginParametricCurves: a plug-in that adds one or more parametric function types, each with a fixed parameter count, all served by a single Evaluator. Register it through (*Context).RegisterPlugins; the plug-in header's Type must be the parametric-curve signature.

type PluginRenderingIntent

type PluginRenderingIntent struct {
	PluginBase
	Intent      uint32
	Link        IntentFn
	Description string
}

PluginRenderingIntent mirrors cmsPluginRenderingIntent: a plug-in that adds a new intent number or overrides a default routine. Embed it and set Base().Type to pluginRenderingIntentSig, then register it with RegisterPlugins.

type PluginTag

type PluginTag struct {
	PluginBase
	Signature  TagSignature
	Descriptor TagDescriptor
}

PluginTag is the plug-in payload that registers one tag descriptor, mirroring cmsPluginTag. A pointer to it satisfies Plugin.

type PluginTagType

type PluginTagType struct {
	PluginBase
	Handler TagTypeHandler
}

PluginTagType is the plug-in payload that registers one tag-type handler, mirroring cmsPluginTagType. A pointer to it satisfies Plugin.

type Profile

type Profile struct {
	// contains filtered or unexported fields
}

Profile is the pure-Go replacement for cmsHPROFILE (_cmsICCPROFILE). It is not safe for concurrent mutation; the embedded mutex guards the tag-read cache and the serializer, matching the intent of the C UsrMutex.

func CreateBCHSWabstractProfile

func CreateBCHSWabstractProfile(nLUTPoints uint32, bright, contrast, hue, saturation float64,
	tempSrc, tempDest uint32) (*Profile, error)

CreateBCHSWabstractProfile builds a BCHSW abstract profile on the default context.

func CreateDeviceLinkFromCubeFile

func CreateDeviceLinkFromCubeFile(fileName string) (*Profile, error)

CreateDeviceLinkFromCubeFile builds a .cube device link on the default context (the C cmsCreateDeviceLinkFromCubeFile).

func CreateDeviceLinkFromCubeMem

func CreateDeviceLinkFromCubeMem(data []byte) (*Profile, error)

CreateDeviceLinkFromCubeMem builds a .cube device link on the default context.

func CreateGrayProfile

func CreateGrayProfile(whitePoint *CIExyY, transferFunction *ToneCurve) (*Profile, error)

CreateGrayProfile builds a gray profile on the default context.

func CreateInkLimitingDeviceLink(colorSpace ColorSpaceSignature, limit float64) (*Profile, error)

CreateInkLimitingDeviceLink builds an ink-limiting device link on the default context.

func CreateLab2Profile

func CreateLab2Profile(whitePoint *CIExyY) (*Profile, error)

CreateLab2Profile builds a Lab v2 identity profile on the default context.

func CreateLab4Profile

func CreateLab4Profile(whitePoint *CIExyY) (*Profile, error)

CreateLab4Profile builds a Lab v4 identity profile on the default context.

func CreateLinearizationDeviceLink(colorSpace ColorSpaceSignature,
	transferFunctions []*ToneCurve) (*Profile, error)

CreateLinearizationDeviceLink builds a linearization device link on the default context.

func CreateNULLProfile

func CreateNULLProfile() (*Profile, error)

CreateNULLProfile builds a NULL profile on the default context.

func CreateProfilePlaceholder

func CreateProfilePlaceholder() *Profile

CreateProfilePlaceholder builds an empty profile on the default context.

func CreateRGBProfile

func CreateRGBProfile(whitePoint *CIExyY, primaries *CIExyYTRIPLE,
	transferFunction []*ToneCurve) (*Profile, error)

CreateRGBProfile builds an RGB matrix-shaper profile on the default context.

func CreateXYZProfile

func CreateXYZProfile() (*Profile, error)

CreateXYZProfile builds an XYZ identity profile on the default context.

func Create_OkLabProfile

func Create_OkLabProfile() (*Profile, error)

Create_OkLabProfile builds the OkLab profile on the default context.

func Create_sRGBProfile

func Create_sRGBProfile() (*Profile, error)

Create_sRGBProfile builds the sRGB profile on the default context.

Example
p, err := Create_sRGBProfile()
if err != nil {
	panic(err)
}
fmt.Println(p.GetColorSpace() == SigRgbData)
Output:
true

func OpenProfileFromFile

func OpenProfileFromFile(fileName, access string) (*Profile, error)

OpenProfileFromFile opens an ICC profile from disk on the default context.

func OpenProfileFromMem

func OpenProfileFromMem(buf []byte) (*Profile, error)

OpenProfileFromMem opens an ICC profile from a memory block on the default context.

func Transform2DeviceLink(hTransform *Transform, version float64, dwFlags uint32) (*Profile, error)

Transform2DeviceLink ports cmsTransform2DeviceLink: convert a transform into a device-link profile of the requested ICC version.

func (*Profile) CloseProfile

func (p *Profile) CloseProfile() error

CloseProfile releases the profile, saving it first if it was opened for writing, mirroring cmsCloseProfile.

func (*Profile) ComputeProfileID

func (p *Profile) ComputeProfileID() error

ComputeProfileID ports cmsMD5computeID: zero the flags, rendering intent and profile ID, serialize the profile, MD5 the bytes, and store the digest as the profile ID (per ICC 4.4 section 7.2.18). The header state is restored around the computation.

func (*Profile) Context

func (p *Profile) Context() *Context

Context returns the profile's context, mirroring cmsGetProfileContextID.

func (*Profile) DetectBlackPoint

func (p *Profile) DetectBlackPoint(intent, dwFlags uint32) (CIEXYZ, bool)

DetectBlackPoint ports cmsDetectBlackPoint. It returns the profile's source black point (relative to D50) and whether the detection succeeded; on failure the returned XYZ is zero, mirroring the reference which zeroes the point.

func (*Profile) DetectDestinationBlackPoint

func (p *Profile) DetectDestinationBlackPoint(intent, dwFlags uint32) (CIEXYZ, bool)

DetectDestinationBlackPoint ports cmsDetectDestinationBlackPoint, the Adobe black-point-compensation destination black algorithm. It returns the black point and whether detection succeeded (zero XYZ on failure).

func (*Profile) DetectRGBProfileGamma

func (p *Profile) DetectRGBProfileGamma(threshold float64) float64

DetectRGBProfileGamma ports cmsDetectRGBProfileGamma: estimate the working gamma of an RGB profile via a synthetic gray ramp; returns -1 on unsupported profiles.

func (*Profile) DetectTAC

func (p *Profile) DetectTAC() float64

DetectTAC ports cmsDetectTAC: detect the total area coverage of an output profile (result in %). Returns 0 for unsupported profiles.

func (*Profile) GetColorSpace

func (p *Profile) GetColorSpace() ColorSpaceSignature

GetColorSpace mirrors cmsGetColorSpace.

func (*Profile) GetDeviceClass

func (p *Profile) GetDeviceClass() ProfileClassSignature

GetDeviceClass mirrors cmsGetDeviceClass.

func (*Profile) GetEncodedICCversion

func (p *Profile) GetEncodedICCversion() uint32

GetEncodedICCversion mirrors cmsGetEncodedICCversion.

func (*Profile) GetHeaderAttributes

func (p *Profile) GetHeaderAttributes() uint64

GetHeaderAttributes mirrors cmsGetHeaderAttributes.

func (*Profile) GetHeaderCMM

func (p *Profile) GetHeaderCMM() uint32

GetHeaderCMM mirrors cmsGetHeaderCMM.

func (*Profile) GetHeaderCreationDateTime

func (p *Profile) GetHeaderCreationDateTime() time.Time

GetHeaderCreationDateTime mirrors cmsGetHeaderCreationDateTime, returning the creation timestamp as a UTC time.Time.

func (*Profile) GetHeaderCreator

func (p *Profile) GetHeaderCreator() uint32

GetHeaderCreator mirrors cmsGetHeaderCreator.

func (*Profile) GetHeaderFlags

func (p *Profile) GetHeaderFlags() uint32

GetHeaderFlags mirrors cmsGetHeaderFlags.

func (*Profile) GetHeaderManufacturer

func (p *Profile) GetHeaderManufacturer() uint32

GetHeaderManufacturer mirrors cmsGetHeaderManufacturer.

func (*Profile) GetHeaderModel

func (p *Profile) GetHeaderModel() uint32

GetHeaderModel mirrors cmsGetHeaderModel.

func (*Profile) GetHeaderRenderingIntent

func (p *Profile) GetHeaderRenderingIntent() uint32

GetHeaderRenderingIntent mirrors cmsGetHeaderRenderingIntent.

func (*Profile) GetPCS

func (p *Profile) GetPCS() ColorSpaceSignature

GetPCS mirrors cmsGetPCS.

func (*Profile) GetProfileID

func (p *Profile) GetProfileID() [16]byte

GetProfileID returns a copy of the 16-byte profile ID, mirroring cmsGetHeaderProfileID.

func (*Profile) GetProfileInfo

func (p *Profile) GetProfileInfo(info InfoType, languageCode, countryCode string, buffer []rune) uint32

GetProfileInfo ports cmsGetProfileInfo: copy the localized wide string into buffer (capacity in runes). Returns the number of wchar bytes required or written; see cmsMLUgetWide for the exact contract.

func (*Profile) GetProfileInfoASCII

func (p *Profile) GetProfileInfoASCII(info InfoType, languageCode, countryCode string, buffer []byte) uint32

GetProfileInfoASCII ports cmsGetProfileInfoASCII.

func (*Profile) GetProfileInfoUTF8

func (p *Profile) GetProfileInfoUTF8(info InfoType, languageCode, countryCode string, buffer []byte) uint32

GetProfileInfoUTF8 ports cmsGetProfileInfoUTF8.

func (*Profile) GetProfileVersion

func (p *Profile) GetProfileVersion() float64

GetProfileVersion mirrors cmsGetProfileVersion: 0x02100000 -> 2.10.

func (*Profile) GetTagCount

func (p *Profile) GetTagCount() int

GetTagCount returns the number of tags, mirroring cmsGetTagCount. A nil profile yields -1.

func (*Profile) GetTagOffsetAndSize

func (p *Profile) GetTagOffsetAndSize(n uint32) (offset, size uint32, ok bool)

GetTagOffsetAndSize returns the on-disk location of tag n, mirroring cmsGetTagOffsetAndSize.

func (*Profile) GetTagSignature

func (p *Profile) GetTagSignature(n uint32) TagSignature

GetTagSignature returns the signature of tag n, or 0 if out of range, mirroring cmsGetTagSignature.

func (*Profile) GetTagTrueType

func (p *Profile) GetTagTrueType(sig TagSignature) TagTypeSignature

GetTagTrueType ports _cmsGetTagTrueType: the true stored type of a tag, or 0.

func (*Profile) IOHandler

func (p *Profile) IOHandler() *IOHandler

IOHandler returns the profile's underlying IO handler, mirroring cmsGetProfileIOhandler.

func (*Profile) IsCLUT

func (p *Profile) IsCLUT(intent, usedDirection uint32) bool

IsCLUT ports cmsIsCLUT.

func (*Profile) IsIntentSupported

func (p *Profile) IsIntentSupported(intent, usedDirection uint32) bool

IsIntentSupported ports cmsIsIntentSupported.

func (*Profile) IsMatrixShaper

func (p *Profile) IsMatrixShaper() bool

IsMatrixShaper ports cmsIsMatrixShaper.

func (*Profile) IsTag

func (p *Profile) IsTag(sig TagSignature) bool

IsTag reports whether sig is present, mirroring cmsIsTag.

func (*Profile) LinkTag

func (p *Profile) LinkTag(sig, dest TagSignature) error

LinkTag ports cmsLinkTag: collapse sig onto dest so both share one block.

func (*Profile) ReadDevicelinkLUT

func (p *Profile) ReadDevicelinkLUT(intent uint32) (*Pipeline, error)

ReadDevicelinkLUT ports _cmsReadDevicelinkLUT: build the devicelink pipeline (also handles abstract profiles). No matrix-shaper fallback exists here.

func (*Profile) ReadInputLUT

func (p *Profile) ReadInputLUT(intent uint32) (*Pipeline, error)

ReadInputLUT ports _cmsReadInputLUT: build the device->PCS pipeline for an intent, handling named-color profiles, float tags, Lab V2/V4 fix-ups, and the matrix-shaper fallbacks. Intent > INTENT_ABSOLUTE_COLORIMETRIC forces the matrix-shaper path (used with 0xffffffff).

func (*Profile) ReadOutputLUT

func (p *Profile) ReadOutputLUT(intent uint32) (*Pipeline, error)

ReadOutputLUT ports _cmsReadOutputLUT: build the PCS->device pipeline.

func (*Profile) ReadProfileSequence

func (p *Profile) ReadProfileSequence() *ProfileSequence

ReadProfileSequence ports _cmsReadProfileSequence: combine the profile sequence description and profile sequence id tags into one structure.

func (*Profile) ReadRawTag

func (p *Profile) ReadRawTag(sig TagSignature, dst []byte) (uint32, error)

ReadRawTag ports cmsReadRawTag: copy up to len(dst) raw bytes of a tag into dst and return the number available. When dst is nil it returns the tag's on-disk size without copying.

func (*Profile) ReadTag

func (p *Profile) ReadTag(sig TagSignature) (any, error)

ReadTag ports cmsReadTag: parse (and cache) a tag's cooked value, following links. Until W8 populates the type tables this returns an error for every tag that is not already cached. A missing tag returns (nil, nil), matching the C NULL-without-error contract for "tag not present".

func (*Profile) SaveProfileToFile

func (p *Profile) SaveProfileToFile(fileName string) error

SaveProfileToFile serializes the profile to disk, mirroring cmsSaveProfileToFile.

func (*Profile) SaveProfileToMem

func (p *Profile) SaveProfileToMem() ([]byte, error)

SaveProfileToMem serializes the profile and returns the bytes, mirroring cmsSaveProfileToMem. It computes the exact size in a first pass, then writes.

func (*Profile) SetColorSpace

func (p *Profile) SetColorSpace(sig ColorSpaceSignature)

SetColorSpace mirrors cmsSetColorSpace.

func (*Profile) SetDeviceClass

func (p *Profile) SetDeviceClass(sig ProfileClassSignature)

SetDeviceClass mirrors cmsSetDeviceClass.

func (*Profile) SetEncodedICCversion

func (p *Profile) SetEncodedICCversion(v uint32)

SetEncodedICCversion mirrors cmsSetEncodedICCversion.

func (*Profile) SetHeaderAttributes

func (p *Profile) SetHeaderAttributes(a uint64)

SetHeaderAttributes mirrors cmsSetHeaderAttributes.

func (*Profile) SetHeaderCMM

func (p *Profile) SetHeaderCMM(cmm uint32)

SetHeaderCMM mirrors _cmsSetHeaderCMM.

func (*Profile) SetHeaderFlags

func (p *Profile) SetHeaderFlags(flags uint32)

SetHeaderFlags mirrors cmsSetHeaderFlags.

func (*Profile) SetHeaderManufacturer

func (p *Profile) SetHeaderManufacturer(m uint32)

SetHeaderManufacturer mirrors cmsSetHeaderManufacturer.

func (*Profile) SetHeaderModel

func (p *Profile) SetHeaderModel(m uint32)

SetHeaderModel mirrors cmsSetHeaderModel.

func (*Profile) SetHeaderRenderingIntent

func (p *Profile) SetHeaderRenderingIntent(intent uint32)

SetHeaderRenderingIntent mirrors cmsSetHeaderRenderingIntent.

func (*Profile) SetPCS

func (p *Profile) SetPCS(pcs ColorSpaceSignature)

SetPCS mirrors cmsSetPCS.

func (*Profile) SetProfileID

func (p *Profile) SetProfileID(id [16]byte)

SetProfileID sets the 16-byte profile ID, mirroring cmsSetHeaderProfileID.

func (*Profile) SetProfileVersion

func (p *Profile) SetProfileVersion(version float64)

SetProfileVersion mirrors cmsSetProfileVersion: 4.2 -> 0x04200000.

func (*Profile) TagLinkedTo

func (p *Profile) TagLinkedTo(sig TagSignature) TagSignature

TagLinkedTo ports cmsTagLinkedTo: the tag sig is linked to, or 0.

func (*Profile) WriteProfileSequence

func (p *Profile) WriteProfileSequence(seq *ProfileSequence) error

WriteProfileSequence ports _cmsWriteProfileSequence: write the sequence to the desc tag, and (for v4) also to the id tag.

func (*Profile) WriteRawTag

func (p *Profile) WriteRawTag(sig TagSignature, data []byte) error

WriteRawTag ports cmsWriteRawTag: stage raw bytes for a tag verbatim.

func (*Profile) WriteTag

func (p *Profile) WriteTag(sig TagSignature, value any) error

WriteTag ports cmsWriteTag: stage a cooked value for serialization, or delete the tag when value is nil. Cooked writes require W8's type tables.

type ProfileClassSignature

type ProfileClassSignature uint32

ProfileClassSignature mirrors cmsProfileClassSignature: the profile/device class in the header.

const (
	SigInputClass                   ProfileClassSignature = 0x73636E72 // 'scnr'
	SigDisplayClass                 ProfileClassSignature = 0x6D6E7472 // 'mntr'
	SigOutputClass                  ProfileClassSignature = 0x70727472 // 'prtr'
	SigLinkClass                    ProfileClassSignature = 0x6C696E6B // 'link'
	SigAbstractClass                ProfileClassSignature = 0x61627374 // 'abst'
	SigColorSpaceClass              ProfileClassSignature = 0x73706163 // 'spac'
	SigNamedColorClass              ProfileClassSignature = 0x6e6d636c // 'nmcl'
	SigColorEncodingSpaceClass      ProfileClassSignature = 0x63656E63 // 'cenc'
	SigMultiplexIdentificationClass ProfileClassSignature = 0x6D696420 // 'mid '
	SigMultiplexLinkClass           ProfileClassSignature = 0x6d6c6e6b // 'mlnk'
	SigMultiplexVisualizationClass  ProfileClassSignature = 0x6d766973 // 'mvis'
)

ICC profile-class signatures (cmsProfileClassSignature, include/lcms2.h).

func (ProfileClassSignature) String

func (s ProfileClassSignature) String() string

String renders the signature as four ASCII characters (big-endian order).

type ProfileSequence

type ProfileSequence struct {
	// contains filtered or unexported fields
}

ProfileSequence mirrors cmsSEQ: an ordered set of profile descriptors.

func AllocProfileSequenceDescription

func AllocProfileSequenceDescription(n uint32) *ProfileSequence

AllocProfileSequenceDescription on the default context.

func (*ProfileSequence) Dup

func (s *ProfileSequence) Dup() *ProfileSequence

Dup ports cmsDupProfileSequenceDescription.

func (*ProfileSequence) N

func (s *ProfileSequence) N() uint32

N reports the number of entries.

func (*ProfileSequence) Seq

func (s *ProfileSequence) Seq() []PSeqDesc

Seq exposes the descriptor slice for handlers in the same package.

type Sampler16

type Sampler16 func(in, out []uint16, cargo any) bool

Sampler16 mirrors cmsSAMPLER16: called on every grid knot during cmsStageSampleCLut16bit / cmsSliceSpace16. Returning false aborts the sweep (mirroring the C convention where a FALSE return stops sampling). out is nil for the slice-space samplers.

type SamplerFloat

type SamplerFloat func(in, out []float32, cargo any) bool

SamplerFloat mirrors cmsSAMPLERFLOAT.

type Screening

type Screening struct {
	Flag      uint32
	NChannels uint32
	Channels  [maxChannels]ScreeningChannel
}

Screening mirrors cmsScreening.

type ScreeningChannel

type ScreeningChannel struct {
	Frequency   float64
	ScreenAngle float64
	SpotShape   uint32
}

ScreeningChannel mirrors cmsScreeningChannel.

type Signature

type Signature uint32

Signature is a generic four-byte ICC signature value, the payload of a signatureType tag (cmsSignature).

func (Signature) String

func (s Signature) String() string

String renders the signature as four ASCII characters.

type Stage

type Stage struct {
	Type       StageSignature
	Implements StageSignature

	InputChannels  uint32
	OutputChannels uint32
	// contains filtered or unexported fields
}

Stage mirrors cmsStage (struct _cmsStage_struct): one multi-process element.

func StageAllocCLut16bit

func StageAllocCLut16bit(nGridPoints, inputChan, outputChan uint32, table []uint16) (*Stage, error)

StageAllocCLut16bit builds a uniform-grid 16-bit CLUT on the default context.

func StageAllocCLut16bitGranular

func StageAllocCLut16bitGranular(clutPoints []uint32, inputChan, outputChan uint32, table []uint16) (*Stage, error)

StageAllocCLut16bitGranular builds a granular 16-bit CLUT on the default context.

func StageAllocCLutFloat

func StageAllocCLutFloat(nGridPoints, inputChan, outputChan uint32, table []float32) (*Stage, error)

StageAllocCLutFloat builds a uniform-grid float CLUT on the default context.

func StageAllocCLutFloatGranular

func StageAllocCLutFloatGranular(clutPoints []uint32, inputChan, outputChan uint32, table []float32) (*Stage, error)

StageAllocCLutFloatGranular builds a granular float CLUT on the default context.

func StageAllocIdentity

func StageAllocIdentity(nChannels uint32) *Stage

StageAllocIdentity builds an identity stage on the default context.

func StageAllocMatrix

func StageAllocMatrix(rows, cols uint32, matrix, offset []float64) (*Stage, error)

StageAllocMatrix builds a matrix stage on the default context.

func StageAllocToneCurves

func StageAllocToneCurves(nChannels uint32, curves []*ToneCurve) (*Stage, error)

StageAllocToneCurves builds a curve-set stage on the default context.

func (*Stage) CLUTData

func (mpe *Stage) CLUTData() *stageCLutData

CLUTData returns a CLUT stage's payload, or nil.

func (*Stage) ContextID

func (mpe *Stage) ContextID() *Context

ContextID ports cmsGetStageContextID.

func (*Stage) Data

func (mpe *Stage) Data() any

Data ports cmsStageData.

func (*Stage) Free

func (mpe *Stage) Free()

Free ports cmsStageFree: a no-op under the Go garbage collector.

func (*Stage) GetToneCurves

func (mpe *Stage) GetToneCurves() []*ToneCurve

GetToneCurves ports _cmsStageGetPtrToCurveSet: the tone curves of a curve-set stage, or nil if this is not a curve-set stage.

func (*Stage) InputChannelsCount

func (mpe *Stage) InputChannelsCount() uint32

InputChannelsCount ports cmsStageInputChannels.

func (*Stage) MatrixData

func (mpe *Stage) MatrixData() (double, offset []float64)

MatrixData returns the matrix payload (row-major coefficients and optional offset) of a matrix stage, or nil, nil otherwise.

func (*Stage) Next

func (mpe *Stage) Next() *Stage

Next ports cmsStageNext.

func (*Stage) OutputChannelsCount

func (mpe *Stage) OutputChannelsCount() uint32

OutputChannelsCount ports cmsStageOutputChannels.

func (*Stage) SampleCLut16bit

func (mpe *Stage) SampleCLut16bit(sampler Sampler16, cargo any, dwFlags uint32) bool

SampleCLut16bit ports cmsStageSampleCLut16bit: sweep the whole grid, calling Sampler on each knot. Returns false if the sweep is aborted or the stage is malformed.

func (*Stage) SampleCLutFloat

func (mpe *Stage) SampleCLutFloat(sampler SamplerFloat, cargo any, dwFlags uint32) bool

SampleCLutFloat ports cmsStageSampleCLutFloat.

func (*Stage) StageType

func (mpe *Stage) StageType() StageSignature

StageType ports cmsStageType.

type StageLoc

type StageLoc int

StageLoc mirrors cmsStageLoc: where to insert / remove a stage.

const (
	AtBegin StageLoc = iota // cmsAT_BEGIN
	AtEnd                   // cmsAT_END
)

type StageSignature

type StageSignature uint32

StageSignature mirrors cmsStageSignature: the four-byte type tag of a multi-process element (pipeline stage).

const (
	SigCurveSetElemType      StageSignature = 0x63767374 // 'cvst'
	SigMatrixElemType        StageSignature = 0x6D617466 // 'matf'
	SigCLutElemType          StageSignature = 0x636C7574 // 'clut'
	SigBAcsElemType          StageSignature = 0x62414353 // 'bACS'
	SigEAcsElemType          StageSignature = 0x65414353 // 'eACS'
	SigXYZ2LabElemType       StageSignature = 0x6C327820 // 'l2x '
	SigLab2XYZElemType       StageSignature = 0x78326C20 // 'x2l '
	SigNamedColorElemType    StageSignature = 0x6E636C20 // 'ncl '
	SigLabV2toV4             StageSignature = 0x32203420 // '2 4 '
	SigLabV4toV2             StageSignature = 0x34203220 // '4 2 '
	SigIdentityElemType      StageSignature = 0x69646E20 // 'idn '
	SigLab2FloatPCS          StageSignature = 0x64326C20 // 'd2l '
	SigFloatPCS2Lab          StageSignature = 0x6C326420 // 'l2d '
	SigXYZ2FloatPCS          StageSignature = 0x64327820 // 'd2x '
	SigFloatPCS2XYZ          StageSignature = 0x78326420 // 'x2d '
	SigClipNegativesElemType StageSignature = 0x636C7020 // 'clp '
)

Stage element type signatures, mirroring the cmsStageSignature enum in include/lcms2.h.

type Stride

type Stride struct {
	BytesPerLineIn   uint32
	BytesPerLineOut  uint32
	BytesPerPlaneIn  uint32
	BytesPerPlaneOut uint32
}

Stride mirrors cmsStride: the per-line and per-plane byte strides handed to a transform worker.

type TagDescriptor

type TagDescriptor struct {
	// ElemCount is how many elements the tag's value array holds.
	ElemCount uint32
	// SupportedTypes lists, most-preferred first, the tag-type signatures this
	// tag may be stored as. At most maxTypesInPlugin are consulted.
	SupportedTypes []TagTypeSignature
	// DecideType, if non-nil, chooses the write type from the ICC version and
	// the value, overriding SupportedTypes[0]. Mirrors the DecideType pointer.
	DecideType func(iccVersion float64, data any) TagTypeSignature
}

TagDescriptor is the pure-Go analogue of cmsTagDescriptor. It describes how a tag maps to serialized types.

type TagSignature

type TagSignature uint32

TagSignature mirrors cmsTagSignature: the four-byte signature that names an entry in a profile's tag directory.

const (
	SigAToB0Tag                          TagSignature = 0x41324230 // 'A2B0'
	SigAToB1Tag                          TagSignature = 0x41324231 // 'A2B1'
	SigAToB2Tag                          TagSignature = 0x41324232 // 'A2B2'
	SigBlueColorantTag                   TagSignature = 0x6258595A // 'bXYZ'
	SigBlueMatrixColumnTag               TagSignature = 0x6258595A // 'bXYZ'
	SigBlueTRCTag                        TagSignature = 0x62545243 // 'bTRC'
	SigBToA0Tag                          TagSignature = 0x42324130 // 'B2A0'
	SigBToA1Tag                          TagSignature = 0x42324131 // 'B2A1'
	SigBToA2Tag                          TagSignature = 0x42324132 // 'B2A2'
	SigCalibrationDateTimeTag            TagSignature = 0x63616C74 // 'calt'
	SigCharTargetTag                     TagSignature = 0x74617267 // 'targ'
	SigChromaticAdaptationTag            TagSignature = 0x63686164 // 'chad'
	SigChromaticityTag                   TagSignature = 0x6368726D // 'chrm'
	SigColorantOrderTag                  TagSignature = 0x636C726F // 'clro'
	SigColorantTableTag                  TagSignature = 0x636C7274 // 'clrt'
	SigColorantTableOutTag               TagSignature = 0x636C6F74 // 'clot'
	SigColorimetricIntentImageStateTag   TagSignature = 0x63696973 // 'ciis'
	SigCopyrightTag                      TagSignature = 0x63707274 // 'cprt'
	SigCrdInfoTag                        TagSignature = 0x63726469 // 'crdi'
	SigDataTag                           TagSignature = 0x64617461 // 'data'
	SigDateTimeTag                       TagSignature = 0x6474696D // 'dtim'
	SigDeviceMfgDescTag                  TagSignature = 0x646D6E64 // 'dmnd'
	SigDeviceModelDescTag                TagSignature = 0x646D6464 // 'dmdd'
	SigDeviceSettingsTag                 TagSignature = 0x64657673 // 'devs'
	SigDToB0Tag                          TagSignature = 0x44324230 // 'D2B0'
	SigDToB1Tag                          TagSignature = 0x44324231 // 'D2B1'
	SigDToB2Tag                          TagSignature = 0x44324232 // 'D2B2'
	SigDToB3Tag                          TagSignature = 0x44324233 // 'D2B3'
	SigBToD0Tag                          TagSignature = 0x42324430 // 'B2D0'
	SigBToD1Tag                          TagSignature = 0x42324431 // 'B2D1'
	SigBToD2Tag                          TagSignature = 0x42324432 // 'B2D2'
	SigBToD3Tag                          TagSignature = 0x42324433 // 'B2D3'
	SigGamutTag                          TagSignature = 0x67616D74 // 'gamt'
	SigGrayTRCTag                        TagSignature = 0x6b545243 // 'kTRC'
	SigGreenColorantTag                  TagSignature = 0x6758595A // 'gXYZ'
	SigGreenMatrixColumnTag              TagSignature = 0x6758595A // 'gXYZ'
	SigGreenTRCTag                       TagSignature = 0x67545243 // 'gTRC'
	SigLuminanceTag                      TagSignature = 0x6C756d69 // 'lumi'
	SigMeasurementTag                    TagSignature = 0x6D656173 // 'meas'
	SigMediaBlackPointTag                TagSignature = 0x626B7074 // 'bkpt'
	SigMediaWhitePointTag                TagSignature = 0x77747074 // 'wtpt'
	SigNamedColorTag                     TagSignature = 0x6E636f6C // 'ncol'
	SigNamedColor2Tag                    TagSignature = 0x6E636C32 // 'ncl2'
	SigOutputResponseTag                 TagSignature = 0x72657370 // 'resp'
	SigPerceptualRenderingIntentGamutTag TagSignature = 0x72696730 // 'rig0'
	SigPreview0Tag                       TagSignature = 0x70726530 // 'pre0'
	SigPreview1Tag                       TagSignature = 0x70726531 // 'pre1'
	SigPreview2Tag                       TagSignature = 0x70726532 // 'pre2'
	SigProfileDescriptionTag             TagSignature = 0x64657363 // 'desc'
	SigProfileDescriptionMLTag           TagSignature = 0x6473636d // 'dscm'
	SigProfileSequenceDescTag            TagSignature = 0x70736571 // 'pseq'
	SigProfileSequenceIdTag              TagSignature = 0x70736964 // 'psid'
	SigPs2CRD0Tag                        TagSignature = 0x70736430 // 'psd0'
	SigPs2CRD1Tag                        TagSignature = 0x70736431 // 'psd1'
	SigPs2CRD2Tag                        TagSignature = 0x70736432 // 'psd2'
	SigPs2CRD3Tag                        TagSignature = 0x70736433 // 'psd3'
	SigPs2CSATag                         TagSignature = 0x70733273 // 'ps2s'
	SigPs2RenderingIntentTag             TagSignature = 0x70733269 // 'ps2i'
	SigRedColorantTag                    TagSignature = 0x7258595A // 'rXYZ'
	SigRedMatrixColumnTag                TagSignature = 0x7258595A // 'rXYZ'
	SigRedTRCTag                         TagSignature = 0x72545243 // 'rTRC'
	SigSaturationRenderingIntentGamutTag TagSignature = 0x72696732 // 'rig2'
	SigScreeningDescTag                  TagSignature = 0x73637264 // 'scrd'
	SigScreeningTag                      TagSignature = 0x7363726E // 'scrn'
	SigTechnologyTag                     TagSignature = 0x74656368 // 'tech'
	SigUcrBgTag                          TagSignature = 0x62666420 // 'bfd '
	SigViewingCondDescTag                TagSignature = 0x76756564 // 'vued'
	SigViewingConditionsTag              TagSignature = 0x76696577 // 'view'
	SigVcgtTag                           TagSignature = 0x76636774 // 'vcgt'
	SigMetaTag                           TagSignature = 0x6D657461 // 'meta'
	SigcicpTag                           TagSignature = 0x63696370 // 'cicp'
	SigArgyllArtsTag                     TagSignature = 0x61727473 // 'arts'
	SigMHC2Tag                           TagSignature = 0x4D484332 // 'MHC2'
)

ICC tag signatures (cmsTagSignature, include/lcms2.h). Values are the big-endian four-character codes.

func (TagSignature) String

func (s TagSignature) String() string

String renders the signature as four ASCII characters (big-endian order).

type TagTypeHandler

type TagTypeHandler struct {
	// Signature is the tag-type signature this handler serializes.
	Signature TagTypeSignature

	// Read allocates and reads a value from io. sizeOfTag is the number of bytes
	// available for the tag body (the 8-byte type base has already been
	// consumed). It returns the parsed value, the number of elements it
	// represents, and an error. Mirrors ReadPtr.
	Read func(self *TagTypeHandler, io *IOHandler, sizeOfTag uint32) (value any, count uint32, err error)

	// Write serializes nItems elements of value to io. Mirrors WritePtr.
	Write func(self *TagTypeHandler, io *IOHandler, value any, nItems uint32) error

	// Dup returns an independent copy of value (n elements). Mirrors DupPtr. In
	// Go, immutable values may return themselves. A nil return signals failure.
	Dup func(self *TagTypeHandler, value any, n uint32) (any, error)

	// Free releases any resources held by value. Mirrors FreePtr. Under the Go
	// garbage collector it is usually a no-op and may be nil.
	Free func(self *TagTypeHandler, value any)

	// ContextID and ICCVersion are stamped per call by the container.
	ContextID  *Context
	ICCVersion uint32
}

TagTypeHandler is the pure-Go analogue of cmsTagTypeHandler. It serializes and deserializes one tag type. The container copies the handler and stamps ContextID/ICCVersion before each call, exactly as cmsio0.c does with its LocalTypeHandler, so a handler's function fields must be reentrant and read those two fields from the self pointer rather than from captured state.

type TagTypeSignature

type TagTypeSignature uint32

TagTypeSignature mirrors cmsTagTypeSignature: the four-byte signature that identifies the serialized type of a tag's contents.

const (
	SigChromaticityType          TagTypeSignature = 0x6368726D // 'chrm'
	SigcicpType                  TagTypeSignature = 0x63696370 // 'cicp'
	SigColorantOrderType         TagTypeSignature = 0x636C726F // 'clro'
	SigColorantTableType         TagTypeSignature = 0x636C7274 // 'clrt'
	SigCrdInfoType               TagTypeSignature = 0x63726469 // 'crdi'
	SigCurveType                 TagTypeSignature = 0x63757276 // 'curv'
	SigDataType                  TagTypeSignature = 0x64617461 // 'data'
	SigDictType                  TagTypeSignature = 0x64696374 // 'dict'
	SigDateTimeType              TagTypeSignature = 0x6474696D // 'dtim'
	SigDeviceSettingsType        TagTypeSignature = 0x64657673 // 'devs'
	SigLut16Type                 TagTypeSignature = 0x6d667432 // 'mft2'
	SigLut8Type                  TagTypeSignature = 0x6d667431 // 'mft1'
	SigLutAtoBType               TagTypeSignature = 0x6d414220 // 'mAB '
	SigLutBtoAType               TagTypeSignature = 0x6d424120 // 'mBA '
	SigMeasurementType           TagTypeSignature = 0x6D656173 // 'meas'
	SigMultiLocalizedUnicodeType TagTypeSignature = 0x6D6C7563 // 'mluc'
	SigMultiProcessElementType   TagTypeSignature = 0x6D706574 // 'mpet'
	SigNamedColorType            TagTypeSignature = 0x6E636f6C // 'ncol'
	SigNamedColor2Type           TagTypeSignature = 0x6E636C32 // 'ncl2'
	SigParametricCurveType       TagTypeSignature = 0x70617261 // 'para'
	SigProfileSequenceDescType   TagTypeSignature = 0x70736571 // 'pseq'
	SigProfileSequenceIdType     TagTypeSignature = 0x70736964 // 'psid'
	SigResponseCurveSet16Type    TagTypeSignature = 0x72637332 // 'rcs2'
	SigS15Fixed16ArrayType       TagTypeSignature = 0x73663332 // 'sf32'
	SigScreeningType             TagTypeSignature = 0x7363726E // 'scrn'
	SigSignatureType             TagTypeSignature = 0x73696720 // 'sig '
	SigTextType                  TagTypeSignature = 0x74657874 // 'text'
	SigTextDescriptionType       TagTypeSignature = 0x64657363 // 'desc'
	SigU16Fixed16ArrayType       TagTypeSignature = 0x75663332 // 'uf32'
	SigUcrBgType                 TagTypeSignature = 0x62666420 // 'bfd '
	SigUInt16ArrayType           TagTypeSignature = 0x75693136 // 'ui16'
	SigUInt32ArrayType           TagTypeSignature = 0x75693332 // 'ui32'
	SigUInt64ArrayType           TagTypeSignature = 0x75693634 // 'ui64'
	SigUInt8ArrayType            TagTypeSignature = 0x75693038 // 'ui08'
	SigVcgtType                  TagTypeSignature = 0x76636774 // 'vcgt'
	SigViewingConditionsType     TagTypeSignature = 0x76696577 // 'view'
	SigXYZType                   TagTypeSignature = 0x58595A20 // 'XYZ '
	SigMHC2Type                  TagTypeSignature = 0x4D484332 // 'MHC2'
)

ICC tag-type signatures (cmsTagTypeSignature, include/lcms2.h).

func (TagTypeSignature) String

func (s TagTypeSignature) String() string

String renders the signature as four ASCII characters (big-endian order).

type ToneCurve

type ToneCurve struct {
	// contains filtered or unexported fields
}

ToneCurve mirrors cmsToneCurve (struct _cms_curve_struct). It keeps a limited-precision 16-bit table (Table16) for fast 8/16-bit transforms and, for segmented/parametric curves, the segment description used by the higher-precision floating-point evaluator.

func BuildGamma

func BuildGamma(gamma float64) (*ToneCurve, error)

BuildGamma builds a gamma curve on the default context.

func BuildParametricToneCurve

func BuildParametricToneCurve(typ int32, params []float64) (*ToneCurve, error)

BuildParametricToneCurve builds a parametric curve on the default context.

func BuildSegmentedToneCurve

func BuildSegmentedToneCurve(segments []CurveSegment) (*ToneCurve, error)

BuildSegmentedToneCurve builds a segmented tone curve on the default context.

func BuildTabulatedToneCurve16

func BuildTabulatedToneCurve16(values []uint16) (*ToneCurve, error)

BuildTabulatedToneCurve16 builds a 16-bit tabulated curve on the default context.

func BuildTabulatedToneCurveFloat

func BuildTabulatedToneCurveFloat(values []float32) (*ToneCurve, error)

BuildTabulatedToneCurveFloat builds a float tabulated curve on the default context.

func JoinToneCurve

func JoinToneCurve(x, y *ToneCurve, nResultingPoints uint32) (*ToneCurve, error)

JoinToneCurve joins two curves on the default context.

func (*ToneCurve) Dup

func (c *ToneCurve) Dup() (*ToneCurve, error)

Dup ports cmsDupToneCurve: an independent deep copy of the curve.

func (*ToneCurve) EstimateGamma

func (t *ToneCurve) EstimateGamma(precision float64) float64

EstimateGamma ports cmsEstimateGamma: least-squares estimate of the curve's effective gamma, or -1 if the fit's standard deviation exceeds precision (i.e. the curve is not well described by a single exponent).

func (*ToneCurve) EstimatedTable

func (t *ToneCurve) EstimatedTable() []uint16

EstimatedTable ports cmsGetToneCurveEstimatedTable: the low-resolution 16-bit table backing the curve. The slice aliases the curve's storage.

func (*ToneCurve) EstimatedTableEntries

func (t *ToneCurve) EstimatedTableEntries() uint32

EstimatedTableEntries ports cmsGetToneCurveEstimatedTableEntries.

func (*ToneCurve) Eval16

func (c *ToneCurve) Eval16(v uint16) uint16

Eval16 ports cmsEvalToneCurve16: evaluate the curve through its 16-bit interpolation params (the throughput path used by 8/16-bit transforms), dispatching through InterpParams.Interpolation.Lerp16 (LinLerp1D).

func (*ToneCurve) EvalFloat

func (c *ToneCurve) EvalFloat(v float32) float32

EvalFloat ports cmsEvalToneCurveFloat: evaluate the curve at v with high precision. Tabulated (segment-less) curves fall back to the 16-bit table.

func (*ToneCurve) Free

func (c *ToneCurve) Free()

Free ports cmsFreeToneCurve as a documented no-op: the Go garbage collector reclaims the curve. Kept only for API symmetry with the reference.

func (*ToneCurve) GetSegment

func (t *ToneCurve) GetSegment(n int32) *CurveSegment

GetSegment ports cmsGetToneCurveSegment: the n-th segment, or nil if out of range. The pointer aliases the curve's storage.

func (*ToneCurve) IsDescending

func (t *ToneCurve) IsDescending() bool

IsDescending ports cmsIsToneCurveDescending.

func (*ToneCurve) IsLinear

func (c *ToneCurve) IsLinear() bool

IsLinear ports cmsIsToneCurveLinear: true when the 16-bit table matches a linear ramp to within 12 bits (0x0f counts) at every node.

func (*ToneCurve) IsMonotonic

func (t *ToneCurve) IsMonotonic() bool

IsMonotonic ports cmsIsToneCurveMonotonic (allowing a 2-count ripple).

func (*ToneCurve) IsMultisegment

func (t *ToneCurve) IsMultisegment() bool

IsMultisegment ports cmsIsToneCurveMultisegment.

func (*ToneCurve) ParametricType

func (t *ToneCurve) ParametricType() int32

ParametricType ports cmsGetToneCurveParametricType: the parametric type of a single-segment curve, or 0 for multi-segment/tabulated curves.

func (*ToneCurve) Reverse

func (c *ToneCurve) Reverse() (*ToneCurve, error)

Reverse ports cmsReverseToneCurve: invert into a 4096-entry table.

func (*ToneCurve) ReverseEx

func (c *ToneCurve) ReverseEx(nResultSamples uint32) (*ToneCurve, error)

ReverseEx ports cmsReverseToneCurveEx: invert the curve into a table of nResultSamples entries. Single-segment curves of a known parametric type are inverted analytically; otherwise the 16-bit table is inverted numerically.

func (*ToneCurve) Smooth

func (t *ToneCurve) Smooth(lambda float64) error

Smooth ports cmsSmoothToneCurve: smooth a regularly-sampled curve in place. A negative lambda disables the monotonicity/degeneracy sanity checks (its magnitude is used). Returns nil on success; on a genuine failure it returns the error the reference would have signalled. Linear curves are left untouched (success). Mirrors the reference's SuccessStatus/notCheck logic.

type Transform

type Transform struct {
	InputFormat  uint32
	OutputFormat uint32

	// Lut is the full (optimized) transform pipeline.
	Lut *Pipeline

	// GamutCheck goes from the input space to a bilevel out-of-gamut marker.
	GamutCheck *Pipeline

	// Colorant tables (informational).
	InputColorant  *NamedColorList
	OutputColorant *NamedColorList

	// Informational only.
	EntryColorSpace ColorSpaceSignature
	ExitColorSpace  ColorSpaceSignature
	EntryWhitePoint CIEXYZ
	ExitWhitePoint  CIEXYZ

	// Profile sequence (kept when cmsFLAGS_KEEP_SEQUENCE is set).
	Sequence *ProfileSequence

	RenderingIntent uint32

	ContextID *Context
	// contains filtered or unexported fields
}

Transform is the pure-Go replacement for cmsHTRANSFORM (_cmsTRANSFORM). It is safe for concurrent DoTransform calls: no field is mutated during a transform. It must not be mutated (ChangeBuffersFormat, DeleteTransform) concurrently with a DoTransform.

func CreateMultiprofileTransform

func CreateMultiprofileTransform(profiles []*Profile, nProfiles,
	inputFormat, outputFormat, intent, dwFlags uint32) (*Transform, error)

CreateMultiprofileTransform ports cmsCreateMultiprofileTransform (default context).

func CreateProofingTransform

func CreateProofingTransform(
	input *Profile, inputFormat uint32,
	output *Profile, outputFormat uint32,
	proofing *Profile, nIntent, proofingIntent, dwFlags uint32) (*Transform, error)

CreateProofingTransform ports cmsCreateProofingTransform (profile context).

func CreateTransform

func CreateTransform(input *Profile, inputFormat uint32,
	output *Profile, outputFormat, intent, dwFlags uint32) (*Transform, error)

CreateTransform ports cmsCreateTransform (default/profile context).

func (*Transform) ChangeBuffersFormat

func (p *Transform) ChangeBuffersFormat(inputFormat, outputFormat uint32) error

ChangeBuffersFormat ports cmsChangeBuffersFormat: swap the input/output pixel formats of an existing (>= 16-bit) transform, rebuilding the formatters.

func (*Transform) DeleteTransform

func (p *Transform) DeleteTransform()

DeleteTransform ports cmsDeleteTransform. Under the Go GC there is nothing to free; the user-data free hook is still honoured for plug-in parity.

func (*Transform) DoTransform

func (p *Transform) DoTransform(in, out []byte, size uint32)

DoTransform ports cmsDoTransform: transform size pixels from in to out.

func (*Transform) DoTransformLineStride

func (p *Transform) DoTransformLineStride(in, out []byte,
	pixelsPerLine, lineCount,
	bytesPerLineIn, bytesPerLineOut,
	bytesPerPlaneIn, bytesPerPlaneOut uint32)

DoTransformLineStride ports cmsDoTransformLineStride: the full stride API.

func (*Transform) DoTransformStride

func (p *Transform) DoTransformStride(in, out []byte, size, strideBytes uint32)

DoTransformStride ports cmsDoTransformStride: the legacy planar stride entry.

func (*Transform) GetNamedColorList

func (p *Transform) GetNamedColorList() *NamedColorList

GetNamedColorList ports cmsGetNamedColorList: return the named-color list a named-color transform carries. The reference reads it straight off the first pipeline stage when that stage is a named-color element, and returns NULL for any other transform. Mirroring that keeps the accessor free of extra state on the Transform.

func (*Transform) GetTransformContextID

func (p *Transform) GetTransformContextID() *Context

GetTransformContextID ports cmsGetTransformContextID.

func (*Transform) GetTransformFlags

func (p *Transform) GetTransformFlags() uint32

GetTransformFlags ports _cmsGetTransformFlags.

func (*Transform) GetTransformFormatters16

func (p *Transform) GetTransformFormatters16() (fromInput, toOutput Formatter16)

GetTransformFormatters16 ports _cmsGetTransformFormatters16.

func (*Transform) GetTransformFormattersFloat

func (p *Transform) GetTransformFormattersFloat() (fromInput, toOutput FormatterFloat)

GetTransformFormattersFloat ports _cmsGetTransformFormattersFloat.

func (*Transform) GetTransformGamutCheckPipeline

func (p *Transform) GetTransformGamutCheckPipeline() *Pipeline

GetTransformGamutCheckPipeline ports cmsGetTransformGamutCheckPipeline.

func (*Transform) GetTransformInputColorants

func (p *Transform) GetTransformInputColorants() *NamedColorList

GetTransformInputColorants ports cmsGetTransformInputColorants.

func (*Transform) GetTransformInputFormat

func (p *Transform) GetTransformInputFormat() uint32

GetTransformInputFormat ports cmsGetTransformInputFormat.

func (*Transform) GetTransformOutputColorants

func (p *Transform) GetTransformOutputColorants() *NamedColorList

GetTransformOutputColorants ports cmsGetTransformOutputColorants.

func (*Transform) GetTransformOutputFormat

func (p *Transform) GetTransformOutputFormat() uint32

GetTransformOutputFormat ports cmsGetTransformOutputFormat.

func (*Transform) GetTransformPipeline

func (p *Transform) GetTransformPipeline() *Pipeline

GetTransformPipeline ports cmsGetTransformPipeline (read-only; do not free).

func (*Transform) GetTransformUserData

func (p *Transform) GetTransformUserData() any

GetTransformUserData ports _cmsGetTransformUserData.

func (*Transform) SetTransformUserData

func (p *Transform) SetTransformUserData(ptr any, freeFn func(ctx *Context, data any))

SetTransformUserData ports _cmsSetTransformUserData.

type UcrBg

type UcrBg struct {
	Ucr  *ToneCurve
	Bg   *ToneCurve
	Desc *MLU
}

UcrBg mirrors cmsUcrBg: under-color-removal and black-generation curves plus a description.

type VEC3

type VEC3 [3]float64

VEC3 is a 3-component vector of float64 (cmsVEC3).

func MAT3Eval

func MAT3Eval(a MAT3, v VEC3) VEC3

MAT3Eval evaluates the vector v across the matrix a, i.e. r = a*v (_cmsMAT3eval).

func MAT3Solve

func MAT3Solve(a MAT3, b VEC3) (x VEC3, ok bool)

MAT3Solve solves the system Ax = b, returning x and ok=false when A is singular (_cmsMAT3solve).

func VEC3Cross

func VEC3Cross(u, v VEC3) VEC3

VEC3Cross returns the cross product u x v (_cmsVEC3cross).

func VEC3Init

func VEC3Init(x, y, z float64) VEC3

VEC3Init builds a vector from its components (_cmsVEC3init).

func VEC3Minus

func VEC3Minus(a, b VEC3) VEC3

VEC3Minus returns a - b (_cmsVEC3minus).

type VideoSignalType

type VideoSignalType struct {
	ColourPrimaries         uint8
	TransferCharacteristics uint8
	MatrixCoefficients      uint8
	VideoFullRangeFlag      uint8
}

VideoSignalType mirrors cmsVideoSignalType (the 'cicp' tag).

type ViewingConditions

type ViewingConditions struct {
	WhitePoint CIEXYZ  // whitePoint
	Yb         float64 // Yb
	La         float64 // La
	Surround   uint32  // surround
	DValue     float64 // D_value
}

ViewingConditions mirrors cmsViewingConditions: the observing environment fed to cmsCIECAM02Init.

Directories

Path Synopsis
internal
oracletest
Package oracletest runs the reference lcms2 oracle harness (bin/lcms2_oracle) for differential tests.
Package oracletest runs the reference lcms2 oracle harness (bin/lcms2_oracle) for differential tests.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL