riff:   A wrapper to the FLIF library.
1 Common FLIF Functions
_  FLIF-IMAGE
flif?
flif-create-image
flif-create-image-rgb
flif-create-image-gray
flif-create-image-gray16
flif-create-image-palette
flif-create-image-hdr
flif-import-image-rgba!
flif-import-image-rgb!
flif-import-image-gray!
flif-import-image-gray16!
flif-import-image-palette!
flif-destroy-image!
flif-image-get-width
flif-image-get-height
flif-image-get-nb-channels
flif-image-get-palette-size
flif-image-get-palette
flif-image-set-palette!
flif-image-get-depth
flif-image-get-frame-delay
flif-image-set-frame-delay!
flif-image-get-metadata
flif-image-set-metadata!
flif-image-free-metadata!
flif-image-write-row-palette8!
flif-image-read-row-palette8!
flif-image-read-palette8
flif-image-write-row-gray8!
flif-image-read-row-gray8!
flif-image-read-gray8
flif-image-write-row-rgba8!
flif-image-read-row-rgba8!
flif-image-read-rgba8
flif-image-write-row-rgba16!
flif-image-read-row-rgba16!
flif-image-read-rgba16
flif-image-write-row-gray16!
flif-image-read-row-gray16!
flif-image-read-gray16
flif-free-memory!
2 Decoder Functions
_  callback-t
_  FLIF-DECODER
_  FLIF-INFO
flif-animated?
flif-create-decoder
flif-decoder-decode-file!
flif-decoder-decode-memory!
flif-decoder-decode-filepointer!
flif-decoder-num-images
flif-decoder-num-loops
flif-decoder-get-image
flif-decoder-generate-preview
flif-destroy-decoder!
flif-abort-decoder!
flif-decoder-set-crc-check!
flif-decoder-set-quality!
flif-decoder-set-scale!
flif-decoder-set-resize!
flif-decoder-set-fit!
flif-decoder-set-callback!
flif-decoder-set-first-callback-quality!
flif-read-info-from-memory
flif-destroy-info!
flif-dimensions
flif-info-get-width
flif-info-get-height
flif-info-get-nb-channels
flif-info-get-depth
flif-info-num-images
3 Encoder Functions
_  FLIF-ENCODER
flif-create-encoder
flif-encoder-add-image!
flif-encoder-add-image-move!
flif-encoder-encode-file!
flif-encoder-encode-memory
flif-destroy-encoder!
flif-encoder-set-interlaced!
flif-encoder-set-learn-repeat!
flif-encoder-set-auto-color-buckets!
flif-encoder-set-palette-size!
flif-encoder-set-lookback!
flif-encoder-set-divisor!
flif-encoder-set-min-size!
flif-encoder-set-split-threshold!
flif-encoder-set-alpha-zero-lossless!
flif-encoder-set-chance-cutoff!
flif-encoder-set-chance-alpha!
flif-encoder-set-crc-check!
flif-encoder-set-channel-compact!
flif-encoder-set-ycocg!
flif-encoder-set-frame-shape!
flif-encoder-set-lossy!
Index
6.12

riff: A wrapper to the FLIF library.

Lehi Toskin

 (require riff) package: riff
riff is a simple wrapper to the FLIF library, providing a mostly C-like interface.

    1 Common FLIF Functions

    2 Decoder Functions

    3 Encoder Functions

    Index

1 Common FLIF Functions

value

_FLIF-IMAGE : ctype?

This ctype is the basis for the functions in this section. It is associated with an image itself - either from file or its bytes.

procedure

(flif? img)  boolean?

  img : any/c
Determines if the given file has a FLIF header.

procedure

(flif-create-image width height)  _FLIF-IMAGE

  width : integer?
  height : integer?

procedure

(flif-create-image-rgb width height)  _FLIF-IMAGE

  width : integer?
  height : integer?

procedure

(flif-create-image-gray width height)  _FLIF-IMAGE

  width : integer?
  height : integer?

procedure

(flif-create-image-gray16 width height)  _FLIF-IMAGE

  width : integer?
  height : integer?

procedure

(flif-create-image-palette width height)  _FLIF-IMAGE

  width : integer?
  height : integer?

procedure

(flif-create-image-hdr width height)  _FLIF-IMAGE

  width : integer?
  height : integer?
Creates a pointer to a _FLIF-IMAGE struct. Note: flif-create-image is RGBA.

procedure

(flif-import-image-rgba! width    
  height    
  rgba    
  stride)  _FLIF-IMAGE
  width : integer?
  height : integer?
  rgba : bytes?
  stride : integer?

