# Interface Compositor.Buffer

Enclosing class:
  `Compositor`

public static interface Compositor.Buffer
Buffer of pixels on which compositing operations can be performed.

Since:
  12 Feb 2013
Author:
  Mark Taylor

## Method Summary

Modifier and Type
Method
Description
`boolean`
`addSample(int index, float r, float g, float b, float alpha)`
Adds an RGBA sample to one pixel, using separate float scalars.
`boolean`
`addSample(int index, int rgba)`
Adds an RGBA sample to one pixel, using an RGBA integer.
`boolean`
`addSample(int index, int rgb, float alpha)`
Adds an RGBA sample to one pixel, using an RGB integer and separate float value.
`void`
`clear()`
Clears all samples from this buffer.
`int`
`toRgbInt(int index)`
Returns the result of compositing all the added samples as a non-premultiplied ARGB integer.

## Method Details

### clear

void clear()
Clears all samples from this buffer.

### addSample

boolean addSample(int index, float r, float g, float b, float alpha)
Adds an RGBA sample to one pixel, using separate float scalars.

Parameters:
  `index` - pixel index
  `r` - red value, 0-1
  `g` - green value, 0-1
  `b` - blue value, 0-1
  `alpha` - alpha value, 0-1
Returns:
  true if saturation has been reached, that is further samples added to this pixel will have no effect

### addSample

boolean addSample(int index, int rgb, float alpha)
Adds an RGBA sample to one pixel, using an RGB integer and separate float value.

Parameters:
  `index` - pixel index
  `rgb` - integer containing RGB in lower 24 bits; highest byte is ignored
  `alpha` - alpha value, 0-1
Returns:
  true if saturation has been reached, that is further samples added to this pixel will have no effect

### addSample

boolean addSample(int index, int rgba)
Adds an RGBA sample to one pixel, using an RGBA integer.

Parameters:
  `index` - pixel index
  `rgba` - integer containing RGBA values one per byte
Returns:
  true if saturation has been reached, that is further samples added to this pixel will have no effect

### toRgbInt

int toRgbInt(int index)
Returns the result of compositing all the added samples as a non-premultiplied ARGB integer. This is suitable for use with `BufferedImage` `setRGB` methods) or, more efficiently, an `RgbImage` buffer.

Parameters:
  `index` - pixel index
Returns:
  ARGB integer