coloricc

package
v0.1.3 Latest Latest
Warning

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

Go to latest
Published: Sep 24, 2026 License: Apache-2.0 Imports: 8 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package coloricc 提供基于 ICC 色彩配置文件的设备颜色到 sRGB 的转换。 使用纯 Go 的 github.com/kovidgoyal/imaging/prism/meta/icc 引擎,不依赖 cgo。

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DeviceCMYKToRGB

func DeviceCMYKToRGB(c, m, y, k float64) (float64, float64, float64)

DeviceCMYKToRGB 用 Adobe/poppler 的 4 色印刷矩阵模型把 CMYK 油墨量(0-1) 转换为 sRGB 分量(0-1)。当没有可用的 ICC 配置文件时,internal/pdf2ofd 与 internal/render 都回退到该模型,保证同一 CMYK 颜色在两条路径上一致。

纯色结果与印刷色一致:纯青 (0,173,239)、纯品红 (236,0,140)、纯黄 (255,242,0)、 纯黑 (35,31,32)。相比逐油墨独立吸收的近似模型,混合色(尤其青 + 黄得到的绿) 更接近 poppler/Adobe 的渲染结果。

Types

type Transformer

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

Transformer 把某个设备颜色空间(1/3/4 通道)的颜色转换为 sRGB。

func DefaultCMYK

func DefaultCMYK() (*Transformer, error)

DefaultCMYK 返回用于 DeviceCMYK(无内嵌配置文件)的默认转换器。

只有当显式设置环境变量 OFD_CMYK_ICC 指向一个 ICC 配置文件时才启用; 不做隐式的系统路径扫描,避免同一文档在不同机器上转换结果不一致。 未设置或加载失败时返回 (nil, nil),调用方应回退到近似油墨模型。

func New

func New(profileData []byte, inputChannels int) (*Transformer, error)

New 解析 ICC 配置文件并按输入通道数创建到 sRGB 的转换管线。 inputChannels 必须与配置文件的颜色空间一致(GRAY=1、RGB=3、CMYK=4)。 相同配置文件与通道数的转换器会被缓存复用。

func (*Transformer) ToRGB

func (t *Transformer) ToRGB(components []uint8) (uint8, uint8, uint8)

ToRGB 把分量(0-255)转换为 sRGB 分量(0-255)。

Jump to

Keyboard shortcuts

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