Module Raster.Sample

Sample semantics and formats.

Sample semantics

type semantics = [
  1. | `Other of string * int
  2. | `Color of Color.profile * bool
]

The type for sample semantics.

  • `Color (p, alpha) is for color samples from the color profile p. alpha indicates if there's an alpha component on the right of the color components.
  • `Other(label, dim) is for samples of dim dimension identified by label.
val rgb_l : semantics

rgb_l is for linear RGB samples from the Color.p_rgb_l profile.

val rgba_l : semantics

rgba_l is for linear RGB samples from the Color.p_rgb_l profile with an alpha component.

val gray_l : semantics

gray_l is for linear Gray samples from the Color.p_gray_l profile.

val graya_l : semantics

graya_l is for linear Gray samples from the Color.p_gray_l luminance with an alpha component.

val pp_semantics : Stdlib.Format.formatter -> semantics -> unit

pp_sample_semantics ppf sem prints a textual representation of sem on ppf.

Sample format

type pack = [
  1. | `PU8888
  2. | `FourCC of string * Ba.scalar_type option
  3. | `Other of string * Ba.scalar_type option
]

The type for sample packs. A sample pack describes storage for samples that do not use one scalar per component.

  • `PU8888. An arbitrary 4D sample X, Y, Z, W with unsigned 8 bits components packed in a single `UInt32 scalar as 0xXXYYZZWWl.
  • `FourCC(code, restrict). A sample is stored according to the format specified by the FourCC code, a string of length 4. If restrict is specified the pack can only be used with the corresponding scalar type. For example `FourCC("DXT5", Some `UInt64) can be used to specify a buffer of DXT5 compressed data. `FourCC can also be used to describe the numerous YUV packed pixel formats.
  • `Other(label, restrict). A sample is stored in some other packing scheme identified by label, restrict has the same meaning as in `FourCC.
val pp_pack : Stdlib.Format.formatter -> pack -> unit

pp_pack ppf pack prints a textual representation of pack on ppf.

type format

The type for sample formats.

val format : ?pack:pack -> semantics -> Ba.scalar_type -> format

format pack sem st is a sample format with semantics sem and scalar type st. If pack is absent one scalar of type st per sample component is used. If present, see Sample.pack.

Raises Invalid_argument if pack is incompatible with st, see Sample.pack or if a pack `FourCC code is not made of 4 bytes.

val semantics : format -> semantics

semantics sf is sf's semantics.

val scalar_type : format -> Ba.scalar_type

scalar_type sf is sf's buffer scalar type

val pack : format -> pack option

pack sf is sf's sample pack, if any.

val dim : format -> int

dim sf is sf's sample dimension.

val scalar_count : ?first:int -> ?w_stride:int -> ?h_stride:int -> [ `D1 of size1 | `D2 of size2 | `D3 of size3 ] -> format -> int

sf_scalar_count first w_stride h_stride size sf is the minimal number of scalars needed to hold a raster data with the corresponding parameters, see v for their description.

Raises Invalid_argument if sf is packed.

val pp_format : Stdlib.Format.formatter -> format -> unit

pp_format ppf sf prints a textual representation of sf on ppf.