# Class GifEncoder

java.lang.Object
javajs.img.ImageEncoder
javajs.img.GifEncoder

All Implemented Interfaces:
  `GenericImageEncoder`

public class GifEncoder extends ImageEncoder
GifEncoder extensively adapted for Jmol by Bob Hanson Color quantization roughly follows the GIMP method "dither Floyd-Steinberg (normal)" but with some twists. (For example, we exclude the background color.) Note that although GIMP code annotation refers to "median-cut", it is really using MEAN-cut. That is what I use here as well. -- commented code allows visualization of the color space using Jmol. Very enlightening! -- much simplified interface with ImageEncoder -- uses simple Hashtable with Integer() to catalog colors -- allows progressive production of animated GIF via Jmol CAPTURE command -- uses general purpose javajs.util.OutputChannel for byte-handling options such as posting to a server, writing to disk, and retrieving bytes. -- allows JavaScript port -- Bob Hanson, first try: 24 Sep 2013; final coding: 9 Nov 2014

Author:
  Bob Hanson hansonr@stolaf.edu

## Field Summary

### Fields inherited from class ImageEncoder

`date, doClose, dpi, height, logging, out, pixels, quality, width`

## Constructor Summary

Constructors
Constructor
Description
`GifEncoder()`

## Method Summary

Modifier and Type
Method
Description
`protected void`
`close()`
`protected void`
`flushBytes()`
`protected void`
`generate()`
`P3`
`labToXyz(P3 lab, P3 xyz)`
`P3`
`rgbToXyz(P3 rgb, P3 xyz)`
`protected void`
`setParams(Map<String,Object> params)`
we allow for animated GIF by being able to re-enter the code with different parameters held in params
`protected P3`
`toLABnorm(int rgb)`
////////////////////// CIE Lab / XYZ / sRGB conversion methods /////////
`protected P3`
`toRGB(P3 lab)`
`P3`
`xyzToLab(P3 xyz, P3 lab)`
`P3`
`xyzToRgb(P3 xyz, P3 rgb)`

### Methods inherited from class ImageEncoder

`createImage, putByte, putString`

### Methods inherited from class Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

## Constructor Details

### GifEncoder

public GifEncoder()

## Method Details

### setParams

protected void setParams(Map<String,Object> params)
we allow for animated GIF by being able to re-enter the code with different parameters held in params

Specified by:
  `setParams` in class `ImageEncoder`

### generate

protected void generate() throws IOException

Specified by:
  `generate` in class `ImageEncoder`
Throws:
  `IOException`

### close

protected void close()

Overrides:
  `close` in class `ImageEncoder`

### toLABnorm

protected P3 toLABnorm(int rgb)
////////////////////// CIE Lab / XYZ / sRGB conversion methods /////////

### toRGB

protected P3 toRGB(P3 lab)

### rgbToXyz

public P3 rgbToXyz(P3 rgb, P3 xyz)

### xyzToRgb

public P3 xyzToRgb(P3 xyz, P3 rgb)

### xyzToLab

public P3 xyzToLab(P3 xyz, P3 lab)

### labToXyz

public P3 labToXyz(P3 lab, P3 xyz)

### flushBytes

protected void flushBytes()