procedure

(flif-import-image-rgb! width    
  height    
  rgb    
  stride)  _FLIF-IMAGE
  width : integer?
  height : integer?
  rgb : bytes?
  stride : integer?

procedure

(flif-import-image-gray! width    
  height    
  gray    
  stride)  _FLIF-IMAGE
  width : integer?
  height : integer?
  gray : bytes?
  stride : integer?

procedure

(flif-import-image-gray16! width    
  height    
  gray    
  stride)  _FLIF-IMAGE
  width : integer?
  height : integer?
  gray : bytes?
  stride : integer?

procedure

(flif-import-image-palette! width    
  height    
  palette    
  stride)  _FLIF-IMAGE
  width : integer?
  height : integer?
  palette : bytes?
  stride : integer?
Creates a pointer to a _FLIF-IMAGE struct by importing the associated bytes.

procedure

(flif-destroy-image! image)  void?

  image : _FLIF-IMAGE
Destroy the image pointer.

procedure

(flif-image-get-width image)  integer?

  image : _FLIF-IMAGE

procedure

(flif-image-get-height image)  integer?

  image : _FLIF-IMAGE

procedure

(flif-image-get-nb-channels image)  integer?

  image : _FLIF-IMAGE
Gets the associated information from the image pointer.

procedure

(flif-image-get-palette-size image)  integer?

  image : _FLIF-IMAGE
Gets the size of the palette from the image pointer, where 0 means no palette and 1 - 256 means nb of colors in the palette.

procedure

(flif-image-get-palette image)  bytes?

  image : _FLIF-IMAGE
Gets the bytes of the image palette from a newly-created byte buffer, allocated with flif-image-get-palette-size.

procedure

(flif-image-set-palette! image buffer)  void?

  image : _FLIF-IMAGE
  buffer : bytes?
Puts the RGBA bytes into the image pointer (must be (* 4 palette-size) in size).

procedure

(flif-image-get-depth image)  integer?

  image : _FLIF-IMAGE
Gets the bit-depth of the image (e.g. 8).

procedure

(flif-image-get-frame-delay image)  integer?

  image : _FLIF-IMAGE

procedure

(flif-image-set-frame-delay! image    
  frame-delay)  void?
  image : _FLIF-IMAGE
  frame-delay : integer?
Gets or sets the frame delay for an image. Only applicable for FLIF images with animation.

procedure

(flif-image-get-metadata image chunkname)  bytes?

  image : _FLIF-IMAGE
  chunkname : string?
Gets the metadata from the image from a newly-created pointer that is passed to the FFI.

procedure

(flif-image-set-metadata! image    
  chunkname    
  data)  void?
  image : _FLIF-IMAGE
  chunkname : string?
  data : bytes?
Sets the metadata for the image.

procedure

(flif-image-free-metadata! image data)  void?

  image : _FLIF-IMAGE
  data : cpointer?
Free the data pointer returned by flif-image-get-metadata – this function is largely worthless because there is no pointer to free and it is visible to the garbage collector anyway. However, just for gits and shiggles, I added this function to the end of flif-image-get-metadata to free the generated data pointer.

procedure

(flif-image-write-row-palette8! image    
  row    
  buffer)  void?
  image : _FLIF-IMAGE
  row : integer?
  buffer : bytes?

procedure

(flif-image-read-row-palette8! image    
  row    
  buffer    
  len)  bytes?
  image : _FLIF-IMAGE
  row : integer?
  buffer : cpointer?
  len : integer?

procedure

(flif-image-read-palette8 image    
  width    
  height)  bytes?
  image : _FLIF-IMAGE
  width : integer?
  height : integer?

procedure

(flif-image-write-row-gray8! image    
  row    
  buffer)  void?
  image : _FLIF-IMAGE
  row : integer?
  buffer : bytes?

procedure

(flif-image-read-row-gray8! image    
  row    
  buffer    
  len)  bytes?
  image : _FLIF-IMAGE
  row : integer?
  buffer : cpointer?
  len : integer?

procedure

(flif-image-read-gray8 image width height)  bytes?

  image : _FLIF-IMAGE
  width : integer?
  height : integer?

procedure

(flif-image-write-row-rgba8! image    
  row    
  buffer)  void?
  image : _FLIF-IMAGE
  row : integer?
  buffer : bytes?

procedure

(flif-image-read-row-rgba8! image    
  row    
  buffer    
  len)  bytes?
  image : _FLIF-IMAGE
  row : integer?
  buffer : cpointer?
  len : integer?

