package camlimages

  1. Overview
  2. Docs
Legend:
Page
Library
Module
Module type
Parameter
Class
Class type
Source

Module ImagesSource

The image data structure definition.

Sourceexception Out_of_image

Exception for illegal point access

Sourceexception Wrong_image_type

Exception for illegal internal image type

Sourceexception Wrong_file_type

Exception for unsupported image FILE format

Sourcetype t =
  1. | Index8 of Index8.t
  2. | Rgb24 of Rgb24.t
  3. | Index16 of Index16.t
  4. | Rgba32 of Rgba32.t
  5. | Cmyk32 of Cmyk32.t
    (*

    Generic image type

    *)
Sourcetype sequence = {
  1. seq_width : int;
  2. seq_height : int;
  3. seq_frames : frame list;
  4. seq_loops : int;
}
Sourceand frame = {
  1. frame_left : int;
  2. frame_top : int;
  3. frame_image : t;
  4. frame_delay : int;
}
Sourcetype rgb = Color.rgb = {
  1. mutable r : int;
  2. mutable g : int;
  3. mutable b : int;
}

Colors: the copies of color.mli

Sourcetype rgba = Color.rgba = {
  1. color : rgb;
  2. mutable alpha : int;
}
Sourcetype cmyk = Color.cmyk = {
  1. mutable c : int;
  2. mutable m : int;
  3. mutable y : int;
  4. mutable k : int;
}
Sourcetype 'a map = 'a Color.map = {
  1. mutable max : int;
  2. mutable map : 'a array;
}
Sourcetype format =
  1. | Gif
  2. | Bmp
  3. | Jpeg
  4. | Tiff
  5. | Png
  6. | Xpm
  7. | Ppm
  8. | Ps

Image formats

Sourceval extension : format -> string

Functions for filename extensions

returns the corresponding extension "gif", "bmp" etc. for given format

Sourceval guess_format : string -> format

returns the image format guessed from the file extension of a given file name

Sourceval get_extension : string -> string * string

Lower interface

Sourceval guess_extension : string -> format
Sourcetype colormodel = Info.colormodel =
  1. | Gray
  2. | RGB
  3. | Index
  4. | GrayA
  5. | RGBA
  6. | YCbCr
  7. | CMYK
Sourcetype info = Info.info =
  1. | Info_DPI of float
    (*

    dot per inch

    *)
  2. | Info_BigEndian
  3. | Info_LittleEndian
    (*

    endianness of image file

    *)
  4. | Info_ColorModel of colormodel
    (*

    color model of image file

    *)
  5. | Info_Depth of int
    (*

    Image bit depth

    *)
  6. | Info_Corrupted
    (*

    For corrupted PNG files

    *)

Infos attached to bitmaps

Sourceval dpi : info list -> float option

Info query

Sourcetype header = {
  1. header_width : int;
  2. header_height : int;
  3. header_infos : info list;
}

Image file header

Sourceval file_format : string -> format * header

file_format filename reads the header of image file filename and returns its format and some useful information found in the header (ex. width, height). file_format does not read image contents, but just quickly returns file header information.

file_format does not depend on any external libraries

Sourcetype load_option =
  1. | Load_Progress of float -> unit
    (*

    For progress meters

    *)
  2. | Load_Resolution of float * float
    (*

    Pixel/Inch for rasterization of PS

    *)
  3. | Load_only_the_first_frame
    (*

    Load only the first frame of an animation

    *)

Load options

Sourcetype save_option =
  1. | Save_Quality of int
    (*

    Save quality for Jpeg compression

    *)
  2. | Save_Progress of float -> unit
    (*

    For progress meters

    *)
  3. | Save_Interlace
    (*

    Interlaced Gif

    *)

Save options

Sourceval load_progress : load_option list -> (float -> unit) option

Option queries

Sourceval load_resolution : load_option list -> (float * float) option
Sourceval save_progress : save_option list -> (float -> unit) option
Sourceval save_interlace : save_option list -> bool
Sourceval save_quality : save_option list -> int option
Sourcetype format_methods = {
  1. check_header : string -> header;
  2. load : (string -> load_option list -> t) option;
  3. save : (string -> save_option list -> t -> unit) option;
  4. load_sequence : (string -> load_option list -> sequence) option;
  5. save_sequence : (string -> save_option list -> sequence -> unit) option;
}
Sourceval add_methods : format -> format_methods -> unit

If you write new drivers for some image format, use this function to register their loading/saving functions into the libaray

Sourceval load : string -> load_option list -> t

load filename options read the header of an image file filename, loads the image by calling corresponding loading method, and returns it. If the file format is not supported by the library, a Wrong_file_type exception will be raised. You can specify loading options in options such as progressive meter function.

Sourceval save : string -> format option -> save_option list -> t -> unit

save filename formatopt options image saves image into a file filename. The image format can be specified by formatopt. If formatopt is Some format, then format is used. If it is None, then the image format is guessed from filename. You can specify some saving parameters options. Some options are specific to some image formats and do not work with the others.

Sourceval load_sequence : string -> load_option list -> sequence
Sourceval save_sequence : string -> format option -> save_option list -> sequence -> unit
Sourceval unoptimize_sequence : sequence -> sequence
Sourceval size : t -> int * int

Returns size (width and height) of image

Sourceval destroy : t -> unit

Free the image. If you turn on image swapping (see bitmap.mli), you can call this function explicitly to tell the library that this image is no longer used. (This is not required, though.)

Sourceval sub : t -> int -> int -> int -> int -> t

sub dst x y width height returns sub-bitmap of dst, at (x, y) - (x + width - 1, y + height - 1).

Sourceval blit : t -> int -> int -> t -> int -> int -> int -> int -> unit

blit src sx sy dst dx dy width height copies the rectangle region of src at (sx, sy) - (sx + width - 1, sy + height - 1) to dst, at (dx, dy) - (dx + width - 1, dy + height - 1).

Sourceval blocks : t -> int * int
OCaml

Innovation. Community. Security.