module Sample: sig
.. end
Sample semantics and formats.
Sample semantics
type
semantics = [ `Color of Gg.Color.profile * bool | `Other of string * int ]
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
val rgba_l : semantics
rgba_l
is for linear RGB samples from the
Gg.Color.p_rgb_l
profile with an alpha component.
val gray_l : semantics
val graya_l : semantics
graya_l
is for linear Gray samples from the
Gg.Color.p_gray_l
luminance with an alpha component.
val pp_semantics : Format.formatter -> semantics -> unit
pp_sample_semantics ppf sem
prints a textual representation of sem
on ppf
.
Sample format
type
pack = [ `FourCC of string * Gg.Ba.scalar_type option
| `Other of string * Gg.Ba.scalar_type option
| `PU8888 ]
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 : 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 -> Gg.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
Gg.Raster.Sample.pack
.
Raises Invalid_argument
if
pack
is incompatible with
st
,
see
Gg.Raster.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 -> Gg.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 Gg.size1 | `D2 of Gg.size2 | `D3 of Gg.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
Gg.Raster.v
for their description.
Raises Invalid_argument
if
sf
is packed.
val pp_format : Format.formatter -> format -> unit
pp_format ppf sf
prints a textual representation of sf
on ppf
.