procedure

(flif-image-read-rgba8 image width height)  bytes?

  image : _FLIF-IMAGE
  width : integer?
  height : integer?
Read or write 8-bit depth image data. read-row-type functions will return a byte string of length len with the row pixels inside, while read-type functions will reaturn a byte string width x height in size.

procedure

(flif-image-write-row-rgba16! image    
  row    
  buffer)  void?
  image : _FLIF-IMAGE
  row : integer?
  buffer : cpointer?

procedure

(flif-image-read-row-rgba16! image    
  row    
  buffer    
  len)  bytes?
  image : _FLIF-IMAGE
  row : integer?
  buffer : cpointer?
  len : integer?

procedure

(flif-image-read-rgba16 image width height)  bytes?

  image : _FLIF-IMAGE
  width : integer?
  height : integer?

procedure

(flif-image-write-row-gray16! image    
  row    
  buffer)  void?
  image : _FLIF-IMAGE
  row : integer?
  buffer : cpointer?

procedure

(flif-image-read-row-gray16! image    
  row    
  buffer    
  len)  void?
  image : _FLIF-IMAGE
  row : integer?
  buffer : cpointer?
  len : integer?

procedure

(flif-image-read-gray16 image width height)  bytes?

  image : _FLIF-IMAGE
  width : integer?
  height : integer?
Read or write 16-bit depth image data. read-row-type functions will return a byte string of length len with the row pixels inside, while read-type functions will reaturn a byte string width x height in size.

procedure

(flif-free-memory! buffer)  void?

  buffer : cpointer?
Free the memory located inside the buffer gcpointer. Again, this is kind of a useless function.

2 Decoder Functions

procedure

(_callback-t quality    
  bytes-read    
  decode-over?    
  user-data    
  context)  integer?
  quality : integer?
  bytes-read : integer?
  decode-over? : boolean?
  user-data : cpointer?
  context : cpointer?
The generalized form of the progressive callback function.

value

_FLIF-DECODER : ctype?

value

_FLIF-INFO : ctype?

These ctypes are the basis for the functions in this section. They keep track of the image you are working on.

procedure

(flif-animated? img)  boolean?

  img : flif?
Determine if the FLIF image provided is animated.

procedure

(flif-create-decoder)  _FLIF-DECODER

Create a new pointer to a _FLIF-DECODER struct.

procedure

(flif-decoder-decode-file! decoder file)  boolean?

  decoder : _FLIF-DECODER
  file : string?

procedure

(flif-decoder-decode-memory! decoder    
  buffer)  boolean?
  decoder : _FLIF-DECODER
  buffer : bytes?

procedure

(flif-decoder-decode-filepointer! decoder    
  filepointer    
  filename)  boolean?
  decoder : _FLIF-DECODER
  filepointer : cpointer?
  filename : string?
Decode the FLIF either from a string to the file, from its bytes, or from a filepointer.

procedure

(flif-decoder-num-images decoder)  integer?

  decoder : _FLIF-DECODER
Obtain the number of frames in the FLIF.

procedure

(flif-decoder-num-loops decoder)  integer?

  decoder : _FLIF-DECODER
The number of times the FLIF animation should be looped (0 indicates the FLIF should be looped forever).

procedure

(flif-decoder-get-image decoder index)  _FLIF-IMAGE

  decoder : _FLIF-DECODER
  index : integer?
Obtain the _FLIF-IMAGE pointer to the frame located at index.

procedure

(flif-decoder-generate-preview context)  void?

  context : cpointer?
Generate a preview to display.

procedure

(flif-destroy-decoder! decoder)  void?

  decoder : _FLIF-DECODER
Free memory associated with the pointer.

procedure

(flif-abort-decoder! decoder)  void?

  decoder : _FLIF-DECODER
Abort the decoder (may be used before decoding is complete).

procedure

(flif-decoder-set-crc-check! decoder    
  check?)  void?
  decoder : _FLIF-DECODER
  check? : boolean?
Set whether the decoder should check the CRC. The default behavior is to not check the CRC.

procedure

(flif-decoder-set-quality! decoder quality)  void?

  decoder : _FLIF-DECODER
  quality : (integer-in 0 100)
Set the decoder quality.

procedure

(flif-decoder-set-scale! decoder scale)  void?

  decoder : _FLIF-DECODER
  scale : integer?
Set the decoder scale. scale must be a number that is a power of 2: 1, 2, 4, 8, 16 ...

procedure

(flif-decoder-set-resize! decoder resize)  void?

  decoder : _FLIF-DECODER
  resize : integer?
