package bimage

  1. Overview
  2. Docs

Source file color.ml

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
type 'a t = { t : 'a; channels : int; has_alpha : bool }

let create ~has_alpha ~channels t = { t; channels; has_alpha }

let has_alpha { has_alpha; _ } = has_alpha

let channels { channels; _ } = channels

let t { t; _ } = t

type gray = [ `Gray ]

type rgb = [ `Rgb ]

type rgb_packed = [ `Rgb_packed ]

type yuv = [ `Yuv ]

type xyz = [ `Xyz ]

type rgba = [ `Rgba ]

type any = [ `Any ]

let gray = create ~has_alpha:false ~channels:1 `Gray

let rgb = create ~has_alpha:false ~channels:3 `Rgb

let yuv = create ~has_alpha:false ~channels:3 `Yuv

let xyz = create ~has_alpha:false ~channels:3 `Xyz

let rgba = create ~has_alpha:false ~channels:4 `Rgba

let rgb_packed = create ~has_alpha:false ~channels:1 `Rgb_packed

let color n = create ~has_alpha:(n = 4) ~channels:n `Any

let[@inline] channels_of_color : type a. a t -> int =
 fun { channels; _ } -> channels
OCaml

Innovation. Community. Security.