Set the decoder resize.

procedure

(flif-decoder-set-fit! decoder fit)  void?

  decoder : _FLIF-DECODER
  fit : integer?
Set the decoder fit.

procedure

(flif-decoder-set-callback! decoder    
  callback    
  user-data)  void?
  decoder : _FLIF-DECODER
  callback : _callback-t
  user-data : ctype?
Set the decoder callback. Useful for progressive decoding where the callback is called at every new level of quality achieved.

procedure

(flif-decoder-set-first-callback-quality! decoder    
  quality)  void?
  decoder : _FLIF-DECODER
  quality : integer?
Set the first quality level to send to the decoder callback. Note: setting decoder quality is different from setting the initial callback quality.

procedure

(flif-read-info-from-memory buffer)  _FLIF-INFO

  buffer : bytes?
Generate an info pointer with information gained from buffer.

procedure

(flif-destroy-info! info)  void?

  info : _FLIF-INFO
Destroy the info pointer.

procedure

(flif-dimensions img)  list?

  img : flif?
Read width and height information from img. This procedure is provided because the flif-info C functions can be finicky and may report incorrect values if the image has not yet been decoded.

procedure

(flif-info-get-width info)  integer?

  info : _FLIF-INFO

procedure

(flif-info-get-height info)  integer?

  info : _FLIF-INFO

procedure

(flif-info-get-nb-channels info)  integer?

  info : _FLIF-INFO

procedure

(flif-info-get-depth info)  integer?

  info : _FLIF-INFO

procedure

(flif-info-num-images info)  integer?

  info : _FLIF-INFO
Obtain various data from the info pointer.

3 Encoder Functions

value

_FLIF-ENCODER : ctype?

This ctype is the basis for the functions in this section. It is associated with an image itself - either from file or its bytes.

procedure

(flif-create-encoder)  _FLIF-ENCODER

Create a pointer to an encoder struct.

procedure

(flif-encoder-add-image! encoder image)  void?

  encoder : _FLIF-ENCODER
  image : _FLIF-IMAGE
Add the image onto the encoder — add more than one image to create an animation. This function will clone the image (so the input image is not touched and you have to flif-destroy-image! on it yourself to free the memory).

procedure

(flif-encoder-add-image-move! encoder    
  image)  void?
  encoder : _FLIF-ENCODER
  image : _FLIF-IMAGE
Add the image onto the encoder — add more than one image to create an animation. This function will move the image (input image becomes invalid during encode and flif-destroy-encoder! will free it.

procedure

(flif-encoder-encode-file! encoder    
  filename)  void?
  encoder : _FLIF-ENCODER
  filename : string?
Encode to the supplied filename.

procedure

(flif-encoder-encode-memory encoder)  bytes?

  encoder : _FLIF-ENCODER
Encode to a newly-generated byte string. If the encoding fails, it will raise-result-error.

procedure

(flif-destroy-encoder! encoder)  void?

  encoder : _FLIF-ENCODER
Destroy the encoder pointer.

procedure

(flif-encoder-set-interlaced! encoder    
  interlaced?)  void?
  encoder : _FLIF-ENCODER
  interlaced? : boolean?
Set whether the image is interlaced or non-interlaced (default is #t).

procedure

(flif-encoder-set-learn-repeat! encoder    
  learn)  void?
  encoder : _FLIF-ENCODER
  learn : integer?
Set how many times FLIF should learn the MANIAC tree (default is 2).

procedure

(flif-encoder-set-auto-color-buckets! encoder    
  acb?)  void?
  encoder : _FLIF-ENCODER
  acb? : boolean?
Default is #t.

procedure

(flif-encoder-set-palette-size! encoder    
  size)  void?
  encoder : _FLIF-ENCODER
  size : integer?
Default is 512, the max.

procedure

(flif-encoder-set-lookback! encoder    
  looback?)  void?
  encoder : _FLIF-ENCODER
  looback? : boolean?
Default is #t.

procedure

(flif-encoder-set-divisor! encoder divisor)  void?

  encoder : _FLIF-ENCODER
  divisor : integer?
Default is 30.

procedure

(flif-encoder-set-min-size! encoder size)  void?

  encoder : _FLIF-ENCODER
  size : integer?
Default is 50.

procedure

(flif-encoder-set-split-threshold! encoder    
  split)  void?
  encoder : _FLIF-ENCODER
  split : integer?
Default is 64.

procedure

(flif-encoder-set-alpha-zero-lossless! encoder    
  azl)  void?
  encoder : _FLIF-ENCODER
  azl : boolean?
Default is #f.

procedure

(flif-encoder-set-chance-cutoff! encoder    
  cutoff)  void?
  encoder : _FLIF-ENCODER
  cutoff : integer?
Default is 2.

procedure

(flif-encoder-set-chance-alpha! encoder    
  alpha)  void?
  encoder : _FLIF-ENCODER
  alpha : integer?
Default is 19.

procedure

(flif-encoder-set-crc-check! encoder    
  check?)  void?
  encoder : _FLIF-ENCODER
  check? : boolean?
Set whether or not a CRC check should be added.

procedure

(flif-encoder-set-channel-compact! encoder    
  plc?)  void?
  encoder : _FLIF-ENCODER
  plc? : boolean?
Default is #t.

procedure

(flif-encoder-set-ycocg! encoder ycocg?)  void?

  encoder : _FLIF-ENCODER
  ycocg? : boolean?
Default is #t.

procedure

(flif-encoder-set-frame-shape! encoder    
  shape?)  void?
  encoder : _FLIF-ENCODER
  shape? : boolean?
Default is #t.

procedure

(flif-encoder-set-lossy! encoder loss)  void?

  encoder : _FLIF-ENCODER
  loss : integer?
Set the amount of quality loss: 0 means no loss and 100 means maximum loss. Negative values indicate adaptive lossy (second image should be the saliency map). Default is 0.

Index

A B C D E F G H I J K L M N O P Q R S T U V W X Y Z

 

_callback-t
_FLIF-DECODER
_FLIF-ENCODER
_FLIF-IMAGE
_FLIF-INFO
Common FLIF Functions
Decoder Functions
Encoder Functions
flif-abort-decoder!
flif-animated?
flif-create-decoder
flif-create-encoder
flif-create-image
flif-create-image-gray
flif-create-image-gray16
flif-create-image-hdr
flif-create-image-palette
flif-create-image-rgb
flif-decoder-decode-file!
flif-decoder-decode-filepointer!
flif-decoder-decode-memory!
flif-decoder-generate-preview
flif-decoder-get-image
flif-decoder-num-images
flif-decoder-num-loops
flif-decoder-set-callback!
flif-decoder-set-crc-check!
flif-decoder-set-first-callback-quality!
flif-decoder-set-fit!
flif-decoder-set-quality!
flif-decoder-set-resize!
flif-decoder-set-scale!
flif-destroy-decoder!
flif-destroy-encoder!
flif-destroy-image!
flif-destroy-info!
flif-dimensions
flif-encoder-add-image!
flif-encoder-add-image-move!
flif-encoder-encode-file!
flif-encoder-encode-memory
flif-encoder-set-alpha-zero-lossless!
flif-encoder-set-auto-color-buckets!
flif-encoder-set-chance-alpha!
flif-encoder-set-chance-cutoff!
flif-encoder-set-channel-compact!
flif-encoder-set-crc-check!
flif-encoder-set-divisor!
flif-encoder-set-frame-shape!
flif-encoder-set-interlaced!
flif-encoder-set-learn-repeat!
flif-encoder-set-lookback!
flif-encoder-set-lossy!
flif-encoder-set-min-size!
flif-encoder-set-palette-size!
flif-encoder-set-split-threshold!
flif-encoder-set-ycocg!
flif-free-memory!
flif-image-free-metadata!
flif-image-get-depth
flif-image-get-frame-delay
flif-image-get-height
flif-image-get-metadata
flif-image-get-nb-channels
flif-image-get-palette
flif-image-get-palette-size
flif-image-get-width
flif-image-read-gray16
flif-image-read-gray8
flif-image-read-palette8
flif-image-read-rgba16
flif-image-read-rgba8
flif-image-read-row-gray16!
flif-image-read-row-gray8!
flif-image-read-row-palette8!
flif-image-read-row-rgba16!
flif-image-read-row-rgba8!
flif-image-set-frame-delay!
flif-image-set-metadata!
flif-image-set-palette!
flif-image-write-row-gray16!
flif-image-write-row-gray8!
flif-image-write-row-palette8!
flif-image-write-row-rgba16!
flif-image-write-row-rgba8!
flif-import-image-gray!
flif-import-image-gray16!
flif-import-image-palette!
flif-import-image-rgb!
flif-import-image-rgba!
flif-info-get-depth
flif-info-get-height
flif-info-get-nb-channels
flif-info-get-width
flif-info-num-images
flif-read-info-from-memory
flif?
riff
riff: A wrapper to the FLIF library.